Serverless vs Dedicated VMs: The Architecture Decision
Should you use serverless (Lambda, Cloudflare Workers) or dedicated VMs (Fly.io, DigitalOcean)? A framework for the decision.
Serverless (Lambda, Cloudflare Workers, Vercel Functions) vs. dedicated VMs (Fly.io, DigitalOcean, EC2) is one of the first architectural decisions for a new project. The tradeoff is real and the right choice depends on workload characteristics.
The Core Tradeoff
Serverless: You trade control for convenience. The platform handles scaling, availability, and resource allocation. You pay per request/use.
Dedicated VMs: You have full control and predictable pricing. You handle scaling (or use a platform that helps). Pay per time.
Serverless Advantages
- Scale to zero: Pay nothing when no traffic
- No ops burden: Platform handles availability and scaling
- Global edge: Most serverless platforms have better geographic distribution
- Cost at low traffic: Can be dramatically cheaper for infrequent workloads
Dedicated VM Advantages
- Predictable pricing: Pay per month, not per million invocations
- No cold starts: Real servers, always ready
- Full compatibility: Any runtime, any library, any binary
- Long-running processes: No execution time limits
- Stateful connections: WebSockets, SSE, persistent TCP work naturally
When to Choose Serverless
- Highly variable traffic (including zero)
- Event-driven workloads (webhooks, scheduled jobs, IoT)
- Simple, short-running functions
- Teams without ops capacity who want maximum convenience
When to Choose Dedicated VMs
- Consistent baseline traffic
- Stateful or long-running processes
- Specific runtime requirements (Python with C extensions, etc.)
- Need for full system control
- Predictable budgeting
For OpenClaw AI Backends
Dedicated VMs (Fly.io) are the right model. AI chatbots need persistent connections, can't tolerate cold starts, and often run at consistent traffic levels. The serverless model is a poor fit.