Skip to content
Go back

LLM Inference Architecture

Edit page

80/20 Of The Week … LLM Inference Architecture

Talking about models is cool and all. I do it all the time, especially when DeepSeek drops.

But the thing is, how much complexity shows up when you actually have to serve these things to real users.

I think I talked about LLM inference before, at least I think I have, but this time I want to look at the architecture around it. How do you serve a lot, a lot of people without the whole thing falling apart? Also, a Git link at the bottom for the production AI mini showcase.

Start with one request. One model on one massive GPU. A prompt goes in, tokens come out.

Under light load, that massive GPU spends much of its time idle, and the bill keeps coming. Under heavy load, the same GPU gets overloaded, requests fight for it, and latency climbs. Even one massive GPU is not a production fleet.

Batching is the first fix. Put compatible requests through the model together. Throughput goes up, but the tail gets slower because someone always waits for the batch. It does not give you more GPUs or a fleet that survives a failure.

Then the KV cache shows up. The model saves the attention state for tokens it already saw, so it does not reprocess the prompt for every new token. A prompt becomes a prefill job, and the result is saved as kv-123. The annoying part is memory. That state adds up, which is why paged allocation and eviction exist.

Prefill and decode are the next split. Prefill reads the prompt and is compute-heavy. Decode writes one token at a time and is memory-bandwidth-heavy. If both run in the same pool, one shapes the other. Separate pools let each scale for its own bottleneck.

In front of that sits a gateway and a router. Auth, rate limits, cache-aware placement, health checks, retries. If the router finds kv-123, it skips prefill and goes straight to decode. If decode-2 dies, it should retry another worker and move kv-123, so the user sees a short delay instead of a failed request.

Kubernetes is not decoration. Probes, autoscaling, metrics, and a plan for a dead worker decide whether the system survives a pod disappearing mid-request. You can have a great model and still lose the request because the control plane was an afterthought.

TLDR

Batching, the KV cache, prefill/decode separation, routing and failure handling explain most of what a production serving system does. The model is one part. The rest is the system around it.

I built a small version to see the shape in practice. Eight small Go services, nine Kubernetes pods, a gateway, a cache-aware router, separate simulated prefill and decode pools, a KV metadata store, a model registry, Prometheus and Grafana. It runs on CPU, the upload bundle is 23 MB, and a simulated load test completed 200/200 requests. It is a quote-unquote mini mock, not real GPU inference, but the shape is the shape. I plan to grow it.

https://lnkd.in/dedB9fPX

Diagram of a request moving through an LLM serving stack


Edit page
Share this post on:

Next Post
How Can an LLM Have Hundreds of Billions of Parameters Without Using All of Them?