DSAOps Lab
D
DSAOps LabLogistics Lab

Amazon

Logistics Lab

Route optimization, warehouse management, package tracking

Walkthrough

How Logistics Works

Step-by-step from package arrival to delivery

1

Packages Arrive at Warehouse

Packages of varying weights and destinations arrive at the central warehouse. Each package has a priority, weight, and destination zone that determines how it should be routed.

1
New York21kg
2
Chicago15kg
3
LA8kg
4
Miami13kg
1 / 5

Visualization

3D Control Center

Interactive logistics network visualization

Analysis

Complexity Analysis

Time and space complexity of logistics algorithms

AlgorithmTime ComplexitySpace ComplexityUse Case
BFS (Route)O(V + E)O(V)Unweighted shortest path
DijkstraO((V+E) log V)O(V)Weighted shortest path
A* SearchO(E)O(V)Heuristic pathfinding
DFS (Tracking)O(V + E)O(V)Path existence
Flood FillO(V + E)O(V)Failure zone isolation

Architecture

System Design

How Amazon-scale logistics systems are architected

System Architecture

  • Microservices-based architecture with separate services for routing, tracking, and warehouse management
  • Event-driven communication using message queues for real-time package status updates
  • Distributed graph database (Neo4j) for storing and querying the logistics network topology
  • Redis caching layer for frequently accessed routes and warehouse inventory data

Data Flow

  • Package scan events trigger status updates propagated through Kafka topics
  • Route optimization service consumes real-time traffic data and recalculates ETA using Dijkstra/A*
  • Warehouse inventory changes are broadcast to all connected delivery stations
  • Failure detection via heartbeat monitoring triggers automatic re-routing workflows

Scalability

  • Horizontal scaling of routing workers using Kubernetes pods based on queue depth
  • Geographic sharding of the graph database by region to reduce query latency
  • CDN-based static asset delivery for tracking dashboard with WebSocket live updates
  • Read replicas for the inventory DB to handle peak holiday season traffic

Key Algorithms

  • Dijkstra & A* for shortest path computation across the delivery network graph
  • BFS/DFS for warehouse zone traversal and package location in the sortation center
  • Greedy algorithms for bin packing and truck load optimization
  • Distributed consensus (Raft) for failover coordination between regional control centers

Practice

Interview Questions

Common system design and DSA questions from Amazon interviews

Q

Design a package tracking system that can handle 1M+ packages in transit at any time.

H

Consider sharding by region, event sourcing, and WebSocket push for live updates.

Q

How would you implement real-time shortest path re-computation when a road segment fails?

H

Incremental Dijkstra with a dynamic graph. Cache previous paths and only re-compute affected subgraphs.

Q

Design a warehouse inventory system that optimizes picker travel time.

H

Model as a traveling salesman problem variant. Use A* with Manhattan distance heuristic per zone.

Q

How would you scale last-mile delivery route optimization across thousands of drivers?

H

Hierarchical approach: cluster deliveries by region, then solve vehicle routing problem per cluster using greedy + local search.