VPS vs Serverless functions
VPS vs serverless: cost, cold starts and control
Serverless bills per invocation and scales to zero, which is unbeatable for genuinely intermittent workloads. Past roughly a million invocations a month, a $12 VPS is usually cheaper — and it has no cold starts, no execution time limit, no vendor-specific runtime and no egress surcharge. Serverless optimises for spiky demand; a VPS optimises for steady demand and portability.
| Dimension | VPS | Serverless functions |
|---|---|---|
| Idle cost | Full plan price | Zero |
| Cost at scale | Flat | Grows with every request |
| Cold starts | None | 100 ms to several seconds |
| Execution limit | None | Typically 15 minutes |
| Long-lived connections | Native | Awkward or impossible |
| Lock-in | None | High |
Which should you choose?
VPS
Choose a VPS for steady traffic, background workers, websockets, and anything you want to move later.
Serverless functions
Choose serverless for genuinely bursty, stateless, short work — and watch the invocation count.
Frequently asked questions
At what point does a VPS beat serverless on cost?
Roughly a million invocations a month for a simple handler, and much sooner once egress is counted. Long-running or memory-heavy functions cross over far earlier.
Can I run a websocket server on serverless?
Not straightforwardly. Serverless is designed for short stateless invocations; persistent connections need a managed gateway that adds cost and complexity. A VPS handles them natively.