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

Design a 300K-QPS Distributed MCP
Gateway & Enterprise Tool Registry.

Design a multi-tenant MCP Gateway & Tool Registry supporting 100K+ MCP servers, 1M+ tool schemas, and 300K JSON-RPC 2.0 QPS within <=15ms p99 overhead.
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, allocate a strict 15ms p99 budget across Edge Auth (2ms), Qdrant Top-15 (5ms), Cedar/Vault (1ms), Maglev Mux (2ms), and 3-Stage Firewall (3ms), plus async ClickHouse/Iceberg audits.

TL;DR30-second simplified summary
▾

Capacity math at 300K QPS (4.8 GB/s) sizes 162,000 burst slots across 120 Tokio pods, 25,000 Firecracker stdio VMs (3.2 TB RAM across 64 KVM hosts), and 64 GB Redis for 10M SSE sessions.

Qdrant Int8 HNSW + BM25 RRF prunes 1M+ schemas in <=4.8ms, while Cedar ABAC + RFC 8693 Vault handles zero-trust auth in <=1ms.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Distributed MCP Gateway, Semantic Tool Pruning & Zero-Trust Vault
Route 300,000 JSON-RPC 2.0 tool calls/sec across 100,000+ MCP servers without overflowing 128K LLM context windows or exposing raw credentials.
Full walkthrough · 7 stages
01
foundation

Capacity Math & Strict <=15ms p99 Latency Budget.

Why this matters: Derive bandwidth, Tokio mux concurrency, Firecracker fleet RAM, and the 15ms latency budget.

At 300,000 QPS with 4 KB request + 12 KB response payloads, gateway bandwidth reaches 4.8 GB/s (38.4 Gbps sustained).

By Little's Law (W = 0.180s), active in-flight calls equal 54,000 (162,000 with 3x burst) across 120 Rust Tokio pods (1,350 streams/pod).

Stage 1 • Latency & Scale Math

15ms p99 Budget & 162K Burst Stream Sizing

1. Edge AuthN/Z(2ms)ingress2. Qdrant Top-15(5ms)index3. Cedar + Vault(1ms)security4. Maglev + FW(5ms)compute5ms budget

1.4.8 GB/s Bandwidth: 300K QPS x 16 KB round-trip requires 100 Gbps burst NICs.

2.13ms Core + 2ms Jitter: Leaves zero room for synchronous DB audit writes on the hot path.

Strict per-stage millisecond budgets and Little's Law concurrency keep 300K QPS under 15 ms p99.

02
foundation

Strongly-Typed Protobuf Control Plane & JSON-RPC 2.0 Data Plane.

Why this matters: Separate control-plane discovery/registration from high-throughput tool invocation.

Think of Strongly-Typed Protobuf Control Plane & JSON-RPC 2.0 Data Plane as the intuition layer for Design a 300K-QPS Distributed MCP Gateway & Enterprise Tool Registry: Separate control-plane discovery/registration from high-throughput tool invocation.

The MCP Gateway exposes typed Protobuf RPCs (DiscoverTools, InvokeTool, RegisterMCPServer, ExchangeDelegatedToken) internally while terminating external JSON-RPC 2.0 over HTTP/2 SSE and Streamable-HTTP. Separating discovery (100K QPS) from invocation (300K QPS) lets Qdrant replicas scale independently from Firecracker execution pools.

Stage 2 • Control vs Data Plane

JSON-RPC 2.0 Edge -> Protobuf gRPC Mesh

JSON-RPC 2.0 EdgeingressDiscoverTools (100KQPS)computeInvokeTool (300KQPS)computeRegisterMCPServerstorageHandles tools/call

1.Zero-Downtime Alias: Qdrant Collection Aliasing swaps updated schemas instantaneously.

2.Decoupled Scaling: 100K discovery QPS and 300K invocation QPS scale independently.

Decoupling discovery, registration, and invocation RPCs isolates vector scaling from execution pools.

Engineering Decision Framework
Problem
How to implement Design a 300K-QPS Distributed MCP Gateway & Enterprise Tool Registry 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, allocate a strict 15ms p99 budget across Edge Auth (2ms), Qdrant Top-15 (5ms), Cedar/Vault (1ms), Maglev Mux (2ms), and 3-Stage Firewall (3ms), plus async ClickHouse/Iceberg audits.
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 300K-QPS Distributed MCP Gateway & Enterprise Tool Registry experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Qdrant Int8 HNSW vs Milvus vs pgvector for 1M+ Schemas.

Why this matters: Select the vector engine capable of single-pass RBAC pre-filtering in <=4.8 ms.

At 1M tool schemas, pgvector suffers 18-35 ms p99 latency and HNSW recall collapse under SQL WHERE filters.

Milvus introduces Pulsar/MinIO multi-segment merge overhead (6-9 ms).

Stage 3 • Engine Trade-Off

Qdrant Single-Pass Bitset vs Milvus & pgvector

Qdrant (Selected)indexMilvus DistributedcomparepgvectorcompareCollection AliasingoutputRejected: higher p99

1.<=4.8ms p99: Single-pass Rust payload bitsets keep RBAC filtering O(1).

2.53.25 GB Total RAM: Entire 32x3 Qdrant fabric fits in high-speed DRAM.

