Infrastructure Comparisons
Side-by-side trade-offs where neither column wins. The workload, the team and the operational budget decide — and each comparison ends with the verdict that follows from that, not from a preference.
VM vs Container vs ServerlessManaged vs self-hosted databaseObject vs block vs file storageRolling vs blue/green vs canaryActive-passive vs active-activeDeclarative vs imperative infrastructure
VM vs Container vs Serverless
Three execution models with different boundaries around what you operate. The right one depends on how long the work runs, how much isolation it needs, and how much operational capacity the team has.
| Dimension | Virtual machine | Container | Serverless function |
|---|---|---|---|
| Isolation boundary | Own kernel, virtual hardware | Shared host kernel, process isolation | Provider-managed, strongest by default |
| Start-up | Tens of seconds to minutes | Seconds, plus image pull | Milliseconds warm, hundreds of ms to seconds cold |
| Density | Low | High | Not your concern |
| You operate | OS, patching, images, lifecycle | Image, runtime config, orchestration or platform | Code and configuration |
| State | Local disk available | Treat as disposable | None between invocations |
| Long-running work | Unbounded | Unbounded | Bounded by the platform's execution limit |
| Cost shape | Fixed while running | Fixed while running, better packed | Usage-shaped, scales to zero |
| Connection pooling to a database | Natural | Natural | Hostile — needs a proxy or pooler |
Use Virtual machine when
- Custom kernel modules, drivers or licensed software.
- A strong isolation requirement between tenants or workloads.
- Lift-and-shift of something that expects a machine.
Use Container when
- A long-running service you deploy frequently.
- You want the same artifact in every environment.
- Density and fast replacement matter.
Use Serverless function when
- Short, event-driven work with idle periods.
- Traffic is spiky and unpredictable.
- You want no servers to operate and accept the platform's limits.
Verdict
Most services land on containers via a managed platform. Reach for VMs when the isolation or the OS is the requirement, and for functions when the work is genuinely short and event-shaped.
Lessons behind this comparison