Description
Discussed in https://github.com/orgs/nodejs/discussions/56956
Originally posted by 759325100 February 8, 2025
I want to upgrade my project from Node v16.19.1 to Node 22.13.1, before upgrading I did a benchmark to measure performance changes after the upgrade (http server)
But I got a bad result. The performance of Node V22 has a significant decline compared to Node V16 (specifically referring to http scenarios)
Below is the environment and results of my test. I hope you can get your answers. Thank you.
Docker run node v22.13.1 alpine(3.20) on Ubuntu 16.04.7 LTS(8cpu 16G)
Docker run node v16.19.1 alpine(3.12) on Ubuntu 16.04.7 LTS(8cpu 16G)
Docker run script (The contents in the docker image are basically the same)
docker run --name=node-v22 --rm -it -p 30255:3000 dockerhub.xx/node:22.13.1 /bin/ash
docker run --name=node-v16 --rm -it -p 30256:3000 dockerhub.xx/node:16.19.1 /bin/ash
create app.js content
const http = require('http');
// create HTTP server
const server = http.createServer((req, res) => {
// set response header
res.writeHead(200, { 'Content-Type': 'text/plain' });
// send "Hello World" to client
res.end('Hello World');
});
// listen 3000 port
server.listen(3000, () => {
console.log('Server running at http://localhost:3000/');
});
run
node app.js
Throughput testing using abtest.
# n = 1000 or 2000
ab -n 100000 -c n http://localhost:30256/
# n = 1000 or 2000
ab -n 100000 -c n http://localhost:30255/
Test Result
Node V16 2000 concurrent
Server Software:
Server Hostname: localhost
Server Port: 30256
Document Path: /
Document Length: 11 bytes
Concurrency Level: 2000
Time taken for tests: 26.451 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 11200000 bytes
HTML transferred: 1100000 bytes
Requests per second: 3780.59 [#/sec] (mean)
Time per request: 529.018 [ms] (mean)
Time per request: 0.265 [ms] (mean, across all concurrent requests)
Transfer rate: 413.50 [Kbytes/sec] received
Node V22 2000 concurrent
Server Software:
Server Hostname: localhost
Server Port: 30255
Document Path: /
Document Length: 11 bytes
Concurrency Level: 2000
Time taken for tests: 51.655 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 11200000 bytes
HTML transferred: 1100000 bytes
Requests per second: 1935.93 [#/sec] (mean)
Time per request: 1033.096 [ms] (mean)
Time per request: 0.517 [ms] (mean, across all concurrent requests)
Transfer rate: 211.74 [Kbytes/sec] received
I've tested it many times and the results are basically the same.
Can anyone tell me the reason or a more standard test method
Thank for everyone