Appearance
Architecture & End-to-End System Design
1. High-Level Architecture Overview
2. Request Lifecycle Traces
2.1 Cache Hit Lifecycle (< 1 ms)
- Client sends
GET /static/app.jswithAccept-Encoding: br. src/proxy/index.tsvalidates Host header and IP allowlist.src/cache/key.tscomputes canonical SHA-256 hash:sha256(https://example.com/static/app.js + vary:br).src/cache/lookup.tsfinds matchingCacheEntryinMemoryStore.src/cache/freshness.tsverifies:current_age < max_age.src/cache/serve.tssetsX-Cache: HIT,Age: 42, and pipes buffer directly to downstream client socket.
2.2 Cache Miss with Single-Flight Coalescing
3. Scaling to 100x Traffic & Bottleneck Elimination
At 100x traffic (50,000+ requests per second):
- Bottleneck 1: Node.js Single-Threaded Event Loop:
- Fix: Scale proxy horizontally across multi-core servers using Linux
SO_REUSEPORTkernel socket load balancing or deploy multi-process worker clusters.
- Fix: Scale proxy horizontally across multi-core servers using Linux
- Bottleneck 2: In-Memory Heap GC Pressure:
- Fix: Migrate from V8 heap Buffer allocation to native C++ off-heap slab allocators or Rust/Hyper proxy engine (
backend/).
- Fix: Migrate from V8 heap Buffer allocation to native C++ off-heap slab allocators or Rust/Hyper proxy engine (
- Bottleneck 3: Centralized Purge Broadcast:
- Fix: Replace in-process purge events with a distributed Redis Pub/Sub or Kafka invalidation bus.