Bird
0
0
LLDsystem_design~10 mins

Why parking lot is a classic LLD problem - Scalability Evidence

Choose your learning style9 modes available
Scalability Analysis - Why parking lot is a classic LLD problem
Growth Table: Parking Lot System Scaling
Users / Vehicles100 Vehicles10,000 Vehicles1,000,000 Vehicles100,000,000 Vehicles
Parking SlotsSmall lot, ~100 slotsLarge lot, multiple floorsMultiple lots, city-wideNation-wide, multi-city
Entry/Exit Points1-2 gates10+ gates with sensorsHundreds of gates, automatedThousands of gates, distributed control
Real-time TrackingManual or simple sensorsAutomated sensors, camerasIntegrated IoT devices, cloudDistributed systems, edge computing
Data StorageLocal DB or file systemCentralized DB with cachingDistributed DB, shardingMulti-region DB clusters
User InteractionSimple app or kioskMobile apps, web portalsHigh concurrency, APIsGlobal scale, multi-tenant
First Bottleneck

The first bottleneck is the database that tracks parking slot availability and vehicle entries/exits. At small scale, a single database can handle updates and queries. As users grow, the number of concurrent updates and reads increases, causing delays and potential data inconsistency.

Scaling Solutions
  • Database Scaling: Use read replicas to handle queries, write sharding to distribute updates by parking zones.
  • Caching: Cache slot availability to reduce DB reads.
  • Horizontal Scaling: Add more application servers behind load balancers to handle user requests.
  • Partitioning: Divide parking lots into zones managed independently to reduce contention.
  • Edge Computing: Use local controllers at gates to process data before sending to central servers.
Back-of-Envelope Cost Analysis
  • Requests per second: For 10,000 vehicles with average 1 entry/exit per hour, ~3 requests/sec.
  • Storage: Each vehicle record ~1 KB, 1M vehicles = ~1 GB storage.
  • Bandwidth: Entry/exit data small (~100 bytes), 3 req/sec = ~300 bytes/sec, negligible network load.
Interview Tip

Start by explaining the core entities: vehicles, slots, gates. Discuss how real-time updates and concurrency affect design. Identify bottlenecks like database and network. Propose scaling solutions step-by-step, focusing on data partitioning and caching. Use simple analogies like managing parking zones as neighborhoods.

Self Check

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

Answer: Add read replicas to distribute query load and implement caching for frequent reads to reduce database pressure.

Key Result
The parking lot system first breaks at the database due to concurrent updates and reads; scaling requires partitioning data, caching, and horizontal scaling of application servers.