Serverless means you write functions, not servers. The cloud provider handles all infrastructure — you pay only when your code runs.
// handler.js — AWS Lambda function
exports.handler = async (event) => {
const body = JSON.parse(event.body || '{}');
// Your business logic here
const result = await processRequest(body);
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(result)
};
};
// Deploy with AWS SAM or Serverless Framework:
# serverless.yml
service: myapi
provider:
name: aws
runtime: nodejs20.x
region: eu-west-1
functions:
api:
handler: handler.handler
events:
- httpApi:
path: /api/{proxy+}
method: ANY
memorySize: 256
timeout: 10
// worker.js — runs at 300+ edge locations worldwide
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname === '/api/hello') {
return new Response(JSON.stringify({ message: 'Hello from the edge!' }), {
headers: { 'Content-Type': 'application/json' }
});
}
// Proxy to origin for other routes
return fetch(request);
}
};
| Platform | Cold Start | Max Duration | Free Tier | Best For |
|---|---|---|---|---|
| AWS Lambda | 100-500ms | 15 min | 1M requests/mo | Full backend APIs, event processing |
| Cloudflare Workers | ~0ms (no cold start) | 30s (free), 15min (paid) | 100K requests/day | Edge logic, fast APIs |
| Vercel Functions | ~250ms | 10-60s | 100GB-hrs/mo | Next.js apps, frontend teams |
| Netlify Functions | ~200ms | 10-26s | 125K requests/mo | JAMstack backends |
| Google Cloud Functions | 100-400ms | 9-60 min | 2M invocations/mo | GCP ecosystem, event-driven |
Edge computing runs your code at CDN points-of-presence (PoPs) close to users, reducing latency from ~100ms to ~10ms.