| Scale | Number of Floors | Parking Spots | Vehicles Parked Concurrently | Requests per Second (Entry/Exit) |
|---|---|---|---|---|
| 100 users | 1-2 floors | 50-100 spots | 30-50 vehicles | 10-20 requests/sec |
| 10K users | 5-10 floors | 500-1000 spots | 400-700 vehicles | 200-500 requests/sec |
| 1M users | 20-50 floors | 10,000-20,000 spots | 8,000-15,000 vehicles | 5,000-8,000 requests/sec |
| 100M users | 100+ floors (multiple lots) | 1,000,000+ spots | 800,000+ vehicles | 500,000+ requests/sec |
Class identification (ParkingLot, Floor, Spot, Vehicle) in LLD - Scalability & System Analysis
At small scale, the database is the first bottleneck. It stores data about floors, spots, and vehicles. As users increase, the database struggles to handle many read/write requests for parking spot availability and vehicle entry/exit.
At medium scale, the application server CPU and memory become bottlenecks due to processing many concurrent requests and managing state.
At large scale, network bandwidth and data partitioning become critical to handle massive traffic and data volume.
- Database: Use read replicas to handle read-heavy traffic. Implement connection pooling to manage database connections efficiently.
- Caching: Cache frequently accessed data like available spots per floor to reduce database load.
- Application Servers: Horizontally scale by adding more servers behind a load balancer to distribute traffic.
- Data Partitioning: Shard the database by parking lot or floor to distribute data and reduce contention.
- Network: Use CDNs for static content (e.g., parking rules, maps) and optimize APIs for minimal data transfer.
- At 1M users, expect ~5,000-8,000 requests/sec for entry/exit updates.
- Storage needed: Each vehicle record ~1KB, so 15,000 vehicles = ~15MB active data; historical logs add more.
- Bandwidth: Assuming 1KB per request, 8,000 req/sec = ~8MB/sec (~64Mbps), manageable with standard network setups.
Start by defining system scale and key components (ParkingLot, Floor, Spot, Vehicle). Identify which component handles the most load. Discuss bottlenecks at each scale and propose targeted solutions. Use real numbers to justify your choices. Always mention trade-offs and how to monitor system health.
Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?
Answer: Add read replicas and implement caching to reduce direct database load. Also, optimize queries and use connection pooling before considering more complex solutions.
