Skip to content
$EngineeringAtlas

Running LLM Inference on Serverless GPUs

When serverless GPUs make sense for AI inference, how to control cold starts, and where managed model APIs still win.

Amit Kumar Singh2 min read

The Problem

Managed model APIs are simple, but some teams need custom weights, private fine-tunes, special runtimes, or stricter data boundaries. Running GPUs yourself is powerful, but idle GPU capacity is expensive.

Why It Matters

Serverless GPU platforms now make bursty inference more practical. They can scale to zero, start instances on demand, and remove most driver management. The trade-off is startup latency and less control than a dedicated cluster.

Core Concepts

Your inference path has three parts: container startup, model load, and token generation. Cold start work must be minimized. Large model files should live in a nearby storage mount or be streamed efficiently. The autoscaler needs a metric that matches user pain, usually queue depth or request latency.

Implementation

Keep the container boring:

FROM vllm/vllm-openai:latest

ENV MODEL_PATH=/models/app-model
CMD ["--model", "/models/app-model", "--host", "0.0.0.0", "--port", "8080"]

Pin runtime versions in production and load-test startup separately from steady state throughput.

Real Project Scenario

A legal-tech product summarizes uploaded contracts with a private fine-tuned model. Usage is spiky because customers upload batches at the end of the day. Serverless GPU inference can reduce idle cost, but only if the app accepts cold-start latency or moves work to an async queue.

Production Setup

Expose two paths: synchronous for small, latency-sensitive requests and async for large documents. Track queue wait, cold start, model load, time to first token, tokens per second, and GPU memory. Those metrics show whether the bottleneck is startup, generation, or scheduling.

Common Mistakes

  • Baking huge model files into every image layer.
  • Scaling only on CPU while the GPU queue is saturated.
  • Forgetting that scale-to-zero creates a first-request penalty.
  • Running a custom model when a managed API would be cheaper and more reliable.

Production Considerations

Use request deadlines and a fallback path. For interactive apps, consider keeping a small warm floor during peak hours. For batch jobs, accept longer startup and scale more aggressively.

Security

Do not pass secrets through prompts or model files. Treat model artifacts like code: sign them, scan them, and control who can publish them.

Performance

Measure time to first token, tokens per second, queue wait, and GPU memory usage. Quantization can reduce cost, but verify accuracy on your own tasks.

Summary

Serverless GPUs are useful for custom or private inference with uneven demand. They work best when startup, model placement, autoscaling, and fallbacks are designed up front.

Amit Kumar Singh

// written by

Amit Kumar Singh

Software engineer writing about backend systems, cloud, and the realities of running code in production.

$ subscribe --weekly

The weekly engineering digest

Production-grade engineering writing in your inbox. No spam, unsubscribe anytime.

## related

MCP for Backend Engineers

How the Model Context Protocol connects AI clients to tools and data, and what backend teams must get right for auth, permissions, and auditability.

Amit Kumar Singh2 min read