Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a 50K RPS Distributed LLM
Eval, Guardrails & Red Teaming Platform.

Architect a 50,000 RPS LLM safety and evaluation platform with <25ms p99 inline guardrail sidecars, Kafka shadow-eval streams, a Ray/vLLM Judge Worker fleet scoring 1M+ daily traces, ClickHouse analytics, and automated CI/CD regression gates.
Start the journey7 stages· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When batching and tail latency compete for accelerator cycles, Guardrails & Red, split traffic at the API Gateway into a colocation-optimized <25ms inline guardrail sidecar and an asynchronous Kafka-to-Ray/vLLM judge pipeline backed by ClickHouse.

TL;DR30-second simplified summary
▾

The API Gateway enforces <25ms p99 safety via pod-local Envoy ext_proc + Rust Aho-Corasick + Triton INT8 DeBERTa sidecars, while non-blocking buffers mirror PII-scrubbed traces into priority Kafka topics.

Spot-GPU Ray/vLLM workers use Automatic Prefix Caching and guided JSON decoding to score 1M+ daily traces into ClickHouse MergeTree tables. Materialized 5-minute views power Argo Rollouts canary aborts alongside tiered pre-merge CI suites.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
LLM Guardrails, Red Teaming & Evaluation
Production LLM safety and quality combine sub-25ms inline guardrail meshes (PII, prompt-injection, topic routing) with streaming output verifiers and asynchronous LLM-as-a-Judge + automated red-teaming loops.
Full walkthrough · 7 stages
01
foundation

Traffic Sizing, SLA Budgets & Dual-Path Gateway Split.

Why this matters: Size the 50K RPS inline fleet and 1M+ daily trace async judge fleet with clear latency/throughput targets.

At 50,000 RPS (~2 KB avg prompt+response = ~100 MB/s), the synchronous guardrail sidecar has a strict <25ms p99 budget (<=3ms gateway+network, <=12ms parallel input mesh, <=10ms streaming output window).

Using INT8 TensorRT-optimized DeBERTa-base (~1,200 req/s per L4/T4 GPU at batch=8, <=8ms p99), 50K RPS requires ~45–60 L4 GPUs with 30% headroom.

STAGE 1 · SIZING

50K RPS Inline Sizing & Async Shadow-Eval Split

API Gateway (50KRPS)traffic-splitterInline GuardrailFleetsync-enforcerKafka Shadow Streamasync-busRay/vLLM JudgeFleeteval-clusterMirrors sampled traces

1.Right-Sized Silicon: Small INT8 classifiers run efficiently on cheap L4 GPUs; reserve H100s for 70B+ async judges.

2.Zero Backpressure: Gateway Kafka mirroring must be non-blocking with a bounded ring buffer—drop mirror before dropping user traffic.

Splitting 50K RPS into L4-backed <25ms inline sidecars and Kafka-buffered async judges keeps both cost and tail latency bounded.

02
foundation

Low-Latency Inline Guardrail Sidecar Architecture.

Why this matters: Colocate Rust/Envoy proxy logic with Triton INT8 inference to stay under 25ms p99 at 50K RPS.

Cross-AZ network hops between an API Gateway and a remote guardrail microservice add 2–5ms per round trip—and twice that on streaming output checks.

Deploying the guardrail engine as a pod-local sidecar (or DaemonSet) using Unix Domain Sockets / shared memory between Envoy WASM/ext_proc and a Triton Inference Server (ONNX/TensorRT INT8) eliminates network serialization overhead.

STAGE 2 · INLINE SIDECAR

Pod-Local Envoy ext_proc + Triton INT8 Guardrail Sidecar

Envoy ext_procProxyproxy-hookRust Aho-CorasickEnginedeterministic-filterTriton INT8 Serverclassifier-runtimeCircuit Breakerresilience-gateBatches classifier call

1.2ms Batch Window: Capping Triton queue delay at 2ms boosts GPU throughput 4x while keeping p99 under 12ms.

