Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
node_modules/
.venv/
a.out
CMakeUserPresets.json
Expand Down
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |




---
Expand Down
46 changes: 23 additions & 23 deletions benchmarks/node-benchmark-results.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/\ Grafana /‾‾/
/\ / \ |\ __ / /
/ \/ \ | |/ / / ‾‾\
/\ Grafana /‾‾/
/\ / \ |\ __ / /
/ \/ \ | |/ / / ‾‾\
/ \ | ( | (‾) |
/ __________ \ |_|\_\ \_____/
/ __________ \ |_|\_\ \_____/

execution: local
script: k6.js
Expand All @@ -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
4 changes: 3 additions & 1 deletion benchmarks/node_server/server.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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");
});
}
8 changes: 7 additions & 1 deletion k6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Loading