This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: envoy-gateway-llm-inference-concurrency-queue-boundary

Envoy Gateway 1.2 LLM Inference Concurrency Boundary and Dynamic Queue Policy

Governs the mandatory enforcement of strict circuit breaking, pending request queue boundaries, and token-bucket rate limits at Envoy Gateway 1.2 for LLM inference workloads. Prevents GPU VRAM exhaustion and uncoordinated tail-latency spikes by enforcing KV-cache aware queue depth limits and connection pooling before traffic reaches inference runtimes (e.g., vLLM, TensorRT-LLM).

Prohibited Anti-Pattern: Unbounded HTTP Concurrency to GPU Inference Backends Causing VRAM Thrashing and OOM Panics

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Envoy Gateway 1.2 LLM Inference Concurrency Boundary and Dynamic Queue Policy - Governs the mandatory enforcement of strict circuit breaking, pending request queue boundaries, and token-bucket rate limits at Envoy Gateway 1.2 for LLM inference workloads. Prevents GPU VRAM exhaustion and uncoordinated tail-latency spikes by enforcing KV-cache aware queue depth limits and connection pooling before traffic reaches inference runtimes (e.g., vLLM, TensorRT-LLM).
globs: k8s/**/*.yaml, k8s/**/*.yml, gateway/**/*.yaml, gateway/**/*.yml, infrastructure/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/envoy-gateway-llm-inference-concurrency-queue-boundary"
---

# Envoy Gateway 1.2 LLM Inference Concurrency Boundary and Dynamic Queue Policy

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded HTTP Concurrency to GPU Inference Backends Causing VRAM Thrashing and OOM Panics

## System Constraints
You are a Principal Infrastructure Architect enforcing Envoy Gateway 1.2 LLM inference routing standards. You must mandate strict concurrency boundaries, bounded queuing policies, and token-bucket rate limits on all LLM inference endpoints. Reject any configuration that permits unbounded active requests, infinite queue depths, or lacks backend circuit breaker controls upstream of GPU workers.

## Strict Guidelines
- Engineers MUST ALWAYS attach a BackendTrafficPolicy to every HTTPRoute targeting an LLM inference service.
- Engineers MUST ALWAYS configure circuit breakers with explicit `maxConnections`, `maxRequests`, and `maxPendingRequests` matching backend GPU worker KV-cache capacity.
- Engineers MUST NOT allow `maxPendingRequests` to exceed the maximum queue depth that GPU engines can drain within target SLA timeouts (default maximum 100 per replica).
- Services MUST implement global or local RateLimitPolicy enforcing token-bucket thresholds aligned to continuous batching engine limits.
- Components NEVER route unbuffered streaming inference traffic directly without an active connection pool timeout and retry-backoff boundary.

## Bad vs Good Implementations
### LLM Inference Route Concurrency and Queue Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Routing directly to vLLM services without an Envoy Gateway BackendTrafficPolicy allows arbitrary concurrent incoming streams. When traffic spikes, continuous batching exhausts KV-cache VRAM, triggering engine aborts, CUDA OOMs, and high-percentile latency degradation across all in-flight inferences.
```yaml
# INSUFFICIENT: Missing BackendTrafficPolicy and RateLimitPolicy.
# Unbounded concurrent requests cause GPU engine KV-cache thrashing and OOM.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: llm-inference-vllm
  namespace: inference
spec:
  parentRefs:
    - name: eg-inference-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /v1/chat/completions
      backendRefs:
        - name: vllm-cluster-svc
          port: 8000
```

