0
0
LLDsystem_design~10 mins

Facade pattern in LLD - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - Facade pattern
Growth Table: Facade Pattern
Users / ScaleSystem ComplexitySubsystem CallsPerformance ImpactMaintenance Effort
100 usersSimple facade calls few subsystemsLow number of calls, minimal overheadNegligible latencyEasy to maintain
10,000 usersMore concurrent facade requestsIncreased subsystem calls, some queuingModerate latency possibleNeed monitoring for bottlenecks
1,000,000 usersHigh concurrency, many facade instancesSubsystems may become overloadedLatency increases, possible timeoutsComplex coordination and scaling needed
100,000,000 usersMassive scale, distributed facadesSubsystems must be highly scalableLatency critical, failures impact facadeRequires automated scaling and fault tolerance
First Bottleneck

The first bottleneck is usually the subsystems behind the facade. As user requests grow, the facade itself is lightweight but the underlying subsystems it calls can become overloaded. This causes increased latency and failures that propagate through the facade.

Scaling Solutions
  • Horizontal scaling: Add more instances of subsystems and facade servers behind load balancers.
  • Caching: Cache frequent responses at the facade to reduce subsystem calls.
  • Asynchronous calls: Use async messaging to decouple facade from slow subsystems.
  • Sharding: Partition data and subsystem responsibilities to reduce load per instance.
  • Rate limiting: Protect subsystems by limiting facade request rates.
  • Monitoring and circuit breakers: Detect failures early and prevent cascading issues.
Back-of-Envelope Cost Analysis
  • At 1M users, assuming 1 request per second per user, facade handles ~1M RPS.
  • Each facade request calls 3 subsystems on average -> 3M subsystem calls per second.
  • Subsystem servers handle ~5,000 RPS each -> need ~600 servers total.
  • Network bandwidth depends on payload size; assume 10KB per request -> 10GB/s total bandwidth.
  • Caching can reduce subsystem calls by 50% or more, cutting server needs and bandwidth.
Interview Tip

When discussing facade pattern scalability, start by explaining the facade role as a simple interface. Then identify that subsystems are the real bottleneck as load grows. Discuss how horizontal scaling, caching, and async communication help. Always connect solutions to the bottleneck you identified.

Self Check

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

Answer: Add read replicas and caching layers to reduce load on the main database before scaling application servers.

Key Result
Facade pattern itself scales well, but underlying subsystems become bottlenecks first; scaling requires subsystem horizontal scaling, caching, and async decoupling.