Design locker allocation service

Quick Overview

This question evaluates a candidate's understanding of stateful system design, resource allocation strategies, concurrency control, API and data modeling, and fault tolerance in the context of real-time locker assignment.

Design locker allocation service

Company: Amazon

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Technical Screen

Amazon Locker OS provides a set of LockerIDs. Locker and package sizes are Small, Medium, and Large. Each locker may hold at most one package. Design the component that manages the set of lockers and returns the best-fitting LockerID when a courier arrives with a package. Clearly define "best fit" (e.g., prefer exact size; allow upsizing rules and their priority). Specify core operations (register lockers, mark available/occupied, assign, release on pickup, query status), data structures, and time/space complexity. Address concurrency (simultaneous couriers), idempotency and retries, race conditions, and fairness/starvation. Describe persistence and failure recovery. Provide APIs, schema, and pseudocode for assign(packageSize) and release(lockerId). Consider extensions such as reservations, per-location sharding, priorities/SLA tiers, and scaling.

Quick Answer: This question evaluates a candidate's understanding of stateful system design, resource allocation strategies, concurrency control, API and data modeling, and fault tolerance in the context of real-time locker assignment.

|Home/System Design/Amazon
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
hardSoftware EngineerTechnical ScreenSystem Design
4
0

Design a Best-Fit Locker Assignment Component

Context

You are designing the locker-assignment component for a Locker OS used at physical locker banks (one or more locations). Lockers and packages have sizes: Small (S), Medium (M), Large (L). Each locker holds at most one package. Couriers arrive with packages and need to be assigned the best-fitting LockerID quickly and safely under concurrency.

Assume:

  • The component may run per location (preferred) or centrally with per-location sharding.
  • Locker devices report available/occupied states; the service is the source of truth for assignment decisions.

Requirements

Design a component that:

  1. Returns the best-fitting locker for a given package size.
  2. Defines a clear "best fit" policy (exact match preferred; upsizing rules and priorities).
  3. Exposes core operations:
    • Register lockers
    • Mark locker available/occupied/broken
    • Assign locker to package (for courier)
    • Release on pickup
    • Query status and counts
  4. Specifies data structures and time/space complexity.
  5. Addresses concurrency (simultaneous couriers), idempotency and retries, race conditions, fairness/starvation.
  6. Describes persistence and failure recovery.
  7. Provides APIs, schema, and pseudocode for assign(packageSize) and release(lockerId).
  8. Considers extensions: reservations, per-location sharding, priorities/SLA tiers, and scaling.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...