VPS vs Serverless functions

VPS vs serverless: cost, cold starts and control

Short answer

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.

VPS vs Serverless functions — side by side
DimensionVPSServerless functions
Idle costFull plan priceZero
Cost at scaleFlatGrows with every request
Cold startsNone100 ms to several seconds
Execution limitNoneTypically 15 minutes
Long-lived connectionsNativeAwkward or impossible
Lock-inNoneHigh

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.