
Benchmarking Modern JavaScript Frameworks for Backend Development
JavaScript had made big steps in becoming a full-stack language in last decade.
Now we have not only Express, but other frameworks and even runtimes to make JS back-end possible and even performant enough comparing to PHP, Python and Java.
Today choosing the right framework can significantly impact your application's performance and scalability.
To aid developers and project managers in making an informed decision (and for my own curiosity), I made a benchmark test on several popular Node.js (and Bun) frameworks.
I chose for this test Elysia (Bun), Express, Fastify, NestJS, and Nitro.
These benchmarks focused on GET and POST requests, interacting with a PostgreSQL database via Prisma ORM, with tests executed using Oha.
Source code of the test is in my GitHub repo.
Testing Methodology
- Frameworks Tested: Elysia (Bun), Express, Fastify, NestJS, and Nitro.
- Endpoints: GET and POST requests to
/users
. - Database Interaction: Read and write operations with PostgreSQL using Prisma ORM.
- Environment: All servers were run locally which eliminates HTTP and DNS latency.
- Hardware: Macbook Pro M1 2021 (ARM)
Overall Performance Analysis
GET /users Endpoint
Server | Requests/sec | Average Response (ms) | p99 Latency (ms) |
---|---|---|---|
Elysia (Bun) | 9,695 | 9.83 | 30.02 |
Fastify | 8,970 | 10.73 | 29.19 |
Nitro | 6,105 | 15.91 | 54.90 |
Express | 5,997 | 16.07 | 165.37 |
NestJS | 5,571 | 16.97 | 53.82 |
POST /users Endpoint
Server | Requests/sec | Average Response (ms) | p99 Latency (ms) |
---|---|---|---|
Elysia (Bun) | 2,795 | 34.24 | 55.59 |
Nitro | 2,749 | 34.75 | 59.53 |
Fastify | 2,476 | 38.77 | 83.37 |
Express | 2,407 | 39.87 | 77.11 |
NestJS | 2,171 | 43.91 | 82.29 |
Key Findings
- Elysia (Bun) shows the best overall performance:
- Highest throughput for both GET (9,695 req/sec) and POST (2,795 req/sec) operations
- Lowest average response times for both operations
- Fastify is a strong runner-up:
- Second-best performance for GET requests (8,970 req/sec)
- Competitive performance for POST requests
- Express vs. Nitro:
- Nitro slightly outperforms Express for POST requests
- They're nearly identical for GET requests, with Nitro having a slight edge
- Express shows significantly higher p99 latency for GET requests (165.37ms), suggesting higher variability
- NestJS shows the lowest performance:
- Lowest throughput for both GET and POST operations
- This is expected as NestJS adds abstraction layers on top of Express
- Response size impact:
- All frameworks show significantly lower throughput for POST requests compared to GET
- This correlates with larger response sizes for POST operations
- Tail latency analysis:
- Express shows concerning p99 values (165.37ms) for GET requests, suggesting inconsistent performance
- Elysia maintains good p99 values across both endpoints, indicating consistency
Detailed Observations
- Response Time Distribution:
- Elysia has the most consistent response times with a tight distribution
- Express shows a wider distribution of response times with occasional high latencies
- Resource Efficiency:
- Bun runtime (used by Elysia) appears to provide significant performance benefits
- The traditional Node.js servers (Express, Fastify, NestJS) show similar characteristics with varying levels of overhead
- HTTP Method Impact:
- All frameworks handle GET requests 2-3x faster than POST requests
- This reflects the additional overhead of processing request bodies in POST requests
Recommendations
- For maximum performance: Elysia with Bun is clearly the performance leader in these tests.
- For traditional Node.js environment:
- Fastify provides the best performance
- Nitro is a good alternative with competitive performance
- For enterprise applications:
- If you need the structure and features of NestJS, be aware of the performance trade-off
- Consider Fastify as the underlying HTTP provider for NestJS instead of Express
- For existing Express applications:
- Consider migrating to Fastify for performance improvement
- If migration isn't feasible, optimize Express configuration and middleware usage
These results demonstrate that the choice of framework has a significant impact on backend performance, with newer technologies like Bun showing substantial improvements over traditional Node.js setups.