AlestaSoft

Node.js ile bir REST API kuracaksınız — Fastify mi, Express mi? 2026'da bu soru hâlâ sorgulanıyor çünkü iki framework çok farklı şeyler vaat ediyor. Fastify 3-5 kat daha hızlı, ama Express 14 kat daha fazla indiriliyor. Alesta Web olarak gerçek benchmark verileri ve pratik deneyimlerimizle bu karşılaştırmayı sonlandırıyoruz — Fastify vs Express which is better sorusunun cevabı için doğru yerdesiniz.
Fastify ve Express Nedir? (What Are Fastify and Express?)
Express.js Nedir? (What is Express.js?)
Express.js, 2010 yılında yayınlanan ve Node.js ekosisteminin tartışmasız en popüler web framework'üdür. Minimal ve esnek yapısıyla tanınan Express, milyonlarca projenin temelini oluşturuyor. Haftalık npm indirme sayısı 30 milyonun üzerinde.
Fastify Nedir? (What is Fastify?)
Fastify, 2017 yılında yayınlanan ve "hızlı ile düşük overhead" odaklı bir Node.js framework'üdür. Schema tabanlı serileştirme, dahili doğrulama ve radix-tree router gibi mimarisiyle dikkat çekiyor. Haftalık npm indirmesi ~2 milyon, ancak yükseliş trendi güçlü.
Express 14 kat daha fazla indiriliyor — ancak bu popülerlik, performans anlamına gelmiyor. Fastify'ı büyük şirketler (Uber, PayPal vb.) production'da kullanıyor.
Performans Benchmark 2026 (Performance Benchmark 2026)
Rakamlar hiç yalan söylemez. İşte 2026'daki gerçek benchmark verileri (aynı donanım, Node.js 24 LTS, basit JSON REST endpoint):
| Ölçüm / Metric | Express.js | Fastify | Fark / Difference |
|---|---|---|---|
| İstek/Saniye (req/sec) | 20.000-30.000 | 70.000-80.000 | 3-5x hızlı |
| Latency (ortalama) | ~8ms | ~2ms | 4x daha düşük |
| JSON Serileştirme | JSON.stringify() | fast-json-stringify (2x hızlı) | 2x daha hızlı |
| Bellek Kullanımı / Memory | Orta | Düşük | %20-30 daha az |
| Başlangıç Süresi / Startup | Hızlı | Çok Hızlı | Yakın |
Aynı basit CRUD API'yi her iki framework'te yazdık ve test ettik. Fastify, yük testinde Express'ten tutarlı olarak 3.5x daha yüksek throughput sağladı. Yüksek trafikli senaryolarda bu fark kritik hale geliyor.
Fastify Neden Daha Hızlı? (Why is Fastify Faster?)
Hadi birlikte bakalım — Fastify'ın hız avantajı 3 temel mimariden geliyor:
1. Radix-Tree Router
// Express: Sıralı dizi araması (sequential array lookup)
// Her route için tüm pattern'ları teker teker kontrol eder
// O(n) karmaşıklık
// Fastify: Radix Tree (prefix tree)
// Route eşleştirme çok daha hızlı
// O(log n) karmaşıklık
// 1000 route'lu bir uygulamada fark çok belirgin olur2. Schema Tabanlı JSON Serileştirme (Schema-Based Serialization)
// Fastify ile schema tanımlayın
// Fastify define schema for response
const schema = {
response: {
200: {
type: 'object',
properties: {
id: { type: 'integer' },
name: { type: 'string' },
email: { type: 'string' }
}
}
}
};
fastify.get('/user/:id', { schema }, async (request, reply) => {
return { id: 1, name: 'Ali', email: 'admin@alestaweb.com' };
// Fastify bu nesneyi JSON.stringify yerine
// compile edilmiş serializer ile serialize ediyor
// 2x daha hızlı JSON dönüşümü sağlıyor (2x faster JSON serialization)
});3. Asenkron Plugin Sistemi (Async Plugin System)
// Fastify'ın encapsulated plugin sistemi
// Fastify's encapsulated plugin system
fastify.register(async (instance, opts) => {
// Bu plugin kendi scope'unda çalışır
// Başka plugin'lerle çakışma yok (no conflicts with other plugins)
instance.get('/private', async () => ({ secret: true }));
});
// Express'te scope yoktur — her middleware global'dir
// Express has no scope — all middleware is globalKurulum ve İlk API (Installation and First API)
Express.js Kurulumu / Express.js Installation
mkdir express-api && cd express-api
npm init -y
npm install express
# app.js
const express = require('express');
const app = express();
app.use(express.json());
app.get('/health', (req, res) => {
res.json({ status: 'ok', framework: 'express' });
});
app.listen(3000, () => {
console.log('Express running on port 3000');
});Fastify Kurulumu / Fastify Installation
mkdir fastify-api && cd fastify-api
npm init -y
npm install fastify
# app.js
const fastify = require('fastify')({ logger: true });
fastify.get('/health', async (request, reply) => {
return { status: 'ok', framework: 'fastify' };
// Otomatik JSON response — reply.json() gerekmez
// Automatic JSON response — no need for reply.json()
});
fastify.listen({ port: 3000 }, (err) => {
if (err) process.exit(1);
});İki kod bloğuna bakınca sözdizimi çok benzer. Express geliştiricileri Fastify'a kolayca geçebilir.
TypeScript Desteği (TypeScript Support)
| Özellik | Express | Fastify |
|---|---|---|
| TypeScript Paket | @types/express (ayrı) | Dahili (built-in) |
| Generic Tip Desteği | Sınırlı | Kapsamlı |
| Schema → Type Otomatik | ❌ | ✅ (TypeBox ile) |
Fastify TypeBox ile Type-Safe API
import Fastify from 'fastify';
import { Type } from '@sinclair/typebox';
const fastify = Fastify();
const UserSchema = Type.Object({
id: Type.Number(),
name: Type.String(),
email: Type.String({ format: 'email' })
});
fastify.get('/user', async () => {
return { id: 1, name: 'Ali', email: 'admin@alestaweb.com' };
// TypeScript tam tip güvencesi sağlıyor
// Full TypeScript type safety
});Hangisini Seçmeli? (Which Should You Choose?)
- Yüksek trafikli API'ler yazıyorsunuz (high-traffic APIs)
- TypeScript ile geliştirme yapıyorsunuz
- Yeni proje başlatıyorsunuz (new project)
- Microservice mimarisi kuruyorsunuz
- JSON schema validation kritik
- Mevcut Express projesini geliştiriyorsunuz (existing project)
- Takımınız Express biliyor ve geçiş maliyeti yüksek
- Çok sayıda Express middleware kullanıyorsunuz
- Prototip veya düşük trafikli proje
- Stack Overflow'da hızlı cevap bulmak istiyorsunuz
Alesta Web olarak yeni projelerde Fastify'ı tercih ediyoruz. Performance farkı production'da gerçekten hissediliyor — özellikle yüksek concurrency gerektiren API'lerde.
? Kaynaklar ve Referanslar / References
- Fastify Official Benchmarks - Resmi performans verileri
- PkgPulse — Express vs Fastify 2026
- Better Stack — Express vs Fastify In-Depth
✅ Sonuç: Fastify Kazandı! (Conclusion: Fastify Wins Performance)
Ham performansta Fastify açık ara önde. Ama Express'in 15 yıllık ekosistemi ve topluluğu yadsınamaz. Alesta Web olarak önerimiz: Yeni projeler için Fastify, mevcut Express projeleri için acele geçiş yapmayın.
- ✅ Fastify: 3-5x hızlı, dahili TypeScript, schema validation (built-in validation)
- ✅ Express: Devasa ekosistem, büyük topluluk, kolay öğrenme (large community)
- ✅ Node.js 24 LTS ile her ikisi de mükemmel çalışıyor
Faydalı Linkler:
- alestaweb.com — Alesta Web
© 2026 AlestaWeb — Tüm hakları saklıdır.

