LLM serving
Running models behind an API for many users, tuned for latency, throughput and GPU cost.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOverview
LLM serving is running a model as a production service: many users, concurrent requests, a latency target and a GPU bill. It matters once a team moves from calling a hosted API or running one model on a laptop to hosting open-weight models itself, for data control, cost at high volume or a fine-tuned model no provider offers.
Practitioners pick an inference engine such as vLLM or SGLang and expose an OpenAI-compatible endpoint so existing clients keep working. They size GPUs from the model's parameter count and quantisation, then tune what the engine offers: continuous batching, prefix caching, speculative decoding and splitting a model across several GPUs. They load-test with realistic prompt and output lengths, watch time to first token and tokens per second as concurrency grows, and compare the cost per request with a hosted API before committing.
What you will practise
- Serve an open-weight model with vLLM or SGLang and call it through its OpenAI-compatible API
- Estimate GPU memory for a model at two quantisation levels before choosing hardware
- Load-test an endpoint and plot time to first token and throughput as concurrency rises
- Turn on prefix caching for a shared system prompt and measure the change in latency
- Compare cost per thousand requests on your own GPUs with a hosted API for the same task
Learning paths
- Local models and fine-tuning
Run open-weight models on your own hardware, use them on private documents, decide when fine-tuning beats RAG or long context, and try a small LoRA fine-tune.
Tutorials
- Stream LLM responses to a web page with server-sent events
A Node server relays tokens as server-sent events, the page renders them as they arrive, and a Stop button cancels.
Tools for this skill
Key terms
Words you will meet while learning this, defined in the glossary.
- KV cache
Memory where a transformer stores attention keys and values for tokens it has already processed, so it does not recompute them each step.
- Speculative decoding
A speed-up where a small draft model proposes tokens and the large model checks them in one pass, keeping the ones it accepts.
- Throughput (tokens per second)
How many tokens a model or serving system generates per second, measured per request or across all requests.