Polka: Why uws's requests per second is less than native http.

Created on 14 Jun 2018  路  3Comments  路  Source: lukeed/polka

Compare http and uws.

  1. 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'));
    
  2. 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:

  1. 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
    
  2. 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
    

Most helpful comment

thx!

All 3 comments

but I use wrk锛宼he result is: the requests/sec of uws is more than http.

wrk -t8 -c100 -d30s http://localhost:7000

  1. 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
    
  2. 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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alekbarszczewski picture alekbarszczewski  路  3Comments

kevinfiol picture kevinfiol  路  3Comments

ansarizafar picture ansarizafar  路  3Comments

flawyte picture flawyte  路  7Comments

ASaiAnudeep picture ASaiAnudeep  路  4Comments