From 90359e3907ab22eb62ab924f5dce72c0c3adccf8 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Mon, 6 Jul 2026 23:48:19 -0500 Subject: [PATCH] docs(bench): regenerate BENCHMARKS.md with NestJS (express + fastify) rows Signed-off-by: Diego Resendez --- BENCHMARKS.md | 60 ++++++---- bench/results.json | 284 +++++++++++++++++++++++++++++++-------------- 2 files changed, 231 insertions(+), 113 deletions(-) diff --git a/BENCHMARKS.md b/BENCHMARKS.md index 3133702..d5d02e4 100644 --- a/BENCHMARKS.md +++ b/BENCHMARKS.md @@ -5,7 +5,7 @@ ## Environment - **Date**: 2026-07-07 -- **Commit**: daa13f6 +- **Commit**: fe1831a - **Node**: v22.22.2 - **OS**: darwin - **CPU**: Apple M4 Max (16 cores) @@ -29,56 +29,64 @@ | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | --- | --- | --- | --- | --- | --- | --- | -| raw-http | 116,166 | 0.00 | 1.00 | 1.00 | 0.6% | 115,590–117,242 | -| green-tea | 97,760 | 0.00 | 1.00 | 2.00 | 0.3% | 97,094–97,837 | -| fastify | 86,470 | 1.00 | 2.00 | 2.00 | 0.3% | 86,202–86,829 | -| express | 24,005 | 3.00 | 6.00 | 9.00 | 0.3% | 23,989–24,136 | +| raw-http | 115,398 | 0.00 | 1.00 | 1.00 | 0.3% | 114,822–115,539 | +| green-tea | 98,093 | 0.00 | 1.00 | 2.00 | 0.3% | 98,054–98,669 | +| nestjs-fastify | 95,034 | 1.00 | 1.00 | 2.00 | 0.5% | 94,240–95,264 | +| fastify | 86,765 | 1.00 | 2.00 | 2.00 | 0.3% | 86,496–87,123 | +| express | 24,366 | 3.00 | 5.00 | 8.00 | 0.2% | 24,283–24,418 | +| nestjs-express | 21,762 | 4.00 | 6.00 | 10.00 | 0.4% | 21,698–21,896 | ### Route param | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | --- | --- | --- | --- | --- | --- | --- | -| raw-http | 117,024 | 0.00 | 1.00 | 1.00 | 0.3% | 116,538–117,242 | -| green-tea | 92,384 | 1.00 | 2.00 | 2.00 | 0.5% | 91,795–92,998 | -| fastify | 85,754 | 1.00 | 2.00 | 2.00 | 0.3% | 85,651–86,317 | -| express | 23,666 | 4.00 | 5.00 | 8.00 | 0.1% | 23,666–23,720 | +| raw-http | 116,333 | 0.00 | 1.00 | 1.00 | 0.2% | 115,974–116,410 | +| green-tea | 93,434 | 1.00 | 2.00 | 2.00 | 0.2% | 93,152–93,613 | +| nestjs-fastify | 89,312 | 1.00 | 2.00 | 2.00 | 0.1% | 89,235–89,530 | +| fastify | 86,278 | 1.00 | 2.00 | 2.00 | 0.3% | 86,138–86,765 | +| express | 23,835 | 3.00 | 5.00 | 8.00 | 0.5% | 23,803–24,046 | +| nestjs-express | 20,955 | 4.00 | 6.00 | 11.00 | 0.6% | 20,949–21,202 | ### Pipeline (3 steps) (approximation) | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | --- | --- | --- | --- | --- | --- | --- | -| raw-http | 114,157 | 0.00 | 1.00 | 1.00 | 0.2% | 113,862–114,554 | -| fastify | 84,320 | 1.00 | 2.00 | 2.00 | 0.1% | 84,269–84,422 | -| green-tea | 83,962 | 1.00 | 2.00 | 2.00 | 0.4% | 83,590–84,358 | -| express | 23,829 | 4.00 | 5.00 | 8.00 | 0.1% | 23,768–23,851 | +| raw-http | 113,491 | 0.00 | 1.00 | 1.00 | 0.8% | 112,531–114,810 | +| nestjs-fastify | 87,328 | 1.00 | 2.00 | 2.00 | 0.4% | 86,867–87,661 | +| fastify | 85,024 | 1.00 | 2.00 | 2.00 | 0.3% | 84,512–85,178 | +| green-tea | 84,896 | 1.00 | 2.00 | 2.00 | 0.5% | 84,243–85,267 | +| express | 23,950 | 3.00 | 5.00 | 8.00 | 0.2% | 23,902–24,011 | +| nestjs-express | 20,824 | 4.00 | 6.00 | 11.00 | 0.1% | 20,805–20,878 | ### POST JSON + validation | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | --- | --- | --- | --- | --- | --- | --- | -| raw-http | 100,230 | 0.00 | 1.00 | 2.00 | 0.1% | 100,064–100,294 | -| green-tea | 76,243 | 1.00 | 2.00 | 2.00 | 0.2% | 76,192–76,550 | -| fastify | 63,222 | 1.00 | 2.00 | 3.00 | 0.7% | 62,307–63,229 | -| express | 19,870 | 4.00 | 7.00 | 23.00 | 0.3% | 19,758–19,883 | +| raw-http | 100,141 | 0.00 | 1.00 | 2.00 | 0.2% | 99,846–100,294 | +| green-tea | 77,178 | 1.00 | 2.00 | 2.00 | 0.1% | 77,126–77,254 | +| fastify | 63,722 | 1.00 | 2.00 | 3.00 | 0.1% | 63,574–63,760 | +| nestjs-fastify | 59,146 | 1.00 | 3.00 | 3.00 | 0.3% | 59,005–59,376 | +| express | 20,098 | 4.00 | 6.00 | 12.00 | 0.2% | 20,056–20,174 | +| nestjs-express | 18,856 | 5.00 | 7.00 | 30.00 | 0.5% | 18,853–19,067 | ## Step-scaling (green-tea) | Path | Steps | req/s | | --- | --- | --- | -| /steps/0 | 0 | 91,386 | +| /steps/0 | 0 | 92,282 | | /steps/3 | 3 | 81,530 | -| /steps/5 | 5 | 72,237 | +| /steps/5 | 5 | 71,994 | -Each additional pipeline step costs roughly 3,830 req/s (-21.0% over 5 steps), on this box. +Each additional pipeline step costs roughly 4,058 req/s (-22.0% over 5 steps), on this box. ## Cost of secure-by-default (green-tea) | Label | req/s | | --- | --- | -| security:false (parity) | 97,760 | -| security:true (default) | 93,306 | +| security:false (parity) | 98,093 | +| security:true (default) | 92,998 | -The real cost of running secure-by-default (rather than the parity-mode `security:false` used above) is ~4.6% req/s on this box. +The real cost of running secure-by-default (rather than the parity-mode `security:false` used above) is ~5.2% req/s on this box. > Scope: this micro-bench currently measures the security-**headers** cost only (`security:false` vs > `security:true` on `/hello`). The incremental cost of `@body` validation and CORS is not separately @@ -102,3 +110,9 @@ The real cost of running secure-by-default (rather than the parity-mode `securit - **Content-type charset asymmetry (disclosed, not controlled)**: green-tea and raw-http send `Content-Type: application/json` while Express and Fastify send `application/json; charset=utf-8`. This is a minor header-byte asymmetry that is disclosed here rather than normalized away. +- **NestJS runs on an underlying adapter** (Express or Fastify): the `nestjs-express` / `nestjs-fastify` + rows measure Nest's DI / decorator / routing overhead **on top of** that adapter, so compare each + against its own base (`express` / `fastify`) rather than against the field. Nest's idiomatic + `ValidationPipe` / class-validator is **not** used — `/validate` performs the same manual field check + as every other server (parity). The same parity controls apply: `etag` and `x-powered-by` are disabled + on the underlying Express instance, and `keepAliveTimeout` is 5000 on both adapters. diff --git a/bench/results.json b/bench/results.json index df932d3..73d408c 100644 --- a/bench/results.json +++ b/bench/results.json @@ -1,7 +1,7 @@ { "env": { "date": "2026-07-07", - "commit": "daa13f6", + "commit": "fe1831a", "node": "v22.22.2", "os": "darwin", "cpu": "Apple M4 Max (16 cores)", @@ -23,11 +23,11 @@ { "framework": "raw-http", "reqSec": { - "median": 116166.4, - "min": 115590.4, - "max": 117241.6, - "stddev": 684.2913999167365, - "cv": 0.005882187997853885 + "median": 115398.4, + "min": 114822.4, + "max": 115539.2, + "stddev": 310.09010876768724, + "cv": 0.0026905088104554075 }, "p50": 0, "p99": 1, @@ -36,11 +36,11 @@ { "framework": "fastify", "reqSec": { - "median": 86470.4, - "min": 86201.6, - "max": 86828.8, - "stddev": 256.92278130900564, - "cv": 0.0029701964075911015 + "median": 86764.8, + "min": 86496, + "max": 87123.2, + "stddev": 256.9227813090051, + "cv": 0.002960121758353106 }, "p50": 1, "p99": 2, @@ -49,28 +49,54 @@ { "framework": "express", "reqSec": { - "median": 24004.8, - "min": 23988.8, - "max": 24136, - "stddev": 65.9438144685816, - "cv": 0.002742722036525155 + "median": 24366.4, + "min": 24283.2, + "max": 24417.6, + "stddev": 55.38455460585383, + "cv": 0.002273984274990166 }, "p50": 3, - "p99": 6, - "p999": 9 + "p99": 5, + "p999": 8 }, { "framework": "green-tea", "reqSec": { - "median": 97760, - "min": 97094.4, - "max": 97836.8, - "stddev": 333.34655973759686, - "cv": 0.003416705658430423 + "median": 98092.8, + "min": 98054.4, + "max": 98668.8, + "stddev": 281.0175795212842, + "cv": 0.002859589501804015 }, "p50": 0, "p99": 1, "p999": 2 + }, + { + "framework": "nestjs-express", + "reqSec": { + "median": 21761.6, + "min": 21697.6, + "max": 21896, + "stddev": 82.67870880032535, + "cv": 0.0037952010918943873 + }, + "p50": 4, + "p99": 6, + "p999": 10 + }, + { + "framework": "nestjs-fastify", + "reqSec": { + "median": 95033.6, + "min": 94240, + "max": 95264, + "stddev": 438.6166536839312, + "cv": 0.00462452048886261 + }, + "p50": 1, + "p99": 1, + "p999": 2 } ] }, @@ -81,11 +107,11 @@ { "framework": "raw-http", "reqSec": { - "median": 117024, - "min": 116537.6, - "max": 117241.6, - "stddev": 294.3072317607338, - "cv": 0.0025168575864821115 + "median": 116332.8, + "min": 115974.4, + "max": 116409.6, + "stddev": 189.66281191162406, + "cv": 0.001631663389130871 }, "p50": 0, "p99": 1, @@ -94,11 +120,11 @@ { "framework": "fastify", "reqSec": { - "median": 85753.6, - "min": 85651.2, - "max": 86316.8, - "stddev": 292.6323746044982, - "cv": 0.0034063777495308683 + "median": 86278.4, + "min": 86137.6, + "max": 86764.8, + "stddev": 268.69839349476365, + "cv": 0.003110165492522174 }, "p50": 1, "p99": 2, @@ -107,24 +133,50 @@ { "framework": "express", "reqSec": { - "median": 23665.6, - "min": 23665.6, - "max": 23720, - "stddev": 25.64440593103281, - "cv": 0.0010827856221020677 + "median": 23835.2, + "min": 23803.2, + "max": 24046.4, + "stddev": 107.89690552662897, + "cv": 0.004515472130491916 }, - "p50": 4, + "p50": 3, "p99": 5, "p999": 8 }, { "framework": "green-tea", "reqSec": { - "median": 92384, - "min": 91795.2, - "max": 92998.4, - "stddev": 491.24140252584004, - "cv": 0.005316895043385614 + "median": 93433.6, + "min": 93152, + "max": 93612.8, + "stddev": 189.6628119116206, + "cv": 0.002030662686635119 + }, + "p50": 1, + "p99": 2, + "p999": 2 + }, + { + "framework": "nestjs-express", + "reqSec": { + "median": 20955.2, + "min": 20948.8, + "max": 21201.6, + "stddev": 117.69157432317111, + "cv": 0.005594982425799189 + }, + "p50": 4, + "p99": 6, + "p999": 11 + }, + { + "framework": "nestjs-fastify", + "reqSec": { + "median": 89312, + "min": 89235.2, + "max": 89529.6, + "stddev": 124.68598780759793, + "cv": 0.001395338811201841 }, "p50": 1, "p99": 2, @@ -140,11 +192,11 @@ { "framework": "raw-http", "reqSec": { - "median": 114156.8, - "min": 113862.4, - "max": 114553.6, - "stddev": 283.21155029804993, - "cv": 0.0024801579427618002 + "median": 113491.2, + "min": 112531.2, + "max": 114809.6, + "stddev": 933.9810324031724, + "cv": 0.008220892102882115 }, "p50": 0, "p99": 1, @@ -153,11 +205,11 @@ { "framework": "fastify", "reqSec": { - "median": 84320, - "min": 84268.8, - "max": 84422.4, - "stddev": 63.857619400938304, - "cv": 0.0007571714540811431 + "median": 85024, + "min": 84512, + "max": 85177.6, + "stddev": 284.55819947576623, + "cv": 0.003351507726431956 }, "p50": 1, "p99": 2, @@ -166,24 +218,50 @@ { "framework": "express", "reqSec": { - "median": 23828.8, - "min": 23768, - "max": 23851.2, - "stddev": 35.151481713672865, - "cv": 0.001475960770644645 + "median": 23950.4, + "min": 23902.4, + "max": 24011.2, + "stddev": 44.519758410046, + "cv": 0.0018585004345727763 }, - "p50": 4, + "p50": 3, "p99": 5, "p999": 8 }, { "framework": "green-tea", "reqSec": { - "median": 83961.6, - "min": 83590.4, - "max": 84358.4, - "stddev": 313.5927436802211, - "cv": 0.0037345747973909107 + "median": 84896, + "min": 84243.2, + "max": 85267.2, + "stddev": 423.2825796347192, + "cv": 0.004991414284012342 + }, + "p50": 1, + "p99": 2, + "p999": 2 + }, + { + "framework": "nestjs-express", + "reqSec": { + "median": 20824, + "min": 20804.8, + "max": 20878.41, + "stddev": 31.17605954717337, + "cv": 0.001496278247605678 + }, + "p50": 4, + "p99": 6, + "p999": 11 + }, + { + "framework": "nestjs-fastify", + "reqSec": { + "median": 87328, + "min": 86867.2, + "max": 87660.8, + "stddev": 325.38753646827104, + "cv": 0.0037278603866430907 }, "p50": 1, "p99": 2, @@ -198,11 +276,11 @@ { "framework": "raw-http", "reqSec": { - "median": 100230.4, - "min": 100064, + "median": 100140.8, + "min": 99846.4, "max": 100294.4, - "stddev": 97.10768364152092, - "cv": 0.0009691746695970135 + "stddev": 185.88177843875883, + "cv": 0.0018570746103533369 }, "p50": 0, "p99": 1, @@ -211,11 +289,11 @@ { "framework": "fastify", "reqSec": { - "median": 63222.4, - "min": 62307.2, - "max": 63228.8, - "stddev": 432.9457959401203, - "cv": 0.006880951458691962 + "median": 63721.6, + "min": 63574.4, + "max": 63760, + "stddev": 79.99288857281053, + "cv": 0.0012560645345785087 }, "p50": 1, "p99": 2, @@ -224,28 +302,54 @@ { "framework": "express", "reqSec": { - "median": 19870.41, - "min": 19758.41, - "max": 19883.2, - "stddev": 56.05565508195131, - "cv": 0.0028257646983895677 + "median": 20097.6, + "min": 20056, + "max": 20174.41, + "stddev": 49.04789518646266, + "cv": 0.0024390608203285337 }, "p50": 4, - "p99": 7, - "p999": 23 + "p99": 6, + "p999": 12 }, { "framework": "green-tea", "reqSec": { - "median": 76243.2, - "min": 76192, - "max": 76550.4, - "stddev": 158.26975565645782, - "cv": 0.0020735333006502306 + "median": 77177.61, + "min": 77126.4, + "max": 77254.4, + "stddev": 52.602458962379814, + "cv": 0.0006815013839797027 }, "p50": 1, "p99": 2, "p999": 2 + }, + { + "framework": "nestjs-express", + "reqSec": { + "median": 18856, + "min": 18852.8, + "max": 19067.2, + "stddev": 100.32338821143516, + "cv": 0.005301010367660728 + }, + "p50": 5, + "p99": 7, + "p999": 30 + }, + { + "framework": "nestjs-fastify", + "reqSec": { + "median": 59145.6, + "min": 59004.8, + "max": 59376, + "stddev": 153.00625985741647, + "cv": 0.002585636725423652 + }, + "p50": 1, + "p99": 3, + "p999": 3 } ] } @@ -254,7 +358,7 @@ { "path": "/steps/0", "steps": 0, - "reqSec": 91385.6 + "reqSec": 92281.6 }, { "path": "/steps/3", @@ -264,17 +368,17 @@ { "path": "/steps/5", "steps": 5, - "reqSec": 72236.8 + "reqSec": 71993.61 } ], "secureCost": [ { "label": "security:false (parity)", - "reqSec": 97760 + "reqSec": 98092.8 }, { "label": "security:true (default)", - "reqSec": 93305.6 + "reqSec": 92998.4 } ] } \ No newline at end of file