How to design an elevator system?
"Design an elevator system" is a classic object-oriented design (OOD) interview question. A strong answer follows four steps: clarify requirements, design the core classes, pick a scheduling algorithm, and then discuss scaling to multiple elevators. This guide walks through each step the way an interviewer expects to hear it.
Step 1: Clarify Requirements
Functional Requirements
- Elevator control: Move the elevator between floors and stop at requested floors.
- Two kinds of requests: Hall calls (a user on a floor presses up or down) and cab calls (a user inside selects a destination floor).
- Door control: Open and close doors safely at each stop.
- Direction and floor display: Show current floor and direction (up, down, idle).
- Emergency handling: Emergency stop, overload alarm, power failure behavior.
Non-Functional Requirements
- Low wait time: Minimize average wait and travel time.
- Scalability: Support a building with multiple elevators and many floors.
- Reliability and safety: The system must fail safe; doors never open between floors.
Stating both request types (hall calls vs. cab calls) early is a strong signal to the interviewer: it drives the whole design.
Step 2: Core Objects and Classes
An interview-ready object model needs only a handful of classes:
| Class | Responsibility |
|---|---|
| ElevatorSystem | Entry point; owns all elevators and dispatches hall calls |
| Elevator | State (current floor, direction, door), its request queue, movement |
| Request | Floor number plus type (hall call with direction, or cab call) |
| Door | Open/close with safety checks |
| Display | Current floor and direction indicators |
| Scheduler / DispatchStrategy | Decides which elevator serves a hall call |
Two classic design patterns fit naturally here, and naming them earns credit: the State pattern for elevator states (moving up, moving down, idle, doors open) and the Strategy pattern for swappable dispatch algorithms. Both are covered in our guide to the top must-know design patterns.
Step 3: The Scheduling Algorithm
This is the heart of the question. Naive first-come-first-served makes the elevator zigzag between floors. Real elevators use direction-based sweeping:
- SCAN (the "elevator algorithm"): Keep moving in the current direction, serving every request along the way, until the end of the shaft, then reverse.
- LOOK (what you should propose): Same as SCAN, but reverse as soon as there are no more requests ahead in the current direction, rather than traveling to the top or bottom floor.
With LOOK, the elevator maintains two sorted sets of stops: floors above it (served while going up) and floors below it (served while going down). A hall call going down is only served when the elevator is sweeping down past that floor.
Step 4: Implementation Example
Here is a simplified LOOK-style controller in Python. It keeps up-stops and down-stops separate and sweeps in one direction until that direction is exhausted:
class Elevator: def __init__(self, num_floors): self.num_floors = num_floors self.current_floor = 0 self.direction = 'idle' # 'up', 'down', or 'idle' self.up_stops = set() # floors to serve while going up self.down_stops = set() # floors to serve while going down def request(self, floor): """Handles both cab calls and hall calls.""" if floor > self.current_floor: self.up_stops.add(floor) elif floor < self.current_floor: self.down_stops.add(floor) def step(self): """Advance one floor and stop if this floor was requested.""" if self.direction == 'idle': if self.up_stops: self.direction = 'up' elif self.down_stops: self.direction = 'down' else: return if self.direction == 'up': self.current_floor += 1 if self.current_floor in self.up_stops: self.up_stops.remove(self.current_floor) self.open_doors() if not self.up_stops: # LOOK: reverse early self.direction = 'down' if self.down_stops else 'idle' elif self.direction == 'down': self.current_floor -= 1 if self.current_floor in self.down_stops: self.down_stops.remove(self.current_floor) self.open_doors() if not self.down_stops: self.direction = 'up' if self.up_stops else 'idle' def open_doors(self): print(f"Stopping at floor {self.current_floor}, doors open") elevator = Elevator(num_floors=10) elevator.request(3) elevator.request(7) while elevator.direction != 'idle' or elevator.up_stops or elevator.down_stops: elevator.step()
Step 5: Scaling to Multiple Elevators
Once the single-elevator design works, the interviewer will ask about a bank of elevators. Discuss the dispatch strategy:
- Nearest car: Assign each hall call to the elevator that can reach it soonest while moving in a compatible direction.
- Load balancing: Spread requests so one car does not absorb all traffic.
- Zoning: In tall buildings, dedicate elevators to floor ranges (for example, one bank serves floors 1-20, another 21-40) to cut travel time.
- Destination dispatch: Modern buildings ask for the destination floor in the lobby and group passengers heading to nearby floors into the same car.
Also worth mentioning: emergency behavior (return to ground floor on fire alarm), overload sensors blocking departure, and monitoring for maintenance.
How to Present This in an Interview
- Spend the first few minutes on requirements, especially hall calls vs. cab calls.
- Sketch the classes and name the State and Strategy patterns.
- Explain SCAN, then improve it to LOOK.
- Close with multi-elevator dispatch and safety handling.
Frequently Asked Questions
Is elevator design a low-level design (LLD) or high-level design (HLD) question? It is usually asked as low-level / object-oriented design: the interviewer wants classes, state transitions, and the scheduling algorithm rather than distributed-systems architecture.
Which algorithm do real elevators use? Variations of SCAN/LOOK with direction-based sweeping, and destination dispatch with passenger grouping in modern high-rises.
What design patterns apply to an elevator system? State (elevator states), Strategy (dispatch algorithms), Singleton (the system controller), and Observer (floor displays reacting to elevator movement).
Summary
A great elevator design answer is: clarified requirements, a small clean object model, the LOOK scheduling algorithm, and a dispatch strategy for multiple cars. Practice structuring answers like this in Grokking the Object Oriented Design Interview, which covers elevator-style OOD questions in depth, and Grokking the System Design Interview for the large-scale counterpart. For the reusable building blocks behind both, see System Design Patterns: From Fundamentals to Real Systems.

GET YOUR FREE
Coding Questions Catalog

$197

$72

$78