Compare http and uws.
use http module to create server.
'use strict';
const http = require('http');
const server = http.createServer((req, res) => {
res.end('OK');
});
server.listen(7000, () => console.log('http server started'));
use uws module to create server.
'use strict';
const { http } = require('uws');
const server = http.createServer((req, res) => {
res.end('OK');
});
server.listen(7000, () => console.log('http server started'));
Then, I use the ab to test ab -n 10000 -c 50 http://127.0.0.1:7000/
Result:
use http.
Concurrency Level: 50
Time taken for tests: 1.936 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 770000 bytes
HTML transferred: 20000 bytes
Requests per second: 5165.36 [#/sec] (mean)
Time per request: 9.680 [ms] (mean)
Time per request: 0.194 [ms] (mean, across all concurrent requests)
Transfer rate: 388.41 [Kbytes/sec] received
use uws.
Concurrency Level: 50
Time taken for tests: 401.269 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 400000 bytes
HTML transferred: 20000 bytes
Requests per second: 24.92 [#/sec] (mean)
Time per request: 2006.346 [ms] (mean)
Time per request: 40.127 [ms] (mean, across all concurrent requests)
Transfer rate: 0.97 [Kbytes/sec] received
but I use wrk锛宼he result is: the requests/sec of uws is more than http.
wrk -t8 -c100 -d30s http://localhost:7000
use http.
Running 30s test @ http://localhost:7000
8 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 7.92ms 1.62ms 64.24ms 93.52%
Req/Sec 1.53k 159.28 2.52k 80.25%
365487 requests in 30.03s, 35.20MB read
Requests/sec: 12170.21
Transfer/sec: 1.17MB
use uws.
```bash
Running 30s test @ http://localhost:7000
8 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 3.00ms 581.60us 17.16ms 84.33%
Req/Sec 4.00k 488.38 5.81k 83.42%
956109 requests in 30.02s, 36.47MB read
Requests/sec: 31850.10
Transfer/sec: 1.21MB
Hi there,
Using ab is not recommended these days. It's single-threaded and inconsistent in its own reporting. On the other hand, wrk is multi-threaded and far more capable of tracking accurate throughput.
Here's a list of many other benchmarking tools if you'd like more options for testing :)
thx!
Most helpful comment
thx!