Bird
Raised Fist0
LLDsystem_design~25 mins

Multiple elevator coordination in LLD - System Design Exercise

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Design: Multiple Elevator Coordination System
Design focuses on the coordination logic and communication between elevators and control system. Hardware details of elevators and physical sensors are out of scope.
Functional Requirements
FR1: Support multiple elevators in a building with up to 20 floors
FR2: Handle elevator requests from any floor (up/down buttons) and inside elevators (floor selection)
FR3: Efficiently assign elevators to requests to minimize wait and travel time
FR4: Support concurrent requests and real-time updates of elevator positions and states
FR5: Provide status of each elevator (idle, moving up/down, door open/closed)
FR6: Handle edge cases like simultaneous requests, elevator overload, and emergency stop
Non-Functional Requirements
NFR1: System must respond to requests with p99 latency under 100ms
NFR2: Support up to 10 concurrent elevators and 100 concurrent requests
NFR3: High availability with 99.9% uptime
NFR4: Low memory footprint suitable for embedded elevator controllers
Think Before You Design
Questions to Ask
❓ Question 1
❓ Question 2
❓ Question 3
❓ Question 4
❓ Question 5
Key Components
Elevator controller module per elevator
Central coordination system or distributed coordination
Request queue or priority queue for pending calls
State management for elevator position, direction, and door status
Communication protocol between elevators and coordinator
Design Patterns
Observer pattern for state updates
Priority queue for request scheduling
Finite state machine for elevator states
Load balancing algorithms for request assignment
Event-driven architecture for real-time updates
Reference Architecture
          +-----------------------+
          |  Central Coordinator   |
          |  - Request Scheduler   |
          |  - Elevator State DB   |
          +-----------+-----------+
                      |
          +-----------+-----------+-----------+-----------+
          |           |           |           |           |
    +-----v-----+ +---v-----+ +---v-----+ +---v-----+ +---v-----+
    | Elevator 1| |Elevator2| |Elevator3| |Elevator4| |Elevator5|
    | Controller| |Controller| |Controller| |Controller| |Controller|
    +-----------+ +---------+ +---------+ +---------+ +---------+

Each Elevator Controller communicates with Central Coordinator to receive assignments and report status.
Components
Central Coordinator
In-memory scheduler service
Receives all elevator requests, maintains elevator states, assigns requests to elevators efficiently
Elevator Controller
Embedded controller software
Controls individual elevator movement, doors, and reports status to coordinator
Request Queue
Priority queue data structure
Stores pending floor requests prioritized by direction and proximity
State Database
In-memory key-value store
Stores real-time elevator positions, directions, and door states
Communication Protocol
Lightweight message passing (e.g., MQTT or custom TCP)
Enables real-time bidirectional communication between coordinator and elevators
Request Flow
1. User presses floor button inside elevator or call button on a floor
2. Elevator Controller sends request to Central Coordinator
3. Coordinator adds request to Request Queue
4. Scheduler evaluates all pending requests and elevator states
5. Coordinator assigns request to best elevator based on current position and direction
6. Assigned Elevator Controller receives request and updates its internal queue
7. Elevator moves to requested floor, opens doors, and updates status to Coordinator
8. Coordinator updates State Database and removes completed request
9. System repeats for new incoming requests
Database Schema
Entities: - Elevator: id (PK), current_floor, direction (up/down/idle), door_status (open/closed), load_status - Request: id (PK), floor_number, direction (up/down), status (pending/assigned/completed), assigned_elevator_id (FK) Relationships: - One Elevator can have many Requests assigned - Requests are linked to one Elevator when assigned - State Database holds current Elevator states and Request statuses
Scaling Discussion
Bottlenecks
Central Coordinator becomes a single point of failure and bottleneck with many elevators
Request Queue contention under high request volume
Communication delays between elevators and coordinator
Memory limits on embedded controllers for state tracking
Solutions
Implement distributed coordination with partitioned floors or elevator groups
Use concurrent priority queues with locking or lock-free data structures
Optimize communication with lightweight protocols and batch updates
Offload complex scheduling logic to cloud or edge servers, keep controllers simple
Interview Tips
Time: Spend 10 minutes clarifying requirements and constraints, 15 minutes designing components and data flow, 10 minutes discussing scaling and edge cases, 10 minutes summarizing and answering questions.
Clarify number of elevators and floors early
Explain trade-offs in scheduling algorithms (e.g., nearest elevator vs. load balancing)
Describe how state is tracked and updated in real-time
Discuss failure handling and emergency scenarios
Highlight scalability challenges and solutions

Practice

(1/5)
1. What is the main goal of multiple elevator coordination in a building?
easy
A. To reduce wait and travel times for passengers
B. To increase the number of elevators in the building
C. To make elevators move randomly
D. To keep all elevators idle at the ground floor

