Sub topic 14
Monitoring a Running vLLM Server
This chapter assumes that you know basic HTTP, JSON, and command-line use. You should also know how to start a vLLM server and send it requests.
A server can return correct text while still performing poorly. Monitoring shows whether requests are waiting, how long generation takes, and whether the GPU is being used effectively. vLLM exposes metrics in Prometheus format at /metrics. Prometheus is a monitoring system that periodically reads and stores measurements from services.
The request path
A request usually passes through these stages:
The prefill stage processes the input prompt. The decode stage generates output tokens one at a time. The first generated token is especially important for interactive applications.
Reading the metrics endpoint
Check the endpoint with curl:
curl -s http://localhost:8000/metrics | grep '^vllm:'The output contains metric names, values, and sometimes labels. Names can differ between vLLM releases, so inspect the output from the version you run instead of copying names blindly.
| Metric category | What it tells you | Useful question |
|---|---|---|
| Running requests | Requests currently using the scheduler | Is the server busy? |
| Waiting requests | Requests queued for execution | Is capacity saturated? |
| Request latency | Total time from request to response | Are users waiting too long? |
| Time to first token | Delay before generation begins | Is prefill or queueing slow? |
| Token counters | Prompt and generated token totals | What workload is the server handling? |
A high num_requests_waiting value means arrivals exceed the current service capacity. It can result from long prompts, long completions, too many concurrent requests, or insufficient GPU memory for the configured workload.
A high time to first token with low output length often points to queueing or expensive prefill. A high time per output token usually points to decode pressure, memory bandwidth limits, or excessive concurrency.
Scraping with Prometheus
A Prometheus server needs a scrape target. A minimal configuration might look like this:
scrape_configs:
- job_name: vllm
scrape_interval: 15s
static_configs:
- targets: ["localhost:8000"]Prometheus stores samples over time. A dashboard can then plot waiting requests, latency percentiles, token rates, and errors. A single sample is useful for debugging. A time series reveals trends such as traffic growth or gradual saturation.
Measuring useful rates
Counters increase over time, so their raw values are less useful than their rates. Prometheus queries commonly use rate() over a time window. For example, a token counter can be converted into generated tokens per second:
rate(vllm:request_generation_tokens_total[5m])Use a window long enough to smooth individual requests. Compare token rate with latency and waiting requests. Higher throughput is not automatically better if queue time becomes unacceptable.
Exercise
Waiting requests increase steadily, while GPU memory is almost full. Which measurements should you inspect next?
Show answer
Inspect time to first token, time per output token, prompt and generation token rates, request lengths, and the configured concurrency. These measurements distinguish queueing caused by long prompts or completions from a general capacity limit.