To keep serving pipelines predictable under bursty prompts, use Anycast Edge POPs for SSE termination, sharded Postgres + Redis for branching conversation trees, consistent-hash KV-prefix routing, and disaggregated Prefill/Decode GPU pools.
TL;DR30-second simplified summary▾
Serving 35K peak QPS with 350K concurrent SSE streams requires separating edge termination, context hydration, GPU inference, and observability. Envoy Edge POPs proxy to Go/Rust SSE gateways with 15s keepalives and Last-Event-ID Redis Stream replay.
Sharded PostgreSQL + Redis store branching message trees, while bounded-load consistent hashing routes turns to warm RadixAttention GPU replicas. Metering and moderation logs flow asynchronously via Kafka to ClickHouse and S3.
Capacity Estimation & SLO Targets.
Why this matters: Quantify QPS, concurrent SSE connections, GPU HBM capacity, and network egress for 100M DAU.
Assume 100M DAU averaging 10 turns/day = 1B turns/day (~11,500 avg QPS, ~35,000 peak QPS).
With an average response of 400 tokens at 40 tok/s (10s stream duration), peak concurrent open SSE streams reach 350,000.
100M DAU Capacity Model
1.Peak Multiplier: Use 3x peak-to-average ratio for global diurnal traffic waves.
2.Egress Bandwidth: 350K streams * 40 tok/s * 50B SSE frame = ~700 MB/s (5.6 Gbps) edge egress.
Capacity math drives 350K concurrent SSE sockets and 140TB of GPU KV-cache memory.
Edge Ingress, Anycast POPs & SSE Connection Management.
Why this matters: Terminate TLS close to users and maintain 350K+ long-lived SSE streams without exhausting gateway memory.
Geo-DNS routes users to the nearest Anycast Edge POP running Envoy.
Envoy terminates HTTP/3/TLS and proxies /v1/chat/completions over persistent gRPC streams to regional Go/Rust SSE Gateways.
Anycast POP to SSE Gateway Bridge
1.SSE vs WebSocket: SSE works natively over HTTP/2 multiplexing without custom upgrade handshakes.
2.Resumable Streams: Buffer last 60s of tokens in Redis Streams so mobile reconnects resume cleanly.
Edge POPs decouple global TLS termination from regional streaming gateways.
- Problem
- How to implement Design a Conversational AI Serving Platform (ChatGPT Scale) 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
- To keep serving pipelines predictable under bursty prompts, use Anycast Edge POPs for SSE termination, sharded Postgres + Redis for branching conversation trees, consistent-hash KV-prefix routing, and disaggregated Prefill/Decode GPU pools.
- Trade-Offs
- Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
When Design a Conversational AI Serving Platform (ChatGPT Scale) experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?
Branching Conversation Store & Async Context Hydration.
Why this matters: Model editable/regenerable chat trees and hydrate context windows under 20ms p99.
Users frequently edit prompts or regenerate replies, forming a tree rather than a flat list.
PostgreSQL (sharded by user_id) stores conversations and messages(id, parent_id, role, token_count, content_ref) with large attachments in S3. Active conversations are cached in Redis Cluster (hash of recent turns + precomputed rolling summary).
Sharded Postgres + Redis Turn Hydrator
1.Tree Schema: Adjacency list with parent_id enables O(depth) branch traversal and instant edits.
2.Async Compaction: Summarize older turns asynchronously after response completion, never on the hot path.
Sharded PostgreSQL and Redis keep context hydration under 20ms even for branching chats.
KV-Prefix Affine Routing & Bounded-Load Consistent Hashing.
Why this matters: Maximize RadixAttention prefix cache hits while preventing hot GPUs during viral workloads.
The Inference Router hashes conversation_id onto a consistent-hash ring of Decode/Prefill pods (e.g., Maglev or Ketama with virtual nodes).
To prevent a single power user or retry storm from overloading one GPU, each node has a bounded-load ceiling (1.25x cluster average active tokens).
Bounded-Load Consistent Hash Ring
1.Hit Rate Impact: Sticky routing achieves >85% KV-prefix cache hit rate on multi-turn sessions.
2.Graceful Spillover: Spilling at 1.25x load trades a one-time prefill for cluster-wide tail-latency stability.
Bounded-load consistent hashing balances KV-cache locality against GPU saturation.
Disaggregated Prefill/Decode & Speculative Decoding.
Why this matters: Hit <300ms TTFT and <30ms ITL simultaneously using disaggregated pools and draft verification.
Think of Disaggregated Prefill/Decode & Speculative Decoding as the intuition layer for Design a Conversational AI Serving Platform (ChatGPT Scale): Hit <300ms TTFT and <30ms ITL simultaneously using disaggregated pools and draft verification.
Prefill workers process input prompts in chunked passes and push KV-cache blocks over InfiniBand/RoCEv2 RDMA to Decode workers. To accelerate Decode ITL beyond memory-bandwidth limits, small draft models (or Medusa/EAGLE heads) propose 4-5 candidate tokens verified in a single parallel target-model forward pass, boosting effective decode speed by 2x-2.5x without changing output distribution.
Disaggregated Prefill + Speculative Decode
1.Speculative Speedup: Lossless speculative verification doubles tok/s on memory-bound decode batches.
2.NVMe Offload: Offloading evicted KV prefixes to local NVMe extends prefix retention to hours.
Disaggregation plus speculative decoding hits both TTFT and ITL SLOs at high batch sizes.
Multi-Region Failover, Model Tier Fallback & Load Shedding.
Why this matters: Maintain availability during regional GPU outages or sudden viral traffic surges.
Think of Multi-Region Failover, Model Tier Fallback & Load Shedding as the intuition layer for Design a Conversational AI Serving Platform (ChatGPT Scale): Maintain availability during regional GPU outages or sudden viral traffic surges.
Each region runs active-active stateless gateways and replicated Redis/Postgres metadata. If a region's GPU pool hits >90% HBM saturation, the router performs priority-based load shedding: paid/interactive requests stay on primary frontier models, free-tier or background tasks degrade gracefully to a distilled fast model, and excess traffic overflows cross-region via Geo-DNS weighted shifting.
Priority Load Shedder & Cross-Region Failover
1.Zero Retry Storms: Return 429 with Retry-After jitter rather than letting clients hammer saturated GPUs.
2.Circuit Breakers: Trip cross-region failover if regional TTFT p99 exceeds 1.5s for 30s.
Priority load shedding and model-tier fallback keep interactive chat responsive under overload.
Async Telemetry, Token Billing & Moderation Audit Pipeline.
Why this matters: Track exact token usage, latency percentiles, and compliance logs off the critical path.
Think of Async Telemetry, Token Billing & Moderation Audit Pipeline as the intuition layer for Design a Conversational AI Serving Platform (ChatGPT Scale): Track exact token usage, latency percentiles, and compliance logs off the critical path.
Once a stream finishes or aborts, the SSE Gateway emits a single CompletionAuditEvent (user_id, prompt_tokens, cached_tokens, completion_tokens, TTFT, ITL, safety_flags) to Kafka with idempotent producer keys. Flink aggregates real-time FinOps cost and quota counters into Redis/ClickHouse, while encrypted audit transcripts land in S3 Parquet for compliance.
Kafka-Flink Metering & Audit Pipeline
1.Zero Hot-Path Cost: Metering and S3 persistence never add latency to the user's SSE stream.
2.Cached Token Billing: Track cached_prefix_tokens separately to pass KV-cache savings to tenants.
Asynchronous Kafka pipelines decouple billing, FinOps, and compliance from token streaming.
Practice: Make the trade-off yourself.
Why is consistent hashing with bounded load preferred over pure round-robin when routing multi-turn ChatGPT requests to GPU replicas?