Solution

  1. Step 1: Understand elevator coordination purpose

    Multiple elevator coordination aims to improve efficiency by reducing passenger wait and travel times.
  2. Step 2: Evaluate options based on goal

    Options B, C, and D do not focus on improving passenger experience or efficiency.
  3. Final Answer:

    To reduce wait and travel times for passengers -> Option A
  4. Quick Check:

    Goal of coordination = reduce wait/travel times [OK]
Hint: Focus on passenger experience improvement goals [OK]
Common Mistakes:
  • Confusing coordination with adding more elevators
  • Thinking elevators should stay idle
  • Assuming random movement improves service
2. Which of the following is a correct way to assign an elevator to a new request in a multiple elevator system?
easy
A. Always assign the elevator on the ground floor
B. Assign the elevator farthest from the request floor regardless of direction
C. Assign the elevator closest to the request floor moving in the same direction
D. Assign elevators randomly to balance usage

Solution

  1. Step 1: Understand assignment criteria

    Elevators should be assigned based on proximity and direction to minimize wait time.
  2. Step 2: Analyze options

    Assign the elevator closest to the request floor moving in the same direction matches this logic. Options A, B, and C ignore direction or proximity, causing inefficiency.
  3. Final Answer:

    Assign the elevator closest to the request floor moving in the same direction -> Option C
  4. Quick Check:

    Closest elevator + direction match = correct assignment [OK]
Hint: Match elevator direction and proximity for assignment [OK]
Common Mistakes:
  • Ignoring elevator direction when assigning
  • Choosing elevators randomly
  • Always picking ground floor elevator
3. Consider a system with 2 elevators: Elevator A at floor 3 moving up with destinations [5, 7], Elevator B at floor 6 moving down with destinations [4, 2]. A request comes from floor 4 to go up. Which elevator should be assigned?
medium
A. Neither elevator
B. Elevator B
C. Either elevator
D. Elevator A

Solution

  1. Step 1: Analyze elevator positions and directions

    Elevator A is at floor 3 going up; Elevator B is at floor 6 going down.
  2. Step 2: Match request direction and elevator direction

    Request is at floor 4 going up. Elevator A is below floor 4 and moving up, so it can pick up on the way. Elevator B is above floor 4 but moving down, so it cannot pick up going up.
  3. Final Answer:

    Elevator A -> Option D
  4. Quick Check:

    Elevator moving towards request floor in same direction = Elevator A [OK]
Hint: Pick elevator moving towards request floor in same direction [OK]
Common Mistakes:
  • Choosing elevator moving away from request
  • Ignoring elevator direction
  • Assuming either elevator works
4. In a multiple elevator system, the controller assigns requests but sometimes an elevator gets stuck and does not update its position. What is the likely problem and how to fix it?
medium
A. Elevator state not updated; add regular position updates and health checks
B. Elevator hardware failure; replace elevator immediately
C. Controller assigns requests randomly; fix assignment logic
D. Elevator doors stuck open; fix door sensors

Solution

  1. Step 1: Identify cause of stuck elevator in system

    If elevator position is not updated, controller cannot assign requests properly.
  2. Step 2: Determine fix

    Adding regular position updates and health checks ensures controller has current elevator status to assign requests correctly.
  3. Final Answer:

    Elevator state not updated; add regular position updates and health checks -> Option A
  4. Quick Check:

    Missing updates cause stuck state; fix with health checks [OK]
Hint: Ensure elevator regularly reports position to controller [OK]
Common Mistakes:
  • Assuming hardware failure without checking software updates
  • Blaming random assignment logic
  • Ignoring elevator state updates
5. You are designing a multiple elevator coordination system for a 20-floor building with 4 elevators. To minimize average wait time during peak hours, which strategy is best?
hard
A. Assign elevators randomly to requests to balance load
B. Divide floors into zones and assign elevators to zones dynamically
C. Let all elevators serve all floors equally without zoning
D. Keep all elevators idle at ground floor until called

Solution

  1. Step 1: Understand peak hour challenges

    High traffic causes many requests; serving all floors equally can cause delays and conflicts.
  2. Step 2: Evaluate zoning strategy

    Dividing floors into zones and assigning elevators reduces travel distance and wait time by localizing service.
  3. Step 3: Compare other options

    Random assignment or no zoning causes inefficiency; keeping elevators idle wastes capacity.
  4. Final Answer:

    Divide floors into zones and assign elevators to zones dynamically -> Option B
  5. Quick Check:

    Zoning elevators reduces wait time in tall buildings [OK]
Hint: Use zoning to reduce travel distance and wait time [OK]
Common Mistakes:
  • Ignoring zoning benefits in tall buildings
  • Assuming random assignment balances load
  • Keeping elevators idle wastes capacity