Qdrant Int8 HNSW meets the <=5 ms discovery SLA via single-pass RBAC bitset filtering.

04
intermediate

Firecracker stdio Pool (25K microVMs) & Session Cursor State.

Why this matters: Size and isolate legacy local stdio MCP servers at 3.2 TB RAM across 64 KVM hosts.

Enterprise deployments still rely on thousands of legacy local stdio MCP tools.

Provisioning 25,000 active Firecracker microVMs at 128 MB reserved RAM requires 3.2 TB RAM across 64 bare-metal KVM hosts, booting from warm snapshots in <125ms and communicating over AF_VSOCK gRPC.

Stage 4 • Sandbox & Session State

25K Firecracker microVMs (3.2 TB) + 64 GB Redis

25K Firecracker VMssandboxAF_VSOCK gRPCpipeline64 GB Redis ClustercacheLast-Event-IDResumeoutputRecovers missed SSE events

1.<125ms Boot: Pre-warmed KVM snapshots absorb sudden tool burst traffic.

2.40 GB Session Set: 10M active SSE cursors fit comfortably in a 64 GB Redis Cluster.

A 64-host Firecracker fleet and 64 GB Redis Cluster isolate stdio execution and 10M SSE sessions.

05
intermediate

RFC 8693 Token Exchange & Cedar ABAC Hardening.

Why this matters: Enforce dual SPIFFE + User JWT attestation on every downstream MCP call.

Think of RFC 8693 Token Exchange & Cedar ABAC Hardening as the intuition layer for Design a 300K-QPS Distributed MCP Gateway & Enterprise Tool Registry: Enforce dual SPIFFE + User JWT attestation on every downstream MCP call.

Even if an LLM is tricked via prompt injection into requesting a sensitive tool, Cedar ABAC intersects User JWT scopes, Agent SPIFFE workload identity, and Tool requirements in <1 ms. The isolated Token Vault then exchanges the dual assertions via RFC 8693 for a 60-second, single-tool credential—preventing lateral movement and credential exfiltration.

Stage 5 • Zero-Trust Vault

Dual Attestation -> Cedar ABAC -> 60s Token

User OAuth 2.1 JWTingressAgent SPIFFE SVIDingressCedar ABAC (<1ms)guardRFC 8693 VaultsecurityPasses actor claims

1.60s Token TTL: Short-lived tokens limit blast radius if a downstream server is compromised.

2.Dual Attestation: Prevents agents from acting without an authorized user context.

Dual User + Agent attestation with Cedar ABAC and 60s RFC 8693 tokens blocks confused-deputy abuse.

06
advanced

3-Stage Prompt-Injection Firewall & Rug-Pull Pinning.

Why this matters: Defend both tool-input schemas and tool-output payloads in <=3 ms.

Upstream MCP servers pose two threats: runtime schema tampering ('rug pulls') and malicious data payloads containing indirect prompt injections.

Schema pinning verifies canonical SHA-256 digests on every tools/list sync (tripping a 30s quarantine on mismatch).

Stage 6 • Bidirectional Defense

Schema Pinning + <=3ms 3-Stage Output Firewall

SHA-256 Schema PinguardJSON Schema + 64KBCapfilterAho-Corasick PIIguardINT8 DeBERTa-v3guardScrubs bounded output

1.Bidirectional Guard: Protects both tool selection (pinning) and tool returns (firewall).

2.<=3ms Budget: Automata + INT8 inference fits inside the 15ms p99 SLA.

SHA-256 schema pinning and a <=3ms 3-stage output firewall harden untrusted MCP boundaries.

07
advanced

High-Throughput OTel Audit Ledger (46.6 TB/Day) & Failover.

Why this matters: Stream 300K OTel spans/sec asynchronously and survive Qdrant/Firecracker faults.

Think of High-Throughput OTel Audit Ledger (46.6 TB/Day) & Failover as the intuition layer for Design a 300K-QPS Distributed MCP Gateway & Enterprise Tool Registry: Stream 300K OTel spans/sec asynchronously and survive Qdrant/Firecracker faults.

To preserve the <=15ms p99 SLA, 300,000 serialized OTel spans/s (~1.8 KB = 540 MB/s, 46.6 TB/day) stream asynchronously into Kafka -> ClickHouse (30-day hot SQL) + S3 Apache Iceberg WORM (7-year archive). During Qdrant shard failovers, read replicas absorb traffic seamlessly; during Firecracker OOMs, Maglev + snapshot pools respawn clean microVMs in <125 ms.

Stage 7 • Audit & Failover

46.6 TB/Day OTel Ledger + <125ms VM Respawn

300K OTel Spans/singressClickHouse (30d Hot)storageIceberg WORM (7yr)archiveFirecracker RespawnrecoveryLong-term WORM retention

1.46.6 TB/Day Scale: Async Kafka -> ClickHouse + Iceberg never blocks the 300K QPS path.

2.<125ms Recovery: Crashed stdio microVMs respawn from clean KVM snapshots.

Async 46.6 TB/day OTel auditing and <125 ms Firecracker recovery harden 300K QPS operations.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why is Qdrant Int8 HNSW selected over pgvector for 1M+ MCP tool schemas under a <=5 ms discovery SLA?

Recommended Learning Flow