0.0.1 • Published 7 months ago
nestjs-benchmark v0.0.1
Test Performance
- All tests are executed on MacBook Air M1 with 16G RAM 256 GB.
- Benchmarking tool:
- The software version:
We will test 12 threads with 100 connections in 30s and 3 rounds
Node v20 Express ~ 18k req/30s
Node v20 Fastify ~ 71k req/30s
Bun v1 Express ~ 38k req/30s (211% with Node Express)
Bun v1 Fastify ~ 58k req/30s (80% with Node Fastify)
- The benchmark result tell us:
- Fastify is 4x faster than Express when using NodeJS 😍!
- Fastify is 1.5x faster than Express when using Bun 🙌
- Bun Fastify is slower than NodeJS Fastify??? 😮
- Bun Express is 2x faster than NodeJS Express 😂
Test Build Package Dependencies
- All tests are executed on MacBook Air M1 with 16G RAM 256 GB.
- Now we try to install with >= 1000 packages dependencies so that we can checkout Bun or Pnpm faster
- Bun v1.0.3
- Pnpm v8.2.0
Without lockfile
Pnpm -> Done 24.1s
With lockfile
Pnpm without lockfile -> 5.9s
Feeling
- With the benchmark result above. I surprise when Express (Bun) is increase performance but Fastify (Bun) is decrease performance
- But this is only testing healthcheck so it not represent Bun can be improve NestJS faster than NodeJS
- If your project is dependencies a lot of library or third-party so using Bun with Fastify is the good option to choose
Want to try in your computer
- Install a HTTP benchmarking tool
brew install wrk
- To start with NodeJS
# install package dependencies
pnpm install
# start server
## Express
pnpm run start:dev
## Fastify
pnpm run start:dev -- --platform=fastify
- To start with Bun
# install package dependencies
bun install
# start server
## Express
bun run src/main.ts
## Fastify
bun run src/main.ts --platform=fastify
0.0.1
7 months ago