Prompt
I'm building a public API with unpredictable traffic; should I go serverless or containers?
Latest observation
Oct 26, 2026
OpenAI APIWeb search: off
If your traffic is highly variable and hard to predict, the default answer is usually:
Start with serverless if your API is mostly request/response and can tolerate platform limits.
Choose containers if you need more control, steady performance, or complex runtime behavior.
Go serverless when:
- Traffic has big spikes or long idle periods
- You want minimal ops and automatic scaling
- Your API endpoints are relatively stateless and short-lived
- Cold starts are acceptable or can be minimized
- You want to pay mostly for actual usage
Good fit: CRUD APIs, webhook handlers, lightweight public endpoints, bursty workloads.
Go containers when:
- You need consistent low-latency performance
- Requests are long-running or CPU/memory intensive
- You need custom networking, sidecars, background workers, or special libraries
- You expect sustained traffic and want predictable costs
- You want more control over deployment/runtime
Good fit: real-time APIs, streaming, heavy compute, WebSockets, complex services.
Practical rule of thumb
- Mostly bursty, simple API: serverless
- Always-on, latency-sensitive, or operationally complex API: containers
A common middle path
Many teams use:
- Serverless for the API edge
- Containers for heavier internal services/worker jobs
Things to check before deciding
- Cold starts: will a 200–1000 ms startup hurt you?
- Timeouts: do any endpoints run longer than platform limits?
- Concurrency: can the platform handle your burst pattern?
- Cost at scale: if traffic becomes steady, serverless can become more expensive than containers
- Operational complexity: do you want to manage scaling, health checks, and deployments yourself?
Recommendation
For an unpredictable public API, I’d usually start serverless, unless you already know you need:
- consistently low latency,
- long-running requests,
- or more control over the runtime/networking.
If you want, I can help you choose based on your expected request rate, latency target, and endpoint types.