0
0
LLDsystem_design~10 mins

Proxy pattern in LLD - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - Proxy pattern
Growth Table: Proxy Pattern Scaling
Users/RequestsWhat Changes?
100 usersSingle proxy instance handles requests; minimal latency added; backend service load manageable.
10,000 usersProxy starts to see higher concurrent connections; CPU and memory usage increase; backend load rises; caching at proxy beneficial.
1,000,000 usersSingle proxy becomes bottleneck; needs horizontal scaling; caching and rate limiting essential; backend services require load balancing.
100,000,000 usersMultiple proxy clusters distributed geographically; global load balancing; advanced caching layers; backend sharding and microservices needed.
First Bottleneck

The proxy server itself is the first bottleneck as user requests grow. It handles all incoming traffic and forwards it to backend services. At high load, CPU, memory, and network bandwidth on the proxy limit throughput.

Scaling Solutions
  • Horizontal Scaling: Add more proxy instances behind a load balancer to distribute traffic evenly.
  • Caching: Implement caching at the proxy to reduce backend calls for repeated requests.
  • Rate Limiting: Protect backend services by limiting request rates at the proxy.
  • Geographical Distribution: Deploy proxy clusters closer to users to reduce latency and balance load.
  • Backend Scaling: Use load balancers and sharding for backend services to handle increased traffic.
Back-of-Envelope Cost Analysis

Assuming each user sends 1 request per second:

  • At 1,000 users: 1,000 RPS; one proxy server can handle ~3,000 RPS comfortably.
  • At 10,000 users: 10,000 RPS; need ~4 proxy servers (10,000/3,000 ≈ 4) for load balancing.
  • At 1,000,000 users: 1,000,000 RPS; requires ~334 proxy servers; caching reduces backend load.
  • Bandwidth: Each request ~10KB; at 1M RPS -> 10GB/s bandwidth needed at proxy layer.
  • Storage: Proxy caching requires memory proportional to cache size; e.g., 100GB RAM cluster for effective caching.
Interview Tip

Start by explaining the proxy role and its load. Discuss bottlenecks clearly, then propose scaling solutions step-by-step: horizontal scaling, caching, rate limiting, and backend scaling. Use numbers to justify your choices and show understanding of trade-offs.

Self Check

Your database handles 1000 QPS. Traffic grows 10x. What do you do first?

Answer: Add read replicas and implement caching to reduce direct database queries before scaling vertically or sharding.

Key Result
The proxy server becomes the first bottleneck as user requests grow; horizontal scaling and caching at the proxy layer are key to maintaining performance.