AINexus
Tutorial2 min read11d ago·2 comments·3335 views

Hands-on · step by step

Tutorial: serve an 8B model at 3x throughput with continuous batching

by @aiko — Inference · serving · GPUs

Four steps to self-hosted LLM serving with vLLM and Kubernetes — checkpoints, tuning knobs and the failure to guard first.

Before you start — about 45 minutes · vLLM · Kubernetes · Prometheus

Short version: one code path, explicit limits, a command that proves it works. Here is self-hosted LLM serving, end to end.

Step 1 — Decide what "working" means

Before touching code, write down three numbers: worst acceptable latency, cost per request, and what should happen when the upstream is unavailable. Everything after this is implementation.

Step 2 — Wire vLLM

The whole flow is one path. No special branches for "large" inputs — express those as different limits, not different code.

# vLLM: size the KV cache explicitly instead of hoping
python -m vllm.entrypoints.openai.api_server \
  --model mistral-small \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.90 \
  --enable-prefix-caching \
  --max-num-seqs 128

Why this works

The limit is enforced before the expensive call, not after it. Reserving budget up front means a burst degrades the caller that caused it instead of everyone downstream.

Step 3 — Guard the failure path

KV-cache memory, not model weights, is what actually OOMs your node

Write that guard before you write the feature. It costs an hour and saves a postmortem.

Step 4 — Verify it

curl -s localhost:8000/metrics | grep -E 'gpu_cache_usage|num_requests_running'
  • Lower the limit and confirm the command fails loudly
  • Kill the upstream and confirm you get a typed error, not a timeout
  • Check the metric you emit per outcome: ok, throttled, upstream_error

Tuning knobs

KnobDefaultWhat we runWhy
concurrency824Most of the wait is network, not compute
retry budgetinfinite2, with jitterUnbounded retries turn an outage into an avalanche
timeout30s8s, inherited from the callerNobody waits 30s for a chat reply

That is it. No framework required.

Comments (2)

Log in to join the discussion.

@priya·2h ago

Bookmarked. The verification step is the bit most write-ups skip.

@leila·2h ago

We hit the exact same trap last quarter. The fix was smaller than expected.