Ulaşım
- Adres:2342 Sk, İpekyol, İpek Ap 49A, 63250 Haliliye/Şanlıurfa
- Telefon:
0542 315 45 37 - eMail: info@alestaweb.com
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.
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, 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.
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.
Hadi birlikte bakalım — Fastify'ın hız avantajı 3 temel mimariden geliyor:
// 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 olur
// 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: 'ali@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)
});
// 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 global
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');
});
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.
| Özellik | Express | Fastify |
|---|---|---|
| TypeScript Paket | @types/express (ayrı) | Dahili (built-in) |
| Generic Tip Desteği | Sınırlı | Kapsamlı |
| Schema → Type Otomatik | ❌ | ✅ (TypeBox ile) |
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<{ Reply: typeof UserSchema }>('/user', async () => {
return { id: 1, name: 'Ali', email: 'ali@alestaweb.com' };
// TypeScript tam tip güvencesi sağlıyor
// Full TypeScript type safety
});
Alesta Web olarak yeni projelerde Fastify'ı tercih ediyoruz. Performance farkı production'da gerçekten hissediliyor — özellikle yüksek concurrency gerektiren API'lerde.
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.
Faydalı Linkler:
© 2026 AlestaWeb — Tüm hakları saklıdır.