From 12f307600cc78aa33457e93834ec2c59532fd6d1 Mon Sep 17 00:00:00 2001 From: James Yab Date: Wed, 31 Dec 2025 11:35:31 -0500 Subject: [PATCH 1/4] Remove TLS for the node server --- benchmarks/node_server/server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/benchmarks/node_server/server.js b/benchmarks/node_server/server.js index e8d929d..7a5bfce 100644 --- a/benchmarks/node_server/server.js +++ b/benchmarks/node_server/server.js @@ -1,6 +1,7 @@ import cluster from "node:cluster"; import os from "node:os"; import express from "express"; +import http from "http"; if (cluster.isPrimary) { const numCPUs = os.cpus().length; @@ -17,7 +18,8 @@ if (cluster.isPrimary) { }); }); - app.listen(3490, () => { + // disable TLS + http.createServer(app).listen(3490, () => { console.log("Express server listening on http://localhost:3490"); }); } From 1c6437d69b87358c4a054c69a876cc2c600857ae Mon Sep 17 00:00:00 2001 From: James Yab Date: Wed, 31 Dec 2025 11:35:45 -0500 Subject: [PATCH 2/4] Add node_modules to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4f9c8cb..725dcdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +node_modules/ .venv/ a.out CMakeUserPresets.json From a97ec41db68e61f2821b56127294247800b7e77f Mon Sep 17 00:00:00 2001 From: James Yab Date: Wed, 31 Dec 2025 11:36:08 -0500 Subject: [PATCH 3/4] Add randomization to the benchmark --- k6.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/k6.js b/k6.js index 8246f69..f488567 100644 --- a/k6.js +++ b/k6.js @@ -18,8 +18,14 @@ export const options = { }, }; +function rand(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} + export default function () { - const res = http.post("http://localhost:3490/test2/123/foo/432"); + const res = http.post(`http://localhost:3490/test2/${rand(0,999)}/foo/123`); check(res, { "response code was 200": (res) => res.status == 200, }); From 5aaec05503dbd6fe87365b11d52055de5385e909 Mon Sep 17 00:00:00 2001 From: James Yab Date: Wed, 31 Dec 2025 11:37:49 -0500 Subject: [PATCH 4/4] Update the node server benchmark using the server without TLS --- README.md | 39 ++++++++++++----------- benchmarks/node-benchmark-results.txt | 46 +++++++++++++-------------- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 6a49c5d..f78dc45 100644 --- a/README.md +++ b/README.md @@ -73,25 +73,26 @@ As such, these results demonstrate that the server can reliably handle at least I made sure that the node express server implemented multi-threading to provide a more fair comparison with the cpp_http_server. Check out `benchmarks/node_server` to see the node express server implementation. -The cpp_http_server is ~1.693x faster in throughput or about 69.3% higher request rate. Nice! - -Calculation: 29,675.882135 RPS / 17,524.167725 RPS = ~1.693 - -| Metric | **C++ Server (updated)** | **Node + Express** | -| ------------------ | ------------------------ | ------------------ | -| Target RPS | 30,000.00 | 30,000.00 | -| Actual RPS | 29,675.882135 | 17,524.167725 | -| Total requests | 296,824 | 176,924 | -| Dropped iterations | 3,180 | 123,126 | -| Avg latency | 1.12 ms | 46.88 ms | -| Median latency | 404.76 µs | 34.1 ms | -| p90 latency | 3.24 ms | 103.24 ms | -| p95 latency | 4.3 ms | 132.88 ms | -| p99 latency | 6.58 ms | 192.68 ms | -| Max latency | 22.7 ms | 445.75 ms | -| Error rate | 0.00% | 0.00% | -| Peak VUs | 332 | 1,693 | -| Iterations/sec | 29,675.882135 | 17,524.167725 | +The cpp_http_server is ~1.45x faster in throughput or about 44.9% higher request rate. Nice! + +Calculation: 29,675.882135 RPS / 20,468.045127 RPS = ~1.449 + +| Metric | **C++ Server** | **Node + Express** | +|--------------------|----------------|--------------------| +| Target RPS | 30,000.00 | 30,000.00 | +| Actual RPS | 29,675.882135 | 20,468.045127 | +| Total requests | 296,824 | 205,983 | +| Dropped iterations | 3,180 | 123,126 | +| Avg latency | 1.12 ms | 38.99 ms | +| Median latency | 404.76 µs | 30.25 ms | +| p90 latency | 3.24 ms | 81.37 ms | +| p95 latency | 4.3 ms | 102.58 ms | +| p99 latency | 6.58 ms | 149.76 ms | +| Max latency | 22.7 ms | 318.66 ms | +| Error rate | 0.00% | 0.00% | +| Peak VUs | 332 | 1,547 | + + --- diff --git a/benchmarks/node-benchmark-results.txt b/benchmarks/node-benchmark-results.txt index 4bf335b..8af982f 100644 --- a/benchmarks/node-benchmark-results.txt +++ b/benchmarks/node-benchmark-results.txt @@ -1,9 +1,9 @@ - /\ Grafana /‾‾/ - /\ / \ |\ __ / / - / \/ \ | |/ / / ‾‾\ + /\ Grafana /‾‾/ + /\ / \ |\ __ / / + / \/ \ | |/ / / ‾‾\ / \ | ( | (‾) | - / __________ \ |_|\_\ \_____/ + / __________ \ |_|\_\ \_____/ execution: local script: k6.js @@ -14,42 +14,42 @@ - █ THRESHOLDS + █ THRESHOLDS http_req_duration - ✓ 'p(99)<1000' p(99)=192.68ms + ✓ 'p(99)<1000' p(99)=149.76ms http_req_failed ✓ 'rate<0.01' rate=0.00% - █ TOTAL RESULTS + █ TOTAL RESULTS - checks_total.......: 176924 17524.167725/s - checks_succeeded...: 100.00% 176924 out of 176924 - checks_failed......: 0.00% 0 out of 176924 + checks_total.......: 205983 20468.045127/s + checks_succeeded...: 100.00% 205983 out of 205983 + checks_failed......: 0.00% 0 out of 205983 ✓ response code was 200 HTTP - http_req_duration..............: avg=46.88ms min=180.69µs med=34.1ms max=445.75ms p(90)=103.24ms p(95)=132.88ms - { expected_response:true }...: avg=46.88ms min=180.69µs med=34.1ms max=445.75ms p(90)=103.24ms p(95)=132.88ms - http_req_failed................: 0.00% 0 out of 176924 - http_reqs......................: 176924 17524.167725/s + http_req_duration..............: avg=38.99ms min=221µs med=30.25ms max=318.66ms p(90)=81.37ms p(95)=102.58ms + { expected_response:true }...: avg=38.99ms min=221µs med=30.25ms max=318.66ms p(90)=81.37ms p(95)=102.58ms + http_req_failed................: 0.00% 0 out of 205983 + http_reqs......................: 205983 20468.045127/s EXECUTION - dropped_iterations.............: 123126 12195.522797/s - iteration_duration.............: avg=50.97ms min=253.76µs med=37.01ms max=468.22ms p(90)=112.5ms p(95)=142.84ms - iterations.....................: 176924 17524.167725/s - vus............................: 1679 min=249 max=1679 - vus_max........................: 1693 min=474 max=1693 + dropped_iterations.............: 94056 9346.122993/s + iteration_duration.............: avg=42.23ms min=299.06µs med=32.98ms max=338.26ms p(90)=87.68ms p(95)=109.67ms + iterations.....................: 205983 20468.045127/s + vus............................: 1494 min=446 max=1494 + vus_max........................: 1547 min=453 max=1547 NETWORK - data_received..................: 46 MB 4.6 MB/s - data_sent......................: 19 MB 1.9 MB/s + data_received..................: 54 MB 5.3 MB/s + data_sent......................: 22 MB 2.2 MB/s -running (10.1s), 00000/01695 VUs, 176924 complete and 0 interrupted iterations -constant_request_rate ✓ [ 100% ] 00000/01695 VUs 10s 30000.00 iters/s +running (10.1s), 00000/01549 VUs, 205983 complete and 0 interrupted iterations +constant_request_rate ✓ [ 100% ] 00000/01549 VUs 10s 30000.00 iters/s