Schedule icon
Webhook icon
Request icon
Script icon
If icon
SlackIncomingWebhook icon
Log icon

vLLM GPU KV Cache Exhaustion and Preemption Thrashing Sentinel

Audit vLLM GPU KV-cache usage factor, waiting request queues, and preemptions to alert Slack and trigger autoscaling before latency spikes.

Categories
AIInfrastructure

High-throughput LLM serving engines such as vLLM rely on PagedAttention to allocate Key-Value (KV) cache memory in GPU VRAM blocks. Under surging concurrency or long context windows, the GPU KV-cache reaches saturation (vllm:gpu_cache_usage_factor approaching 1.0). When this occurs, vLLM is forced to swap memory blocks or preempt generating requests, destroying inference throughput and causing Time-To-First-Token (TTFT) and latency spikes.

This blueprint acts as an automated reliability sentinel for production vLLM deployments. It scrapes vLLM's native Prometheus telemetry, tracks GPU KV-cache utilization, detects request queue buildup (num_requests_waiting), identifies active preemption thrashing (num_preemptions_total), and alerts MLOps teams on Slack with actionable scaling guidance.

How it works

  1. check_vllm_health validates that the vLLM server is alive and responding to HTTP health checks.
  2. fetch_vllm_metrics scrapes raw Prometheus metrics from the /metrics endpoint.
  3. audit_vllm_telemetry parses the metrics stream, calculates KV-cache utilization percentages, checks queue backlogs, and evaluates preemption counters against configurable SLA thresholds.
  4. evaluate_health_breaches uses an If flowable task to determine if cache saturation or queue backlog thresholds are exceeded.
  5. If saturated, alert_vllm_saturation_slack posts an urgent incident card to Slack detailing the exact metrics and remediation recommendations.
  6. If healthy, log_vllm_healthy logs the current cluster utilization metrics.
  7. The errors block alerts Slack if the vLLM service becomes unreachable or returns an error.
  8. Triggers include a periodic scheduled check and an authenticated webhook trigger suitable for Kubernetes HPA integration or Prometheus Alertmanager webhooks.

Prerequisites

  • A running vLLM instance exposing /health and /metrics (standard vLLM configuration).
  • A Slack Incoming Webhook URL.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for alerting.

Quick start

  1. Configure SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Update vllm_metrics_url with your vLLM server's address (e.g. http://vllm-service.mlops.svc.cluster.local:8000/metrics).
  3. Adjust kv_cache_threshold_percent (default: 85%) and max_waiting_requests_threshold (default: 5) to match your workload's headroom requirements.
  4. Enable the schedule or trigger the flow via webhook from your monitoring stack.

How to extend

  • Add an automated webhook task that scales your Kubernetes Deployment replica count (kubectl scale or Kubernetes API) when saturation is detected.
  • Export audit metrics to Datadog or BigQuery for long-term GPU capacity planning.
  • Pair with downstream latency benchmarks to correlate KV-cache usage with token-generation speeds.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.