Serverless
Cloud Computing
Edge Computing
AWS
Performance
Ask anything about this article
Hi! I've read this article.
What would you like to know?
@farhan
Serverless has matured from "interesting experiment" to "default deployment model." Here's how the major platforms compare.
| Feature | Cloudflare Workers | AWS Lambda | Vercel Edge |
|---|---|---|---|
| Runtime | V8 Isolates | Container-based | V8 Isolates |
| Cold Start | ~0ms | 100-500ms | ~0ms |
| Max Duration | 30s (free), 15min | 15 min | 25s |
| Memory | 128MB | Up to 10GB | 128MB |
| Global Regions | 300+ PoPs | 30+ regions | 18 regions |
| Pricing | $0.50/M requests | $0.20/M + compute | Included in plan |
| Free Tier | 100K req/day | 1M req/month | 1M req/month |
| Languages | JS/TS, Wasm, Python | Any (container) | JS/TS |
Request latency (p50):
Cloudflare Workers: 2ms ← Edge speed
Vercel Edge: 5ms
AWS Lambda (Node): 45ms (warm)
AWS Lambda (Node): 350ms (cold start)
AWS Lambda (Java): 2500ms (cold start!)
typescript// Cloudflare Worker — runs at 300+ locations globally
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const country = request.cf?.country;
// Route to nearest backend
const backend = country === 'IN'
? 'https://api-mumbai.myapp.com'
: 'https://api-virginia.myapp.com';
const response = await fetch(backend + new URL(request.url).pathname);
// Cache at edge
const cached = new Response(response.body, response);
cached.headers.set('Cache-Control', 's-maxage=60');
return cached;
}
};
typescript// Next.js Middleware (runs on Vercel Edge)
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
const token = request.cookies.get('auth_token');
if (!token && request.nextUrl.pathname.startsWith('/dashboard')) {
return NextResponse.redirect(new URL('/login', request.url));
}
// Add geo headers
const response = NextResponse.next();
response.headers.set('x-user-country', request.geo?.country || 'unknown');
return response;
}
Traditional:
User → CDN → Server (US-East) → Database
Latency: 200-500ms globally
Edge-First:
User → Edge (nearest PoP) → Database (global)
Latency: 20-50ms globally
Edge computing isn't replacing servers — it's augmenting them. Put logic close to users for speed, and use servers for heavy lifting.