DEV Community

Alex Aslam
Alex Aslam

Posted on

Beyond Express: Fastify vs. Hono – Which Wins for High-Throughput APIs?

The Need for Speed

Our traffic was growing 10x month-over-month, and our trusty Express.js API started showing cracks:

  • ~8,000 RPS before latency spiked
  • JSON parsing alone consumed 12% CPU
  • Middleware overhead added ~5ms per request

We tested Fastify and Hono – two frameworks promising better performance without sacrificing developer experience. Here’s what we learned.


Round 1: Fastify – The JSON Speed Demon

Why We Tried It

  • Schema-based validation (faster than Express middleware)
  • Built-in logging/tracing
  • JSON serialization 2x faster than Express

Performance

Metric Express Fastify
Requests/sec 8,000 22,000
Latency (p99) 85ms 32ms
CPU Usage High 40% less

Code Comparison

// Express
app.post('/data', (req, res) => {
  const data = req.body; // Slow JSON parsing
  res.json(data);
});

// Fastify
fastify.post('/data', {
  schema: { body: { /* Type-safe validation */ }
}, async (req, reply) => {
  return req.body; // Pre-validated + optimized JSON
});
Enter fullscreen mode Exit fullscreen mode

Best For: APIs needing JSON speed + validation.


Round 2: Hono – The Ultralight Edge Contender

Why We Tried It

  • Designed for serverless/edge (Cloudflare, Vercel, Deno)
  • ~5x smaller than Express
  • Zero-dependency (faster cold starts)

Performance

Metric Express Hono
Cold Start 450ms 120ms
Memory Usage 120MB 18MB
Edge Runtime ❌ No ✅ Yes

Code Comparison

// Hono (works on Cloudflare Workers)
const app = new Hono();
app.post('/data', async (c) => {
  const data = await c.req.json(); // Blazing-fast edge parsing
  return c.json(data);
});
Enter fullscreen mode Exit fullscreen mode

Best For: Edge functions + low-memory environments.


Key Takeaways

Fastify = Best for monolithic Node.js APIs (better JSON, validation).
Hono = Best for edge/serverless (tiny footprint, cold-start wins).
Express? Still fine for small apps – but falls behind at scale.

We split our stack:

  • Main API → Fastify (for JSON-heavy routes)
  • Edge caching → Hono (for geo-distributed logic)

Result: 3x throughput, 60% lower cloud costs.


Further Reading

Top comments (0)