When hosting open-source models locally using vLLM, memory management is highly sensitive. The vLLM engine pre-allocates substantial GPU VRAM for its KV Cache, leaving little room for system spikes. If a client connects and requests a massive stream of tokens, the engine can crash. You can fix vllm out of memory api proxy issues by using a lightweight pass-through proxy.
For complete cost-saving architectures, read The Complete Architecture of Cost-Efficient LLM Pipelines.
The vLLM Crash Mechanism
When a client closes their connection early (e.g. they close the browser tab), vLLM might keep generating tokens until the context length is full. This wastes GPU resources and causes memory buildup:
$$\text{Wasted GPU Memory} \propto \text{Abandoned Requests} \times \text{Remaining Context Length}$$
To prevent this, you need a proxy that detects client disconnects and instantly drops the upstream socket. To learn how to configure this on Docker setups, read prevent llm oom crash docker.
---
Zero-Copy Connection Abortion
Our Rust proxy implements downstream socket checking. The moment a client drops, the proxy drops the upstream vLLM connection, stopping generation immediately and reclaiming GPU memory.
// Axum proxy endpoint handles client cancellations
tokio::select! {
res = upstream_request => {
// Forward chunks
}
_ = client_disconnect => {
// Client disconnected. Drop upstream connection immediately!
}
}---
Deploy the vLLM Safeguard Proxy
Run the gateway proxy in front of your vLLM engine:
docker run -d \
--name kilovolt-vllm-shield \
-p 8080:8080 \
-e KILOVOLT_PORT=8080 \
-e KILOVOLT_DEFAULT_BUDGET=10.00 \
yodsarun/kilovolt-proxy:latestConfigure your client to target http://localhost:8080 instead of the raw vLLM endpoint.