Design a distributed system for managing access to parking facilities with subscriptions, one-time visits, and offline terminals.
Asked at
AI answer
Architecture
A central service manages parking facilities, spaces, subscriptions, rates, and access rules. Gates and terminals operate through a local controller that connects to the server over a secure channel. PostgreSQL stores accounts and transactions; a broker delivers commands and events; a cache and the controller's local storage enable fast decisions and offline operation.
Passes and visits
A subscription has a validity period, parking facility or zone, restrictions, and a status. A single visit is a separate record with a time window, rate, and entry/exit state. State transitions are performed atomically; repeated requests from a terminal are identified by an idempotency key. Account for concurrent entries and space limits using transactions or locks on the parking facility/pass. Do not treat payments as confirmed based only on a client request—verify confirmation from the provider.
Offline mode and security
If connectivity is lost, the terminal uses a locally stored allowlist, signed and limited by time and volume, along with operator-defined rules—for example, safely deny entry or allow entry with subsequent reconciliation. Every decision and event is recorded in a durable local log with a sequence number; after connectivity is restored, events are synchronized idempotently. Provide for key revocation and conflict handling so that an offline decision does not become a permanent authorization.
Devices authenticate using individual certificates; secrets are protected, traffic is encrypted, and staff access is separated by role. Monitor terminal availability, the share of offline decisions, synchronization latency, and accounting discrepancies. Regularly test database recovery and failover scenarios.
Also asked at Andersen
- Which company did you work for and what projects did you handle?
- How do you work with Linux at the system administration level?
- What databases do you have experience working with?
- How is a container built and run from a Dockerfile?
- How did you deploy the Kubernetes cluster and how did you manage it? What tools did you use for rollout?
Similar questions
- Design a distributed system for managing parking across 100 cities, with offline terminals and accurate billing.
- Design a distributed system for processing orders in an online store, including inventory reservation, payment, delivery, and returns.
- Design a distributed ticket booking system for a stadium where 2 million users simultaneously compete for 80,000 seats, and payments may be confirmed with a delay of up to 30 seconds.
- Design an access control system for buildings serving 1 million employees and 50,000 doors, with offline operation and instant badge revocation.
- Design a distributed system for managing medical prescriptions with versioning, reminders, and offline mode.