0
0
LLDsystem_design~10 mins

Domain-Driven Design basics in LLD - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - Domain-Driven Design basics
Growth Table: Domain-Driven Design Basics
Users / Scale100 Users10,000 Users1,000,000 Users100,000,000 Users
Domain Model ComplexitySimple, few bounded contextsMultiple bounded contexts emergeMany bounded contexts, complex aggregatesHighly modular domains, strict context boundaries
Team StructureSmall team, single team owns domainMultiple teams per bounded contextLarge teams, clear ownership per contextMany teams, microservices aligned with contexts
CommunicationDirect, informalDefined interfaces between contextsAsynchronous messaging, event-drivenAutomated contracts, API gateways
Data ManagementSingle database, simple schemaSeparate databases per bounded contextDatabase per microservice, eventual consistencyPolyglot persistence, CQRS, event sourcing
Scaling FocusCode clarity, domain understandingModularization, decouplingService isolation, independent deploysGlobal distribution, resilience, automation
First Bottleneck

At small scale, the main bottleneck is unclear domain boundaries causing confusion and slow development.

As users grow, the bottleneck shifts to communication overhead between teams and tightly coupled code.

At large scale, data consistency and integration between bounded contexts become the bottleneck.

Scaling Solutions
  • Define clear bounded contexts: Separate domain areas to reduce complexity and team conflicts.
  • Use context maps: Explicitly document relationships and integration patterns between contexts.
  • Apply microservices: Align services with bounded contexts for independent scaling and deployment.
  • Implement asynchronous communication: Use events and messaging to decouple contexts and improve scalability.
  • Adopt eventual consistency: Accept temporary data differences to improve performance and availability.
  • Use domain events and event sourcing: Capture changes as events for auditability and replay.
  • Automate testing and deployment: Ensure safe changes in complex domain models.
Back-of-Envelope Cost Analysis

Assuming 10,000 active users generating 1 request per second:

  • Requests per second: ~10,000 QPS
  • Database queries: 20,000 QPS (including reads and writes)
  • Storage: Depends on domain events and aggregates; estimate 100GB/month for event store
  • Network bandwidth: ~100 Mbps assuming 10KB per request/response
  • Compute: Multiple app servers to handle load, plus messaging infrastructure

Scaling beyond 100,000 users requires sharding databases, adding read replicas, and partitioning event streams.

Interview Tip

When discussing Domain-Driven Design scalability, start by explaining bounded contexts and their importance.

Describe how clear domain boundaries reduce complexity and improve team autonomy.

Explain how asynchronous communication and eventual consistency help scale integrations.

Finally, mention how microservices and event-driven patterns support independent scaling and deployment.

Self Check

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

Answer: Introduce read replicas and caching to reduce load on the primary database before considering sharding or redesign.

Key Result
Domain-Driven Design scales by defining clear bounded contexts, decoupling teams and data, and adopting asynchronous communication and microservices to handle complexity and traffic growth.