Java LLD: Amazon Locker Design with SmallestFit Allocation

Designing an Amazon Locker system is a favorite Low-Level Design (LLD) question at FAANG because it tests your ability to handle physical constraints and concurrency. If you cannot guarantee thread-safe slot allocation while minimizing wasted space, your design will fall apart under production load.

The Mistake Most Candidates Make

Naively picking the first available locker: This leads to massive spatial fragmentation, such as placing a small smartphone box into an extra-large locker, leaving zero room for actual oversized shipments.

Ignoring race conditions: Failing to make slot reservation atomic allows two delivery agents to simultaneously claim the same physical locker slot for different packages.