10 min
A guide to serverless and dedicated containers for LLM hosting
Compare serverless vs. dedicated containers for LLM hosting using GPU prices, break-even utilization, cold starts, and code execution options.

Serverless LLM hosting bills you for GPU seconds and scales to zero when traffic stops. Dedicated containers keep a model warm around the clock at a fixed hourly rate. The choice depends on how steady your traffic runs and how much a cold start hurts.
Flexibility carries a premium. RunPod lists an H100 SXM pod at $3.99 per hour. Its serverless H100 tier costs $5.39 per hour, billed per second. Serverless also adds startup delay. Google says Cloud Run GPU instances start in approximately 5 seconds.
Coding agents add a second decision that sits outside the GPU. The code a model writes needs an isolated place to run. Blaxel provides CPU sandboxes for that execution layer. This guide compares inference options first, with November 2026 prices, then turns to execution.
Key takeaways
- Serverless GPU fits bursty traffic. A RunPod H100 pod beats its serverless tier above 74% utilization.
- Image pulls and weight downloads dominate serverless cold starts, which can take minutes for large models.
- One to three platform engineers cost 4.6 to 13.8 times a 24/7 RunPod H100 pod.
- AI-generated code needs a separate, hardware-isolated execution layer, wherever your inference runs.
Serverless GPU vs dedicated containers vs managed endpoints
Serverless LLM hosting, dedicated containers, and managed endpoints differ most on cold start, idle cost, scaling, and operational load.
| Factor | Serverless GPU containers | Dedicated containers | Managed per-token endpoints |
|---|---|---|---|
| Examples | Google Cloud Run GPU, Modal, RunPod Serverless, Azure Container Apps serverless GPU | vLLM or SGLang on Kubernetes or VMs | Together AI, Fireworks, Groq |
| Cold start | Cloud Run attaches a GPU instance in approximately 5 seconds, before model loading starts | None once warm. Adding GPU nodes or replicas takes longer. | Fireworks documents no cold boots on its serverless tier. |
| Idle cost | Zero after scale-down | Full GPU-hour rate, busy or idle | Zero. You pay per token. |
| Scaling | Automatic, per request, from zero | Your autoscaler plus GPU node provisioning | Provider-managed, within rate limits |
| Ops burden | Container image and platform config | Drivers, autoscaling, upgrades, and on-call | An API key |
| Model control | Your container and weights, limited GPU types | Full control of GPU type, count, and serving stack | Provider's catalog, often limited fine-tune hosting |
Cloud Run, Azure Container Apps, and RunPod Serverless all run your container image. The difference is who owns scheduling and scaling. On serverless platforms, the provider does. On dedicated infrastructure, your team does. Check who owns scheduling and scaling when a vendor calls a container product "serverless."
Once warm, serverless and dedicated containers running the same model and engine should respond at similar speed.
Managed endpoints suit teams that don't want to run inference infrastructure at all. Providers like Together AI bill per token. There's no idle cost and no capacity to plan.
In exchange, teams give up control. Fine-tuning or hosting custom models is often costly or unavailable. The provider sets availability and rate limits.
Serverless infrastructure for coding agent LLMs
Serverless platforms handle scaling, patching, and capacity planning. For coding agent inference, you get lower operational load but accept cold starts and fewer GPU choices.
CPU inference on AWS Lambda
AWS Lambda runs CPU workloads, and its quotas list memory and CPU, not GPUs. The published limits allow 128 MB to 10,240 MB of memory and a 900-second (15-minute) timeout. Lambda can serve AI models with CPU-only inference, which suits small models.
Cold starts add a second constraint. Lambda SnapStart restores from a cached snapshot of the initialized environment instead of booting fresh. Lambda response streaming sends tokens as the model produces them and supports 200 MB response payloads.
CPU inference on Lambda works for autocomplete and for small fast-apply models. Lambda doesn't suit interactive coding sessions, where users expect real-time feedback from larger models.
GPU inference on Google Cloud Run
Cloud Run offers two GPU types, NVIDIA L4 and RTX PRO 6000 Blackwell. They carry 24 GB and 96 GB of video memory (VRAM), respectively. Each instance gets one GPU. The RTX PRO 6000 requires at least 20 CPU cores and 80 GiB of memory. According to Google, the RTX PRO 6000 can serve 70B+ models on demand with scale-to-zero.
Cloud Run pricing lists the L4 at $0.0001867 per second, or $0.67 an hour. The RTX PRO 6000 is $0.00036522 per second, or $1.31 an hour. Both are Iowa (us-central1) rates without zonal redundancy. Zonal redundancy is on by default and raises them to about $1.05 and $2.05 an hour.
Cloud Run bills CPU and memory separately. Keeping one L4 warm for a 720-hour month costs about $484 in GPU charges alone.
For coding agents, warm instances usually decide the bill. Interactive sessions can't absorb a cold start, so you'll likely keep minimum instances running. Each warm instance turns serverless pricing back into a fixed monthly cost.
Serverless GPU platforms with per-second billing
Modal, RunPod Serverless, and Azure Container Apps offer short-lived GPU access with per-execution billing. Billing runs per second while a worker is up and stops after scale-down.
| Platform | GPU | Published rate | Per active hour (calculated) | Notes |
|---|---|---|---|---|
| Modal | H100 SXM5 | $0.001097/s | $3.95 | CPU and memory billed separately. Region selection multiplies prices by 1.15x to 1.75x. |
| Modal | L4 | $0.000222/s | $0.80 | Same CPU, memory, and region charges apply |
| RunPod Serverless | 16 GB class to 288 GB B300 | $0.58/hr to $11.99/hr | $0.58 to $11.99 | Flex workers scale to zero |
| Azure Container Apps (Central US) | NC A100 v4 | $0.000651/s | $2.34 | vCPU and memory billed on top |
| Azure Container Apps (Central US) | NC T4 v3 | $0.00009/s | $0.32 | vCPU and memory billed on top |
Modal rates come from Modal pricing. RunPod publishes its rates on RunPod Serverless. Azure figures are from Azure Container Apps pricing. Azure's serverless GPUs currently cover A100 and T4 only.
Read the metering rules closely. RunPod bills from worker start to full stop, rounded up to the nearest second. You pay for the cold start until your handler is ready, so a slow-loading model inflates every scale-up.
Where serverless cold starts come from
A cold start is a chain of stages, and image pull and weight download dominate it. RunPod's own September 2026 measurement on a four-GPU H200 worker shows the main stages:
| Stage | What happens | Published example |
|---|---|---|
| Image pull | Download and extract the container | About 4.5 minutes |
| Weight download | Fetch weights to the host | 167.7 seconds for about 173 GiB |
| Weight load | Move shards into GPU memory | 38 seconds |
| Engine init | Start the inference engine | 35.3 seconds in eager mode |
| Total | Scale-up to first health check, including steps not listed | About 11 minutes |
Source: RunPod's Qwen3.8-Flash-Next guide. Caching the container image shortens the first stage.
On Cloud Run L4 with Ollama, Google measured 11 to 35 seconds from zero to first word. Google's tests used 2B to 13B models. Even the 11-second case is long for an interactive coding session, so plan on warm capacity.
Mitigating cold-start latency for interactive applications
Three techniques shorten cold starts, and one of them adds standing cost:
- Minimum instances: One warm replica eliminates cold-start delays on Azure Container Apps but incurs continuous cost.
- GPU memory snapshots: Modal restores initialized GPU state instead of reloading. On a 3B model with vLLM, median cold start fell from about 118 seconds to 12 with snapshots.
- Local weight caching: Weights on node-local storage skip the download stage, which speeds repeat launches on the same node.
Before committing, time cold starts on your own model, from an idle endpoint to the first token. Run cold and warm requests separately, and report the median plus p90, p95, and p99. A peer-reviewed benchmark of serverless container platforms says percentiles give a fuller picture than averages.
The benchmark also found that AWS Fargate and Azure Container Apps responded differently under concurrent load.
RunPod also tested Qwen2.5-14B in FP8 on vLLM 0.32.0, using October 29, 2026 prices. Its GPU inference benchmark reports:
| Deployment | Request rate | Output throughput | Cost per million output tokens |
|---|---|---|---|
| A40 Pod | 1 request/second | 114 tokens/second | $1.44 |
| A40 Pod | 4 requests/second | 454 tokens/second | $0.36 |
| 48 GB Serverless on A40 | 4 requests/second | 409 tokens/second | $0.83 |
Four requests per second was the highest Pod rate that met the benchmark's targets. Those targets were one second to first token and 50 milliseconds per output token. At that rate, the Pod cost less than half as much per token as serverless. RunPod ran the test on its own products, so the test doesn't cover managed endpoints.
Dedicated container infrastructure for coding agent LLMs
Dedicated infrastructure fits when you need full control over latency, model customization, or data residency. Teams with consistent high-volume workloads and platform engineering capacity end up here.
Inference engines and GPU requirements
Teams widely use two open-source engines. vLLM uses PagedAttention to manage key-value cache memory, plus continuous batching and prefix caching. SGLang emphasizes fast prefix caching with RadixAttention, which helps multi-turn agent workloads.
Batching lets dedicated hardware earn its cost. Continuous batching evicts finished sequences and admits new requests on every iteration. More concurrent requests mean fuller batches and lower cost per token.
A serverless instance at low traffic runs near-empty batches. In Google's Cloud Run example, three model instances need a maximum concurrency of 24. Each instance handles four parallel queries plus an ideal batch of four.
Kubernetes as the dedicated tier
Two Kubernetes releases in 2025 and 2026 changed how clusters schedule GPUs.
| Capability | Change |
|---|---|
| Dynamic Resource Allocation (DRA) | Reached general availability in Kubernetes v1.34, enabled by default. |
| Extended resources | In v1.37, DRA extended resource support reached general availability. DRA drivers can now satisfy standard GPU resource requests. |
Autoscaling and model loading both need LLM-specific tuning.
| Area | Finding |
|---|---|
| Autoscaling | Google's tests on Google Kubernetes Engine (GKE) found GPU utilization is not an effective metric for autoscaling LLMs. Queue size and batch size worked better. |
| Model loading | On Amazon Elastic Kubernetes Service (EKS), configuration tuning cut a 64 GiB model's first launch from 82 to 65 seconds. Later launches on the same node took 16 seconds. |
When dedicated makes financial sense
The break-even utilization is the dedicated hourly rate divided by the serverless active-hour rate. Above that share of busy time, an always-on instance costs less. Applied to RunPod and Modal list prices, the formula gives these thresholds:
| Comparison | Dedicated rate | Serverless active rate | Break-even utilization (calculated) |
|---|---|---|---|
| RunPod A100 80GB | $1.79/hr pod | $2.72/hr serverless | 66% |
| RunPod H100 80GB SXM | $3.99/hr pod | $5.39/hr serverless | 74% |
| RunPod H100 pod vs Modal H100 (GPU only) | $3.99/hr | $3.95/hr | None. Modal's CPU, memory, and region charges decide it. |
Rates come from RunPod pricing and Modal's pricing page. According to Together AI's deployment guide, the break-even utilization shifts with model size, token mix, cache hit rate, and GPU.
Modal's GPU-only charge stays below a 24/7 RunPod H100 pod even at 720 busy hours.
| Monthly busy GPU-hours | Share of a 720-hour month | Modal H100, GPU only | RunPod H100 pod, 24/7 |
|---|---|---|---|
| 40 | 6% | $158 | $2,873 |
| 73 | 10% | $288 | $2,873 |
| 176 | 24% | $695 | $2,873 |
| 432 | 60% | $1,706 | $2,873 |
| 720 | 100% | $2,843 | $2,873 |
Modal's figures exclude CPU and memory, which cost 3x list for non-preemptible work, plus region multipliers. With those charges included, the high-utilization rows can flip. RunPod's own worked example prices 1 million Llama-3-70B requests two ways. A 24/7 pod at 15% to 25% utilization costs $1,137.60 a month, while serverless costs $264.20.
Dedicated VMs also bill per second after a short minimum. Compute Engine charges a 60-second minimum. EC2 Linux has a 60-second minimum.
Staffing costs of dedicated hosting
Platform engineers in the US earn an average of $158,258 a year. A deployment that needs one to three of them costs $158,000 to $475,000 a year before GPU spend. That comes to $13,000 to $40,000 per month. Staff alone cost 4.6 to 13.8 times the monthly price of one 24/7 RunPod H100 pod.
GPUs also sit underutilized during off-peak hours unless someone actively manages capacity. Without steady volume and in-house platform skills, serverless platforms or managed endpoints avoid that staffing cost.
How to choose between serverless and dedicated for LLM inference
Work through these steps in order:
- Check hard constraints. Confirm your model fits your target platform's GPU limits. For example, Cloud Run allows one GPU per instance. Check request time limits and runtime control. Lambda container images run on a read-only filesystem apart from
/tmp. Dedicated hosts let you pin CUDA versions and choose any inference server. - Map the invocation pattern. Batch and scheduled workloads tolerate cold starts, but interactive coding sessions can't.
- Measure the duty cycle. Pull a week of traffic logs and count busy GPU-hours. Apply the break-even formula to your actual vendor quotes.
- Set a first-token budget. If measured cold starts exceed it, price warm minimum instances as a fixed cost.
- Trace your data boundaries. Managed endpoints send your prompts and generated code to a third party. Confirm your data policy allows it.
- Plan hybrid routing. Size dedicated capacity for your steady baseline. Send overflow to a serverless endpoint when dedicated queue depth passes a set threshold. A gateway in front of both decides the path.
- Price the exit. Container images move between providers with little change, but proprietary SDKs require rewrites.
Selecting the right inference deployment model requires balancing traffic predictability, latency requirements, operational load, and overall spend.
Check capacity and reliability before committing
Scale-to-zero doesn't guarantee a GPU will be available when demand returns. Serverless GPUs come from a shared provider pool that can deny allocation, unlike reserved dedicated capacity.
| Capacity check | Serverless pool | Reserved dedicated capacity |
|---|---|---|
| Regional availability | Verify the GPU and quota in the target region | Verify the reservation's region and GPU |
| Allocation denied | Confirm whether requests queue or fail | Confirm the reservation's scope and replacement policy |
| Burst headroom | Test concurrent scale-out across multiple workers | Size spare capacity and overflow routing |
Before requesting reserved capacity:
- Specify the GPU type, count, region, and baseline workload.
- Verify that any fallback route stays within your data boundary.
Availability commitments and latency targets are different checks. A responsive warm endpoint still needs failover and monitoring.
The missing layer: code execution for coding agents
Choosing how to host your LLM is half the architecture decision. The other half is where generated code runs.
The execution layer must handle untrusted code. A model's output can range from a print statement to a recursive directory deletion.
The execution layer has three requirements that differ from inference hosting:
- Security isolation: One user's execution must never access another user's data. Containers suit your own trusted inference servers. AI-generated code in multi-tenant products needs hardware-enforced boundaries because containers share the host kernel. Firecracker microVMs give each workload its own guest kernel. They start in under 125ms with under 5 MiB of memory overhead.
- Low latency: Sandbox startup time adds to every script the agent runs. Fast inference can't hide a slow sandbox.
- State persistence: The environment must keep cloned repositories, installed dependencies, and filesystem state across interactions. Rebuilding that state on every invocation slows each session.
Decoupling inference from code execution ensures that host security, persistent environment state, and responsiveness remain uncompromised.
How coding agents use LLMs differently
Coding agents use LLMs differently from chatbots. A chatbot sends a prompt, gets a response, and displays it. A coding agent sends a prompt, gets code back, and executes that code in an isolated environment. Then it reads the result and often sends another prompt based on what happened.
This generate-execute-observe-iterate loop creates two infrastructure requirements. The inference layer handles token generation. The execution layer runs the code safely and returns results. Both layers add latency to every interaction.
On the inference side, many production coding agents use hierarchical model architectures. A frontier model like Claude or DeepSeek V3 handles reasoning and code generation. Smaller specialized models handle fast apply, which merges AI-generated edits into existing files. Morph offers a dedicated Fast Apply model for this step.
NVIDIA researchers studied three open-source agents: MetaGPT, Open Operator, and Cradle. The researchers estimate small models under 10B parameters could handle 40% to 70% of LLM calls. For hosting, this split lowers cost because small models fit cheap serverless tiers. Frontier calls usually go to an API or dedicated GPUs.
AWS Lambda vs a managed sandbox for agent code
Lambda works for short, stateless tool calls. Each invocation gets ephemeral /tmp storage of 512 MB to 10,240 MB. State resets between invocations unless you adopt Lambda durable functions, which checkpoint progress in code.
AWS also offers Lambda MicroVMs, built for user- or AI-generated code. Each MicroVM runs up to 8 hours, including suspended time. Single sessions fit within that cap, but an agent that returns to a project across days doesn't.
A managed sandbox keeps the filesystem, memory, and running processes between agent turns. It also adds preview URLs, attachable storage, and SDKs built for agent workflows. Choose standard Lambda functions for discrete stateless calls. For multi-turn projects, compare managed sandboxes with Lambda MicroVMs on session duration and state handling.
Complete your coding agent stack with an execution layer
Pick your inference host on traffic shape, latency budget, and team capacity. Then choose the execution layer on isolation and session length.
For multi-turn coding agents, Baseten Sandboxes, the infrastructure foundation for autonomous agents, are one execution-layer option. It runs the code LLMs generate in hardware-isolated microVM sandbox environments and works with whichever host serves the model. Baseten Sandboxes resume in under 25ms with memory and filesystem intact.
They return to standby after about 15 seconds of network inactivity, so compute charges stop. Blaxel is a first-class sandbox provider in the OpenAI Agents SDK, with SDKs for Python, TypeScript, and Go. Compliance covers SOC 2 Type II, HIPAA, and ISO 27001.
FAQs about serverless vs dedicated containers for LLM hosting
Do I need separate infrastructure for inference and code execution?
Yes. Inference infrastructure (GPU clusters, serverless endpoints, API providers) optimizes for token throughput. Code execution infrastructure optimizes for security isolation, state persistence, and fast process management. Running them as separate layers lets you swap inference hosts without rebuilding your sandboxes.
What models work best for coding agents?
A common pattern splits the work by model size. A frontier model plans and writes code, while a small model merges edits into files. The small model can run on a cheap serverless or single-GPU tier. The frontier model usually runs through an API provider or on multi-GPU dedicated hardware.
When should I use serverless vs dedicated for the inference layer?
Use serverless when traffic is bursty, and your utilization sits below the break-even threshold you calculated. Move to dedicated when traffic is steady or cold starts break your latency budget. Dedicated also suits multi-GPU models, since some serverless platforms, such as Cloud Run, allow one GPU per instance. A hybrid setup handles both: a dedicated baseline with serverless overflow.
How does the execution layer affect total latency?
Execution latency adds to every tool call. An agent that starts a fresh sandbox for each of five tool calls pays the startup cost five times. A sandbox that resumes from standby with memory and filesystem intact avoids those repeated startups. Measure tool-call latency on your own workflow before choosing a provider.
Which platforms offer short-lived GPU access with per-execution billing?
Serverless GPU platforms charge by the second for active workers and cost nothing after scale-down. Google Cloud Run, Modal, RunPod Serverless, and Azure Container Apps all bill GPU time per second. Ask each vendor whether it bills cold-start time, because short tasks pay that cost on every scale-up.
Related articles

Guides
What is a computer use agent? How AI agents automate GUI workflows
Learn how a computer use agent operates software through screenshots, clicks, and keystrokes.
13 min read

Guides
A guide to Bring Your Own Cloud (BYOC) for enterprise leaders
Learn what BYOC is and how Bring Your Own Cloud splits the control and data planes for enterprise workloads.
12 min read

Guides
How gVisor vs Firecracker compare for sandboxing AI agent workloads
Compare gVisor vs Firecracker on isolation, startup, I/O overhead, KVM needs, and Kubernetes fit to choose the right sandbox runtime.
12 min read