"Pay Only for What You Use" Has Fine Print

Serverless (AWS Lambda, Vercel Functions, Cloudflare Workers, Google Cloud Run) promises no servers to manage, automatic scaling, and paying only when code runs. For many projects, that's exactly right: a side project might cost almost nothing.

But some teams discover their serverless bill grew faster than their traffic, or that latency, database limits and debugging became painful. This post explains the hidden costs, with simple math, and how to decide when serverless is worth it.


🎯 Quick Answer (30-Second Read)

  • Serverless is cheapest for spiky or low traffic; it can get expensive at steady, high volume, where an always-on server is often cheaper.
  • Hidden costs: cold starts, database connection limits, egress and extra managed services, duration billing on slow I/O, observability, and vendor lock-in.
  • Do the break-even math for your actual traffic.
  • Hybrid is normal: serverless for APIs and spikes, containers or servers for steady heavy workloads.

The Pricing Model, Simply

Serverless functions are usually billed on:

  1. Number of requests
  2. Duration × memory (GB-seconds), or active CPU time on some platforms
  3. Extras: data transfer, API gateways, logs, other managed services

A server is billed for time it's running, busy or idle.

xychart-beta title "Monthly cost vs traffic (illustrative)" x-axis ["Low", "Medium", "High", "Very high"] y-axis "Relative cost" 0 --> 100 line [3, 18, 45, 90] line [25, 25, 35, 45]

Illustrative shape: the steeper line is pay-per-request serverless; the flatter line is always-on servers that step up as you add capacity. Where they cross depends entirely on your workload and provider prices.

Key takeaway: serverless trades a low starting cost for a higher marginal cost per request. That's a great deal while traffic is small or spiky, and a worse one once traffic is steady and heavy.

The Hidden Costs

1. Cold Starts

When a function hasn't run recently, the platform must start a new instance, adding latency to that first request. Isolate-based platforms (like Cloudflare Workers) reduce this a lot; container-based functions can be slower to start. Keeping instances warm or using provisioned concurrency fixes it, at extra cost.

2. Database Connections

flowchart LR F1["fn instance"] --> DB[("Postgres
connection limit")] F2["fn instance"] --> DB F3["fn instance ×100"] --> DB DB --> X["Too many connections"]

Each instance opens its own connections, so scaling out can exhaust your database. You'll need a pooler or a serverless-friendly database. (Fix Postgres Too Many Connections)

3. Paying for Waiting

If you're billed for wall-clock duration, a function waiting 5 seconds on a slow API or an LLM costs the same as computing for 5 seconds. Some platforms now bill active CPU instead, which helps I/O-heavy workloads; check how yours bills.

4. The Bill Around the Function

Extra Why it adds up
API gateway Per-request fees on top of the function
Data transfer (egress) Charged per GB leaving the cloud
Logs and tracing High-volume logs can rival compute cost
Queues, caches, storage Separate managed services, each billed

5. Limits and Lock-In

  • Maximum execution time per invocation (Fix Vercel Function Timeout)
  • Memory, payload and bundle-size limits
  • Platform-specific APIs (triggers, bindings, configuration) that make moving harder

6. Debugging and Testing

Many short-lived functions spread across managed services are harder to trace, test locally and reason about than one service. Good observability is required, and it costs time and money.


When Serverless Is Worth It

✅ Great fit ⚠️ Think twice
New products, side projects, MVPs Steady, high-volume APIs
Spiky or unpredictable traffic Long-running jobs (video processing, large batch)
Event-driven tasks (webhooks, file uploads, cron) Latency-critical paths sensitive to cold starts
Small teams without ops capacity Heavy database connection needs without pooling

A Practical Decision Process

  • Estimate requests, average duration and memory per month
  • Price it on your platform, including gateway, egress and logs
  • Price an equivalent container or VM setup, including ops time
  • Factor in team skills: managing servers isn't free either
  • Revisit when traffic patterns change; moving steady workloads to containers later is common

(See also Serverless vs Containers.)


Frequently Asked Questions

Is serverless cheaper than servers?

For low or spiky traffic, usually yes, because you don't pay for idle capacity. For steady, high-volume workloads, always-on servers or containers are often cheaper per request. The break-even point depends on your traffic, function duration, memory and provider pricing.

What are the disadvantages of serverless?

Common drawbacks are cold-start latency, execution time and memory limits, database connection exhaustion, extra costs from gateways, egress and logging, harder debugging across many functions, and lock-in to platform-specific features.

How do I reduce serverless costs?

Right-size memory, reduce function duration and avoid waiting on slow calls, cache responses, batch work, use connection pooling, trim logging, and move steady high-volume workloads to containers. Check whether your platform bills wall-clock time or active CPU.


Conclusion

Serverless is a superb default for new and spiky workloads, but its per-request pricing, cold starts, connection limits and surrounding services can make it expensive at steady scale. Do the break-even math with your real numbers, use serverless where it shines, and don't be afraid of a hybrid with containers for heavy, predictable traffic.


Sources

Last verified: 2 November 2026.


Related reads: Serverless vs Containers · Cloudflare Workers Tutorial · Fix Vercel Function Timeout · Why Free Apps Cost Billions to Run

I write about system design and how real products are built. Follow on LinkedIn or X, or invite me to speak.