Ana içeriğe geç
Teknoloji

Edge Functions Nedir?

Edge functions, serverless function'ların CDN edge node'larında (kullanıcıya 50-200ms uzaklıkta) çalışan versiyonu. Klasik serverless (AWS Lambda) tek bölgede çalışırken, edge functions 200+ POP'a deploy. Auth, A/B test, geographical routing, dynamic personalization edge'de.

Edge functions vs klasik serverless: - Klasik (AWS Lambda Frankfurt): kullanıcı İstanbul'dan request → 200ms latency → function çalışıyor (10-100ms) → response 200ms - Edge functions (Cloudflare Workers Istanbul): kullanıcı İstanbul → 30ms latency → function çalışıyor (5ms) → response 30ms

Edge function platform'lar: - Cloudflare Workers — V8 isolates, ultra-low cold start (5ms), 270+ POP - Vercel Edge Functions — V8, 100+ POP, Next.js native - AWS Lambda@Edge — CloudFront entegre, 300+ POP, JS only - Netlify Edge Functions — Deno runtime

Edge function kullanım senaryoları: 1. Auth check — request header'da JWT validate, sayfa render etmeden 401 dönsün 2. Geographical routing — kullanıcı Türkiye'den ise /tr/, Almanya'dan ise /de/ 3. A/B testing — feature flag bazlı render variant seçimi 4. Personalization — kullanıcı önceki sepet/login durumuna göre dinamik content 5. Bot protection — user-agent + behavior detection edge'de filtrele 6. Rate limiting — IP bazlı limit (Redis edge'e yakın)

Limitler: - CPU time: 10-50ms (Cloudflare), 30s (Vercel) - Memory: 128MB - No Node.js APIs (no fs, no child_process) — sadece Web Standards (fetch, Request, Response)

DevPixel'in edge function kullanımı: Next.js proxy.ts (middleware) — auth check + maintenance mode + bot detection edge'de.

DevPixel Yaklaşımı

DevPixel proxy.ts edge function: maintenance mode check (Firebase REST), www→non-www redirect, portal subdomain detection, admin route protection — tümü kullanıcıya yakın edge node'da. Latency 30-80ms, klasik server middleware'a göre 5-10x daha hızlı.

İlgili terimler