Serverless Should Be This Simple
AWS Lambda needs an API Gateway, IAM roles, CloudFormation templates, and a 20-minute setup. For a function that returns JSON.
Cloudflare Workers: Functions at the Edge
Cloudflare Workers runs your code in 300+ data centers worldwide. Sub-millisecond cold starts. No region selection — it runs everywhere.
Free Tier
- 100,000 requests/day
- 10ms CPU time per request
- Workers KV: 100,000 reads/day, 1,000 writes/day
- R2 storage: 10GB free
- D1 database: 5M rows read/day, 100K writes/day
- Queues, Cron, Durable Objects included
Deploy in 3 Commands
npm create cloudflare@latest my-api
cd my-api
npx wrangler deploy
Your function is live at my-api.your-subdomain.workers.dev. Running in 300+ cities.
Hello World
export default {
async fetch(request: Request): Promise<Response> {
return new Response('Hello from the edge!', {
headers: { 'content-type': 'text/plain' }
})
}
}
The Full Edge Stack
KV (Key-Value Store)
await env.MY_KV.put('user:123', JSON.stringify({ name: 'Alice' }))
const user = await env.MY_KV.get('user:123', 'json')
D1 (SQLite Database)
const { results } = await env.DB.prepare(
'SELECT * FROM users WHERE active = ?'
).bind(true).all()
R2 (Object Storage)
await env.BUCKET.put('image.png', imageBuffer)
const object = await env.BUCKET.get('image.png')
Queues
await env.MY_QUEUE.send({ type: 'email', to: 'user@example.com' })
Why Workers Beat Lambda
| Feature | Workers (Free) | Lambda (Free Tier) |
|---|---|---|
| Requests | 100K/day | 1M/month |
| Cold start | <1ms | 100-500ms |
| Locations | 300+ cities | 1 region |
| Setup | 3 commands | 20+ minutes |
| Database | D1 included | DynamoDB separate |
| Storage | R2 included | S3 separate |
| CPU time | 10ms/req | 15 min/req |
Workers win on cold starts and global distribution. Lambda wins on compute-heavy tasks.
When to Use Workers
- APIs that need global low latency
- Edge functions (auth, redirects, A/B testing)
- Full-stack apps with Hono or Remix
- Webhooks and integrations
When to Use Lambda/Vercel
- Long-running tasks (>10ms CPU)
- Large memory requirements
- Node.js native modules (Workers use V8 isolates)
Get Started
npm create cloudflare@latest
Need data from the web? 88+ scrapers on Apify. Process results in Workers for a fully serverless pipeline. Custom: spinov001@gmail.com
Top comments (0)