31. Design Amazon lockers for various locations.
Design locker placement across multiple locations and describe how package assignment, pickup, and capacity fit into the system.
At a high level, this system places lockers across many locations and safely moves each package from assignment to pickup. The main challenge is keeping capacity correct while locker state changes in real time. I would explain three flows: finding and reserving capacity, assigning and delivering a package, and authenticating the customer for pickup. The design uses strongly consistent reservation and pickup records, device heartbeats, and background events. The trade-off is better capacity control at the cost of more coordination.
The goal is to operate package lockers across many locations and make sure each package gets a suitable available space. Customers need nearby lockers, delivery partners need reliable assignments, and the system must know when each locker is free, occupied, or offline. The hard part is keeping capacity correct while many customers, packages, and physical lockers change state. The diagram separates this into location and capacity management, package reservation and assignment, physical locker communication, customer pickup, and background operational work.
- How should we choose between several nearby lockers with available capacity?
- How long should a reservation stay active before unused capacity is released?
- What should happen when a locker temporarily loses network connectivity?
I would start with the customer request. The Customer Mobile App or Amazon Website sends HTTPS requests through the Amazon API Gateway. The gateway provides WAF and DDoS protection before the request reaches the .NET service layer.
Amazon Cognito handles OAuth2 or OIDC authentication. IAM Policies provide RBAC or ABAC authorization. Rate Limiting & Throttling protects the services from excessive requests.
The Locker Location Service manages locations, geofencing, and availability. The Locker Inventory Service tracks door state, temperature, capacity, and heartbeat information.
After a locker is selected, the Reservation Service holds capacity. It also handles reservation expiration, release, and concurrency control so conflicting requests do not consume the same space.
The Package Assignment Service chooses the best locker, checks capacity fit, and creates the reservation. Important locations, lockers, reservations, and pickup records are stored in the Primary DB using Aurora or PostgreSQL. Reservations and pickups use strong consistency because capacity must remain correct.
The Cache keeps locker state and other hot data for faster lookups. The Primary DB remains the durable store for the important reservation and pickup records.
The .NET services send locker commands through HTTPS or MQTT. Locker hardware contains a controller, sensors, connectivity, secure boot, firmware, and a local state buffer.
The lockers send heartbeat and status updates back to the service layer. These updates help the Locker Inventory Service know whether a locker is healthy and available.
Amazon Order Management and Delivery Partner Systems exchange order or status updates with the service layer. The pickup flow then moves from locker selection to assignment and reservation. The customer receives a PIN or QR notification.
At the locker, the Pickup Service verifies the PIN or OTP. It sends the command to open the correct door and completes the pickup. The API Gateway returns the JSON response to the client.
Services publish asynchronous events to the Message Queue and EventBridge. The Notification Service uses email, SMS, or push providers for pickup and expiry alerts. BackgroundService workers handle background work without turning Tasks into a durable queue.
Object Storage keeps audit logs, receipts, and locker firmware. The system also connects to the Payment Service shown in the diagram.
Containerized .NET services run on Kubernetes across multiple availability zones. Health checks support recovery. Metrics, logs, and OpenTelemetry tracing provide observability. Retries use backoff, circuit breakers, and idempotent consumers. The main trade-off is that real-time capacity reduces overbooking, but requires more coordination and operational work.
The benefit is accurate locker capacity and a clear separation of responsibilities. Strong consistency for reservations and pickups helps prevent two requests from taking the same space. The cache makes common locker lookups faster. Multi-AZ deployment and health checks improve availability. The downside is more moving parts. Real-time heartbeats create frequent state updates. Short reservation lifetimes reduce overbooking, but expired reservations must be released correctly. Queues keep background work away from the main request, but retries and duplicate events need careful handling. Offline locker support is useful, but the local state buffer and recovery process make device behavior more complex.
Interviewers ask this question to see whether you can connect software decisions with real physical capacity. They want to know how you prevent conflicting reservations, assign packages to suitable lockers, handle customer pickup, and communicate with devices. They also look for judgment around background work, failures, security, scaling, and consistency. A strong answer explains these choices clearly instead of only naming technologies.






