| Users / Games | Polymorphism Complexity | Strategy Depth | System Impact |
|---|---|---|---|
| 100 games | Basic piece behavior tested; few subclasses | Simple tactics; shallow move trees | Single server handles logic easily |
| 10,000 games | More piece interactions; polymorphic calls increase | Deeper strategy; longer move sequences | CPU load rises; need efficient algorithms |
| 1,000,000 games | Complex polymorphic hierarchies stressed; many piece types | Advanced strategy; deep search trees; pruning needed | Horizontal scaling; caching of common patterns |
| 100,000,000 games | Extensive polymorphism; dynamic behavior changes | AI-level strategy; machine learning integration | Distributed systems; sharding; load balancing |
Why chess tests polymorphism and strategy in LLD - Scalability Evidence
The first bottleneck is the CPU processing power on the application server. As polymorphism requires dynamic method dispatch and strategy involves deep move calculations, the CPU load increases significantly with more concurrent games and complex strategies.
- Horizontal scaling: Add more servers to distribute game processing load.
- Caching: Cache common board states and move results to avoid repeated calculations.
- Algorithm optimization: Use pruning techniques like alpha-beta to reduce strategy search space.
- Load balancing: Evenly distribute incoming game requests across servers.
- Sharding: Partition game data by user or game ID to reduce database contention.
- At 1,000 concurrent games, assuming 1 move per second, ~1,000 QPS of game logic calls.
- Each polymorphic call costs CPU cycles; deep strategy search can multiply CPU usage by 10x or more.
- Storage per game state is small (~1 KB), but 1M games require ~1 GB storage plus indexing.
- Network bandwidth is moderate; mostly small move data (~100 bytes per move).
Start by identifying the core components: polymorphism for piece behavior and strategy for move calculation. Discuss how each scales with users and game complexity. Then explain bottlenecks and propose targeted solutions like caching and horizontal scaling. Use real numbers to show understanding.
Your database handles 1000 QPS. Traffic grows 10x. What do you do first?
Answer: Add read replicas and implement caching to reduce database load before considering sharding or more complex solutions.