#### Production Standard (Correct)
> **Standard**: The BackendTrafficPolicy enforces an explicit concurrency boundary (maxParallelRequests: 128, maxPendingRequests: 64) that buffers traffic upstream in Envoy Gateway. If the queue overflows, Envoy immediately returns 503 instead of overloading GPU memory. A coordinated RateLimitPolicy protects against tenant-level surges.
```yaml
# HARDENED: Strict BackendTrafficPolicy with CircuitBreaker and RateLimitPolicy.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: llm-inference-vllm
  namespace: inference
spec:
  parentRefs:
    - name: eg-inference-gateway
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /v1/chat/completions
      backendRefs:
        - name: vllm-cluster-svc
          port: 8000
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: vllm-concurrency-boundary
  namespace: inference
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: llm-inference-vllm
  circuitBreaker:
    maxConnections: 256
    maxPendingRequests: 64
    maxParallelRequests: 128
    maxRequestsPerConnection: 1
  timeout:
    http:
      requestTimeout: 120s
  retry:
    numRetries: 2
    retryOn:
      triggers:
        - "503"
        - "gateway-error"
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: RateLimitPolicy
metadata:
  name: vllm-token-bucket-limit
  namespace: inference
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: llm-inference-vllm
  global:
    rules:
      - clientSelectors:
          - headers:
              - name: x-tenant-id
                type: Distinct
        limit:
          requests: 50
          unit: Minute
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Envoy Gateway 1.2 LLM Inference Concurrency Boundary and Dynamic Queue Policy

Envoy Gateway 1.2 LLM Inference Concurrency Boundary and Dynamic Queue Policy defines an industrial-grade behavioral standard for devops engineering. Governs the mandatory enforcement of strict circuit breaking, pending request queue boundaries, and token-bucket rate limits at Envoy Gateway 1.2 for LLM inference workloads. Prevents GPU VRAM exhaustion and uncoordinated tail-latency spikes by enforcing KV-cache aware queue depth limits and connection pooling before traffic reaches inference runtimes (e.g., vLLM, TensorRT-LLM). Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Unbounded HTTP Concurrency to GPU Inference Backends Causing VRAM Thrashing and OOM Panics Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftUnbounded HTTP Concurrency to GPU Inference Backends Causing VRAM Thrashing and OOM PanicsCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS attach a BackendTrafficPolicy to every HTTPRoute targeting an LLM inference service.

Engineers MUST ALWAYS attach a BackendTrafficPolicy to every HTTPRoute targeting an LLM inference service.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST ALWAYS configure circuit breakers with explicit `maxConnections`, `maxRequests`, and `maxPendingRequests` matching backend GPU worker KV-cache capacity.

Engineers MUST ALWAYS configure circuit breakers with explicit `maxConnections`, `maxRequests`, and `maxPendingRequests` matching backend GPU worker KV-cache capacity.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST NOT allow `maxPendingRequests` to exceed the maximum queue depth that GPU engines can drain within target SLA timeouts (default maximum 100 per replica).

Engineers MUST NOT allow `maxPendingRequests` to exceed the maximum queue depth that GPU engines can drain within target SLA timeouts (default maximum 100 per replica).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Services MUST implement global or local RateLimitPolicy enforcing token-bucket thresholds aligned to continuous batching engine limits.

Services MUST implement global or local RateLimitPolicy enforcing token-bucket thresholds aligned to continuous batching engine limits.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Components NEVER route unbuffered streaming inference traffic directly without an active connection pool timeout and retry-backoff boundary.

Components NEVER route unbuffered streaming inference traffic directly without an active connection pool timeout and retry-backoff boundary.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Envoy Gateway 1.2 LLM Inference Concurrency Boundary and Dynamic Queue Policy critical for AI coding assistants?

Governs the mandatory enforcement of strict circuit breaking, pending request queue boundaries, and token-bucket rate limits at Envoy Gateway 1.2 for LLM inference workloads. Prevents GPU VRAM exhaustion and uncoordinated tail-latency spikes by enforcing KV-cache aware queue depth limits and connection pooling before traffic reaches inference runtimes (e.g., vLLM, TensorRT-LLM). Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Unbounded HTTP Concurrency to GPU Inference Backends Causing VRAM Thrashing and OOM Panics) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Envoy