2.Tenant Policy Config: Compile per-tenant rule thresholds in an atomic in-memory map pushed via xDS/etcd.

Colocating Envoy ext_proc with Rust Aho-Corasick and Triton INT8 dynamic batching meets the 25ms p99 budget at 50K RPS.

Engineering Decision Framework
Problem
How to implement Design a 50K RPS Distributed LLM Eval, Guardrails & Red Teaming Platform without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When batching and tail latency compete for accelerator cycles, guardrails & Red, split traffic at the API Gateway into a colocation-optimized <25ms inline guardrail sidecar and an asynchronous Kafka-to-Ray/vLLM judge pipeline backed by ClickHouse.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a 50K RPS Distributed LLM Eval, Guardrails & Red Teaming Platform experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Kafka Shadow-Eval Pipeline, PII Scrubbing & Priority Queues.

Why this matters: Ingest 1M+ daily production traces reliably with tenant isolation, PII scrubbing, and priority tiers.

Shadow-eval streams cannot store raw customer SSNs or secrets in long-lived evaluation lakes.

Before writing to Kafka (eval.traces.v1), the gateway's async mirror applies irreversible token-preserving PII redaction (<EMAIL_1>, <CARD_1>). Topics are partitioned by tenant_id hash with separate priority topics: eval.high_priority (blocked requests, user thumbs-down, canary deployments) and eval.sample (2% random baseline).

STAGE 3 · INGESTION

PII-Scrubbed Kafka Shadow-Eval & Priority Partitioning

Edge PII Scrubberprivacy-filtereval.high_prioritypriority-topiceval.sample (2%)baseline-topicDead-Letter &Schema Regdlq-guardRoutes baseline sample

1.Consistent Tagging: Token-preserving placeholders (<PERSON_1>) let judges still score grammar and faithfulness.

2.Canary Boost: Automatically bump sampling from 2% to 25% for newly deployed model/prompt versions.

Irreversible edge PII scrubbing and dual-priority Kafka topics protect customer privacy while guaranteeing fast feedback on incidents and canaries.

04
intermediate

Distributed Ray / vLLM Judge Worker Fleet.

Why this matters: Maximize tokens/sec on 1M+ daily evals using Ray Data micro-batching, vLLM prefix caching, and structured outputs.

Evaluating 1M traces/day across 3 rubric dimensions (faithfulness, toxicity, jailbreak resistance) requires ~3M judge calls/day (~35–100 calls/sec sustained, 3x peak).

Ray actors pull 256-trace micro-batches from Kafka and dispatch them to vLLM workers configured with Automatic Prefix Caching (APC) so the 800-token judge rubric is cached once across all 256 requests.

STAGE 4 · JUDGE FLEET

Ray + vLLM Continuous-Batched Judge Workers

Ray Consumer Actorsbatch-orchestratorvLLM Judge Replicasjudge-engineGuided JSON Decoderschema-enforcerSpot / PreemptiblePoolcompute-tierEnforces {score, reason}

1.Spot GPU Savings: Because async judges tolerate 10-30s restarts, running on spot GPUs cuts eval cost by ~60%.

2.Length Bucketing: Sorting micro-batches by prompt length minimizes padding waste in continuous batching.

Ray Data micro-batching paired with vLLM prefix caching and FSM-guided JSON decoding maximizes judge throughput on spot GPUs.

05
intermediate

ClickHouse Analytical Store & Real-Time Drift Alerting.

Why this matters: Store millions of daily eval scores and audit logs for sub-second slicing by model, prompt version, and tenant.

Transactional Postgres tables choke on analytical aggregations over 30M+ monthly eval rows (GROUP BY prompt_version, model_id, violation_type).

ClickHouse (MergeTree partitioned by toYYYYMM(ts), ordered by (tenant_id, model_version, ts)) ingests judge verdicts via Kafka Connect / Vector at >100K rows/sec with ZSTD compression.

