Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsApr 11, 2026·2 min de lectura

Fastify — Fast & Low Overhead Web Framework for Node.js

Fastify is a fast and low overhead web framework for Node.js, focused on providing the best developer experience with least overhead and a powerful plugin architecture. Schema-driven with JSON Schema validation built in.

Introducción

Fastify is a fast and low overhead web framework for Node.js. Benchmarks consistently show it handling 30K+ req/s — among the fastest Node frameworks. Built around schema validation (JSON Schema) and a lightweight plugin system.

What Fastify Does

  • HTTP server — built on Node http with optimized routing (find-my-way)
  • Schema validation — JSON Schema for body/params/query/headers
  • Serialization — fast JSON output via fast-json-stringify
  • Plugin system — encapsulated context with fastify-plugin
  • Hooks — onRequest, preHandler, onSend, onResponse lifecycle
  • Logging — Pino by default (fastest JSON logger)

Architecture

Plugin tree: each plugin creates an encapsulated context. Decorators attach state to request/reply/instance. Schema compilation happens once at startup for zero-cost runtime validation.

Self-Hosting

# Production
NODE_ENV=production node server.js

# Docker
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
CMD ["node", "server.js"]

Key Features

  • ~2x faster than Express in benchmarks
  • Native TypeScript types
  • JSON Schema validation + serialization
  • Request lifecycle hooks
  • Plugin encapsulation
  • HTTP/2 support
  • Async/await first-class
  • Graceful shutdown built-in

Comparison

Framework Req/s Schema TS
Fastify ~45K JSON Schema Yes
Express ~15K Manual Optional
Koa ~25K Manual Optional
Hapi ~20K Joi Good

FAQ

Q: Can it replace Express? A: Yes. The @fastify/express compatibility layer supports most Express middleware.

Q: Why is it so fast? A: Optimized routing (radix tree) + compile-time schema serialization (fast-json-stringify) + Pino logging.

Q: Can NestJS use Fastify? A: Yes. NestJS officially supports a Fastify adapter that replaces the default Express.

Sources & Credits

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados