https://github.com/ditsmod/vs-webframework
Benchmark: fastify vs nestjs vs ditsmod vs restify vs hapi vs express
https://github.com/ditsmod/vs-webframework
benchmark ditsmod express fastify hapi nestjs restify
Last synced: 28 days ago
JSON representation
Benchmark: fastify vs nestjs vs ditsmod vs restify vs hapi vs express
- Host: GitHub
- URL: https://github.com/ditsmod/vs-webframework
- Owner: ditsmod
- Created: 2020-07-13T20:05:31.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T13:39:47.000Z (about 1 month ago)
- Last Synced: 2025-04-08T14:36:33.854Z (about 1 month ago)
- Topics: benchmark, ditsmod, express, fastify, hapi, nestjs, restify
- Language: TypeScript
- Homepage:
- Size: 687 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Install and build
```bash
git clone --depth 1 https://github.com/ditsmod/vs-webframework.git
cd vs-webframework
npm i
npm run build
```All applications are built in ESM format, `keepAliveTimeout: 0` is set, and generation of additional headers is disabled.
## Cold start
The shorter the cold-start time, the better the frameworks are suited for serverless technology. So, the results of a cold start are as follows:
| framework | result, ms |
|----------------------|:-------------:|
| express v4.19 | 4 |
| koa v2.15 | 4 |
| restify v11.1 | 8 |
| fastify v4.26 | 22 |
| hapi v21.3 | 23 |
| ditsmod v3.0 | 30 |
| nest v10.3 + fastify | 45 |
| nest v10.3 + express | 107 |For now, this benchmark is run manually, for example:
```bash
node dist/ditsmod/main.mjs
# OR
node koa.mjs
# OR
node dist/nestjs/main-express.mjs
# ...
```See `package.json` for more examples with start script.
## Run benchmarks
```bash
npm start
ab -n 20000 -c 10 localhost:3000/hello
# OR
wrk -t1 -c10 -d5 -H 'Connection: close' http://localhost:3006/hello
```Here you need manually changes port in the range from 3000 to 3007.
"Hello, World!" performance comparison for web frameworks:
- `Fastify`
- `Ditsmod`
- `Koa`
- `Restify`
- `Express`
- `Nestjs + Express`
- `Nestjs + Fastify`
- `Hapi`
The following command will allow you to view the status of running programs:
```bash
npx pm2 l
```If you run this command immediately after running the benchmark, in particular you will see how much memory each of the applications is consuming.
Interesting information is in the `cpu` and `mem` columns. Also in `↺` column you can see number of restarting the applications.
In addition, you can also check the work of Ditsmod and NestJS with controllers that are created "per request". To do this, request for the path `/hello2`, for example:
```bash
wrk -t1 -c10 -d3 -H 'Connection: close' http://localhost:3006/hello2
```## Stop webservers
```bash
npm run stop
```