STAGE 5 · ANALYTICS

ClickHouse MergeTree Metrics & Rolling-Window Drift Alerts

ClickHouse KafkaSinkingest-sinkPartitionedMergeTreeolap-table5-Min MaterializedViewsrollup-engineDrift & RegressionAlerteralert-routerUpdates 5-min rollups

1.Immutable Audit Trail: Retain hashed prompt/verdict metadata in S3/Iceberg for 1-7 years for compliance audits.

2.Dimension Cardinality: Keep high-cardinality trace_id out of the primary sort prefix to preserve scan speed.

ClickHouse MergeTree tables and 5-minute materialized views power sub-second slice-and-dice analytics and rapid canary rollback.

06
advanced

Distributed Red-Teaming Sandbox & Scheduled Attack Campaigns.

Why this matters: Execute multi-turn adversarial campaigns in isolated sandboxes without risking production data or rate limits.

Running 50,000 adversarial red-team probes against production endpoints pollutes customer analytics and risks triggering real MCP tool side effects.

Instead, a dedicated Ray Red-Team Orchestrator spins up ephemeral, network-isolated target sandboxes with mocked tool backends (e.g., fake SQL/email/CRM stubs that record attempted exfiltration).

STAGE 6 · RED-TEAM SANDBOX

Isolated Ephemeral Red-Team Sandboxes & Tool Mocks

Ray Red-TeamSchedulercampaign-runnerPAIR / CrescendoAttackersadversary-poolSandboxed Agent +Mocksisolated-sutVulnerabilityRegistryfinding-sinkProbes mocked tools

1.Canary Trap Tokens: Seed mocked tool responses with canary strings to detect indirect prompt-injection exfiltration.

2.Budget Caps: Enforce per-campaign token budgets so multi-turn attacker loops cannot runaway-spend.

Sandboxed red-team campaigns probe mocked agent tools with canary tokens to catch exfiltration and multi-turn jailbreaks safely.

07
advanced

Automated CI/CD Deployment Gates & Progressive Rollback.

Why this matters: Wire ClickHouse eval baselines and Ray test suites into GitOps deployment pipelines.

Think of Automated CI/CD Deployment Gates & Progressive Rollback as the intuition layer for Design a 50K RPS Distributed LLM Eval, Guardrails & Red Teaming Platform: Wire ClickHouse eval baselines and Ray test suites into GitOps deployment pipelines.

When an engineer opens a PR updating a system prompt, guardrail threshold, or model weights, GitHub Actions / ArgoCD triggers a tiered eval job: Tier 1 (200 critical smoke + top-50 red-team probes, <2 min) blocks PR merge; Tier 2 (3,000 stratified cases with paired bootstrap 95% CIs) gates staging-to-production promotion. Once promoted to 5% canary traffic, Argo Rollouts polls ClickHouse's 5-minute materialized views and automatically aborts and rolls back if inline block rate jumps >2% or async faithfulness drops >1.5%.

STAGE 7 · GITOPS GATES

Tiered CI/CD Eval Gates & Automated Canary Rollback

Tier-1 / Tier-2 CIEvalpremerge-gateArgo Rollouts (5%Canary)cd-controllerClickHouse MetricProbehealth-probeAuto-RollbackHandlerrollback-actionQueries live canary delta

1.Two-Speed Safety: Fast 2-minute smoke evals keep developer velocity high; deep 3K-case suites protect prod.

2.Immutable Versioning: Tag every trace with (model_sha, prompt_sha, guardrail_sha) for exact root-cause bisection.

Tiered pre-merge evals paired with Argo Rollouts polling ClickHouse materialized views provide end-to-end automated regression protection.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

At 50,000 RPS, why should the API Gateway mirror shadow-eval traces to Kafka using a non-blocking bounded ring buffer rather than a synchronous Kafka producer?

Recommended Learning Flow