Skip to content

Technology Choices & Exhaustive Trade-Off Comparisons ​

1. Proxy Core Language & Runtime ​

Chosen: TypeScript & Node.js Native HTTP Streams ​

  • File References: src/proxy/index.ts, src/proxy/stream.ts
  • Role in Project: Implements asynchronous reverse proxy listener, stream piping, and RFC 9111 rules.

Exhaustive Alternatives Comparison ​

Evaluation MetricTypeScript / Node.js Streams (Chosen)Rust (Actix-Web / Hyper)Go (net/http)C++ (Nginx / Envoy)
I/O ModelNon-blocking Libuv event loopAsync Tokio epoll event loopGoroutine-per-connectionEvent-driven epoll threads
Memory ModelV8 GC with Buffer segmentationZero-cost manual ownershipGC with small stack framesManual malloc/free
Development SpeedExtremely rapid, rich ecosystemSteep learning curve, strict borrow checkerHigh speed, built-in concurrencySlow development, segfault risk
Zero-Copy PipingNative stream.pipelinePointer slicing without copyio.Copy with buffer poolKernel splice() syscalls
Ecosystem FitShares models with Next.js frontendRequires FFI or separate binarySeparate binary and toolchainSeparate C/C++ build system
  • Why I Used This: Allows rapid iteration on complex RFC 9111 logic with native Buffer streaming, unified TypeScript types across frontend and proxy, and high I/O throughput [CONFIRM WITH DEVELOPER].
  • Why Alternatives Were Rejected:
    • Rust: High implementation complexity for an academic/interview project deadline; Rust stubs maintained in backend/ for native acceleration.
    • Go: Lack of native TypeScript type sharing with Next.js dashboard.
    • Nginx / Envoy: Rigid configuration languages that make custom request coalescing and dynamic surrogate-tag purging difficult to implement without custom Lua or C++ modules.
  • 30-Second Spoken Interview Answer:

"I chose Node.js with TypeScript because its non-blocking stream pipeline allows zero-copy piping between client and origin sockets without buffering entire objects into the V8 heap. By relying on native Buffers, we achieve sub-millisecond edge latency while sharing end-to-end type definitions across our proxy engine and Next.js admin dashboard."


2. In-Memory Cache Storage Architecture ​

Chosen: Memory-Segmented Buffer Store with Doubly-Linked LRU ​

  • File References: src/cache/memory-store.ts, src/cache/eviction/lru.ts
  • Role in Project: Sub-millisecond L1 cache holding unexpired representations.

Exhaustive Alternatives Comparison ​

Evaluation MetricIn-Memory Segments (Chosen)Redis 7.2MemcachedRocksDB (Embedded)
Lookup Latency< 0.05 ms (In-process memory)0.5 - 1.5 ms (Network hop)0.4 - 1.2 ms (Network hop)0.2 - 0.8 ms (Disk index)
Serialization OverheadZero (Raw Buffers stored)Serialization to RESP protocolBinary protocol serializationKey/value byte serialization
Stream CapabilityDirect stream slicingRequires Redis Streams or chunksValue size capped at 1 MBBlock reads required
Operational OverheadNone (Embedded in proxy)Requires Redis cluster & sentinelRequires Memcached daemonRequires C++ native binding
  • Why I Used This: An edge proxy requires sub-millisecond response times. Adding a network hop to Redis introduces 1 ms of latency per request, negating the benefit of an edge cache [CONFIRM WITH DEVELOPER].
  • When I Would Switch: When deploying across a cluster of 50+ stateless proxy instances that require a shared central cache tier to maximize hit ratios.

3. Request Coalescing (Thundering Herd) Strategy ​

Chosen: In-Flight Flight Map with Leader-Follower Stream Fanout ​

  • File References: src/proxy/coalesce.ts, src/proxy/collapsed-forwarding.ts
  • Role in Project: Collapses concurrent cache misses into a single upstream request.

Alternatives Comparison ​

StrategyIn-Flight Map (Chosen)Redis Distributed LockUpstream Queue (RabbitMQ)
Coordination LatencyZero (In-memory lookup)2 - 5 ms (Redlock consensus)5 - 15 ms (Message round-trip)
Stream FanoutInstant stream tee to all socketsPolling loop requiredConsumer polling required
Failure RecoveryLeader failure promotes followerLock timeout requiredDead-letter retry required

4. Frontend Administration Dashboard ​

Chosen: Next.js 14 App Router + TailwindCSS + Recharts ​

  • File References: frontend/app/dashboard/page.tsx
  • Role in Project: Provides a real-time operational dashboard visualizing hit ratios and latencies.

Alternatives Comparison ​

AlternativeTrade-off vs Next.js 14
GrafanaPre-built metrics visualization, but lacks interactive controls for custom purge triggers and route edits.
Plain React Vite SPALacks server-side rendering and unified Next.js API route orchestration.
Embedded HTML OnlyMaintained as lightweight fallback in src/admin/dashboard-html.ts, but lacks interactive charting capabilities.