Unit 9 of 12 · about 4 hours · implement, measure
Per-request logs, metrics and traces, and engine and hardware telemetry
Undashboarded serving is unoperated serving. The metric names, phases and trace joins chosen here become every later diagnosis.
You'll be able to
- Emit per-request logs, metrics and traces joined by
request_idthat explain one request's TTFT and every decode gap. - Build engine dashboards from queue, phase, token, cache and scheduler metrics with alerts on TTFT, KV pressure and stalls.
- Contrast vLLM and SGLang phase boundaries so dashboards survive an engine swap.
Covers
Read
In this order, only the parts listed
0 of 5 done
- vLLM production metricsvLLM Production Metrics
General Metrics table (
vllm:num_requests_waiting,vllm:num_requests_running,vllm:kv_cache_usage_perc,vllm:prefix_cache_hits,vllm:request_success,vllm:time_to_first_token_seconds,vllm:request_queue_time_seconds,vllm:request_prefill_time_seconds,vllm:request_decode_time_seconds,vllm:e2e_request_latency_seconds); MFU counters behind--enable-mfu-metrics; Deprecation Policy - vLLM metrics design and tracingvLLM Online Serving, Architecture and Production Metrics
Scheduler Stats and Engine Core Events, KV Cache Residency Metrics (
vllm:kv_block_lifetime_seconds,vllm:kv_block_idle_before_evict_seconds), and Tracing with--otlp-traces-endpointplus--collect-detailed-traces - SGLang production metricsSGLang documentation - Production Metrics
TTFT definition (streaming ends at first output after detokenization, which may hold no printable text; non-streaming ends at first scheduler token); request TPOT as
(finished_time - first_token_time) / (completion_tokens - 1)with its four exclusions; the p95 TPOT PromQL example (page read 2026-10-14) - AI Systems ch16 monitoring bundle and load harnessAI Systems Performance Engineering - Production Inference Labs
monitoring_config.pymetric names with alert thresholds (TTFT p90 warn 0.6s, p99 crit 1.5s, KV warn 90% crit 98%, stalled floor 50);vllm_monitoring.pyrecording rules withVLLMHighTTFTP90alerts and Grafana panels;inference_server_load_test.pyload harness feedingcapacity_planner.pyRe-measure every bundled expectation on your hardware. The B200 numbers in the expectations files are the authors' results, not your targets.
- Production observability checklistInference Engineering - Chapter 7, Production
Section 7.4.3 (printed p. 203): volume, request and response sizes, response codes, latency as TTFT plus tokens per second plus end-to-end on P50/P90/P99, replica count, CPU, host memory, GPU and GPU-memory utilization, queue depth; server plus audit logs
Focus on
- One request, one ID, three signals: the log line carries
request_idwith queue, prefill, decode and stream timings; the histograms carry the same labels; the trace carries the same ID across frontend, scheduler and runner. Diagnosis starts by joining them. - Queue versus execution is a metric pair, not a feeling:
vllm:request_queue_time_secondsagainstvllm:request_prefill_time_secondsplusvllm:request_decode_time_seconds. TTFT alone cannot separate them. - Gauges describe state (
vllm:num_requests_waiting,vllm:kv_cache_usage_perc); counters describe events (vllm:request_success, token totals). Rate the counters, read the gauges, never the reverse. - TTFT, TPOT and ITL are engine-defined. SGLang's streaming TTFT ends at first detokenized output (possibly empty text) while vLLM's measures first-token time; a dashboard that compares them across engines compares different quantities.
Common mistakes · 3
- Labelling metrics by prompt text or user ID. Cardinality explodes Prometheus; label by model, version and class, and join to raw text only through the request ID in logs.
- Timing decode with per-token host synchronization. The observer serializes the pipeline it measures; prefer engine histograms and sampled profiler ranges over naive timers.
- Treating
vllm:request_successas a gauge. It is a cumulative counter split byfinished_reason(stop,length,abort); alert on its rate, and count aborts as cancellations, not successes.
Try it yourself
Closed-book, before checking anything
/metrics before and after. Show vllm:num_requests_waiting, vllm:kv_cache_usage_perc and the vllm:time_to_first_token_seconds count moving with load, then pull one request's full timeline from logs by its request_id.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.TTFT spikes but prefill time is flat. Queue or execution problem?Answer
Queue. Flat prefill with rising TTFT means
vllm:request_queue_time_secondsgrew while execution held; add replicas or shed instead of tuning kernels.2.How do you compute per-request decode tokens per second from SGLang's TPOT histogram?Answer
Take the reciprocal of the TPOT quantile (p5 TPS equals 1 over p95 TPOT). The reciprocal of mean TPOT is not mean TPS; aggregate rates per request first.
3.Which requests never appear in SGLang's request-TPOT histogram?Answer
Requests with fewer than two output tokens, streaming requests finishing in their first output, aborted requests and disaggregated prefill workers.
4.KV usage sits at 0.97 while TTFT p99 reaches 2s. Which ch16 alerts fire, and what do they mean together?Answer
The KV warn alert (0.97 is above the 90% warn and below the 98% crit) and the TTFT p99 critical alert (2s against 1.5s). Together they point at memory pressure turning into queueing, not slow compute: shed, evict or add capacity.
Practice
- AI Systems ch16: monitoring bundle under load
Deploy
vllm_monitoring.pywithconfigs/vllm_monitoring.yamlagainst a local vLLM server, driveinference_server_load_test.py, and satisfy the validation checklist inREADME.mdShow one alert (TTFT, KV or stalled) firing with its Grafana panel, and record exporter overhead beside the latency numbers.
You're done when
One request ID yields its full timeline across logs, metrics and traces, and your dashboard separates queue, prefill, decode and KV pressure without ambiguity.
Only when you can do this without notes.
Leads to
Notes
Resources · 5 for this unit, 8 more in the section
- vLLM Online Serving, Architecture and Production MetricsvLLM Project · primary
Trace the API server, engine core, scheduler, KV manager and model runner, then map documented metrics to your SLIs. The link is pinned to v0.31.0; add the auth, tenant, quality and rollout controls the engine leaves to you.
- vLLM Production MetricsvLLM Project · required
Define every selected queue, cache, phase and request metric, check histogram buckets and measure exporter overhead. Add model version, cancellation, rejection, quality sample and tenant-safe trace fields in the surrounding service.
- Inference Engineering - Chapter 7, ProductionPhilip Kiely (Baseten Books) · support
Read Chapter 7 for containers, autoscaling, cold starts, routing and queueing, zero-downtime deployment, cost estimation and client-side streaming. Skip the vendor section at its end.
- SGLang documentation - Production MetricsSGLang Project · support
Compare its metric names and phase boundaries with vLLM's, so your dashboards do not depend on one engine's vocabulary.
- AI Systems Performance Engineering - Production Inference LabsChris Fregly · required
Use Chapter 16 monitoring, cache health, capacity planning and load-test utilities, then Chapter 17 routing only if distributed. Add process death, overload and bad-version cases that the performance pairs do not cover.
Also in this section
- Hands-On LLM Serving and Optimization - Chapters 3 and 4, serving system designChi Wang and Peiheng Hu (O'Reilly) · required
Read Chapter 3 (an online service from scratch, batching with streaming, multi-model trade-offs) and the enterprise-architecture part of Chapter 4. Convert the designs into explicit request, model-lifecycle and failure state machines.
- Machine Learning Systems, Volume 2 - Inference at Scale and Serving Fault ToleranceHarvard (Vijay Janapa Reddi) · required
Read "Load Balancing and Request Routing", "Multi-Tenancy and Isolation" and "Autoscaling and Global Infrastructure" in Inference at Scale, then "Serving Fault Tolerance" and "Graceful Degradation" in the Fault Tolerance chapter.
- Gateway API Inference ExtensionKubernetes SIG Network · required
Study model-aware routing, endpoint selection and operational integration. Use it for architecture and an optional local deployment only after the service passes lifecycle and failure tests without Kubernetes.
- 100 Days of LLM Inference - Days 22 to 26Elizabeth Thomas · support
Use the container, autoscaling, routing, capacity and zero-downtime notebooks as small operational simulations. Replace calendar order and fixed scale targets with the stage checkpoint and your hardware limits.
- AI Infrastructure Engineer Learning - Project 103 LLM DeploymentAI Infra Curriculum · support
Use its Docker, API, monitoring, Kubernetes and cost files as scaffolding only. Check its resource assumptions against your own model and GPU, and rerun any benchmark before reusing a result.
- LLM Inference Systems Laboratory - Operations and FailureRoadmap-Final · support
Complete production gateway, isolation, telemetry, canary, drain, rollback and fault campaigns. Store first-cause timelines and revise runbooks from observed blind spots.
- OpenAI API Reference - streaming, auth, rate limits and request IDsOpenAI · reference
Read the chat streaming event shape with the
[DONE]terminator, bearer auth, rate-limit headers, andx-request-idwith caller-suppliedX-Client-Request-Id. vLLM is the implementation under test; use this only for the contract it claims compatibility with. - vLLM Multimodal Inputs - media validation, fetch policy and cache identityvLLM Project · reference
Read Online Serving for image, video and audio inputs:
--allowed-media-domains, fetch timeouts,--limit-mm-per-prompt, local-media path restriction, and media UUIDs for cache identity. The link is pinned to v0.31.0.