nanoexpress/nanoexpress

Performance slowdown on Docker

dalisoft opened this issue · 1 comments

Bug Report

Minimal reproducible repository

See https://github.com/nanoexpress/nanoexpress-vps-bench

Current Behavior

When comparing between native and Docker code execution difference is does 100% for me. After patching command it differs only ~35%. Looks like not a much difference, but it's a lot

Expected behavior/code

Maximum ~10% performance difference

Environment

  • Node/npm version: Node.js v10+
  • OS: Ubuntu, Debian, WSL2 Ubuntu/Debian
  • Addinational Info: Docker causes this

Possible Solution

Run code outside Docker, try use pm2 and cluster or Threaded mode

Additional context/Screenshots

See wrk results

Docker
~ 
❯ wrk -c8 -t8 -d60  http://localhost:4200/time
Running 1m test @ http://localhost:4200/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   188.99us  218.96us  17.18ms   97.72%
    Req/Sec     5.88k   472.61     8.56k    82.54%
  2808875 requests in 1.00m, 736.66MB read
Requests/sec:  46736.89
Transfer/sec:     12.26MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4100/time
Running 1m test @ http://localhost:4100/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    71.53us   48.08us   7.54ms   98.93%
    Req/Sec    14.10k   320.84    14.62k    84.90%
  6745752 requests in 1.00m, 0.90GB read
Requests/sec: 112243.11
Transfer/sec:     15.31MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4300/time
Running 1m test @ http://localhost:4300/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    62.87us   37.68us   8.32ms   98.91%
    Req/Sec    15.88k   274.27    16.46k    84.59%
  7597597 requests in 1.00m, 695.58MB read
Requests/sec: 126417.81
Transfer/sec:     11.57MB
~ took 1m 
❯ 
Native on host
~ 
❯ wrk -c8 -t8 -d60  http://localhost:4200/time
Running 1m test @ http://localhost:4200/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   158.28us  234.08us  16.64ms   98.04%
    Req/Sec     7.13k     1.27k    9.79k    54.36%
  3408243 requests in 1.00m, 0.87GB read
Requests/sec:  56709.17
Transfer/sec:     14.87MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4100/time
Running 1m test @ http://localhost:4100/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    42.81us  483.85us  55.51ms   99.94%
    Req/Sec    27.49k   678.37    29.27k    83.59%
  13154310 requests in 1.00m, 1.75GB read
Requests/sec: 218875.77
Transfer/sec:     29.85MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4300/time
Running 1m test @ http://localhost:4300/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    38.90us  394.14us  46.63ms   99.71%
    Req/Sec    33.28k     1.16k   36.65k    86.69%
  15918839 requests in 1.00m, 1.42GB read
Requests/sec: 264874.76
Transfer/sec:     24.25MB
~ took 1m 
❯ 

As this is Docker issue, not nanoexpress, it's can be closed, but will be pinned