Bird
0
0
LLDsystem_design~10 mins

Class identification (ParkingLot, Floor, Spot, Vehicle) in LLD - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - Class identification (ParkingLot, Floor, Spot, Vehicle)
Growth Table: Parking Lot System
ScaleNumber of FloorsParking SpotsVehicles Parked ConcurrentlyRequests per Second (Entry/Exit)
100 users1-2 floors50-100 spots30-50 vehicles10-20 requests/sec
10K users5-10 floors500-1000 spots400-700 vehicles200-500 requests/sec
1M users20-50 floors10,000-20,000 spots8,000-15,000 vehicles5,000-8,000 requests/sec
100M users100+ floors (multiple lots)1,000,000+ spots800,000+ vehicles500,000+ requests/sec
First Bottleneck

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.

Scaling Solutions
  • 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.
Back-of-Envelope Cost Analysis
  • 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.
Interview Tip

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.

Self Check

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.

Key Result
The database is the first bottleneck as user and request volume grow; scaling requires caching, read replicas, and horizontal application server scaling.