Fastify handles 60,000+ requests per second on Node.js. Schema-based validation, automatic serialization, and a plugin architecture that doesn't sacrifice speed.
Why Not Express?
Express is simple but slow. It has no built-in validation, no schema support, no serialization optimization. Every middleware adds overhead.
Fastify was designed from day one for performance without compromising developer experience.
What You Get for Free
import Fastify from 'fastify';
const app = Fastify({ logger: true });
app.get('/user/:id', {
schema: {
params: { type: 'object', properties: { id: { type: 'string' } } },
response: {
200: {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
email: { type: 'string' }
}
}
}
}
}, async (request) => {
return getUser(request.params.id);
});
app.listen({ port: 3000 });
JSON Schema validation — request validated before your handler runs
Fast serialization — response serialized based on schema (2-3x faster than JSON.stringify)
Encapsulated plugins — plugins can't leak into other parts of your app
TypeScript support — first-class types with @fastify/type-provider-typebox
Logging — pino logger built-in (30x faster than morgan)
Performance
Requests/second (JSON response):
- Express: ~15,000
- Koa: ~25,000
- Fastify: ~60,000+
The secret: Fastify compiles JSON schemas into optimized serialization functions at startup.
Plugin Ecosystem
npm i @fastify/cors @fastify/jwt @fastify/swagger @fastify/rate-limit
app.register(require('@fastify/cors'));
app.register(require('@fastify/swagger'), { openapi: { ... } });
app.register(require('@fastify/rate-limit'), { max: 100, timeWindow: '1 minute' });
Swagger docs auto-generated from your schemas. Rate limiting, JWT, CORS — all official plugins.
Quick Start
npm i fastify
That's it. No express-generator, no template. Import, define routes, listen.
If you need Node.js performance close to Go/Rust — Fastify gets you 80% of the way there.
Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.
Custom solution? Email spinov001@gmail.com — quote in 2 hours.
Top comments (0)