Skip to content
Low Level Design Mastery Logo
LowLevelDesign Mastery

Design an Elevator System

Design a smart elevator control system for a high-rise building.

Design a smart elevator control system for a high-rise building. It needs to handle multiple elevator cars, different request strategies (SCAN, FCFS), and emergency states.

In this problem, you’ll design a central controller that dispatches elevators based on proximity, direction, and current load to reduce waiting time and optimize efficiency.


Design a smart elevator control system for a building with multiple elevators and many floors. The system must efficiently move people while respecting capacity limits and safety protocols.

Functional Requirements:

  • Multi-Elevator Support: Handle a configurable number of elevators, all serving all floors.
  • Capacity Management: Each car has a maximum weight/person limit that must never be exceeded.
  • Request Handling: Support external floor requests and internal cabin floor selections.
  • Smart Dispatching: Minimize wait times by selecting the best elevator based on direction, distance, and load.
  • Batch Processing: Each car should handle multiple requests, stopping at floors along the way efficiently.
  • State Tracking: Monitor and update current floor positions and movement states.
  • Door Control: Properly manage transitions for door opening and closing during stops.

Non-Functional Requirements:

  • Object-Oriented Design: Clear separation of roles (Controller, Car, Dispatcher, Button).
  • Modular & Flexible: Easy to add new strategies (SCAN, FCFS) or maintenance modes.
  • Thread Safety: Ensure state updates and requests are handled safely under concurrent access.
  • Maintainability: Core logic should be easy to understand, test, and extend over time.

The system uses a central ElevatorController to manage the fleet of ElevatorCars.

Diagram
classDiagram
    class ElevatorController {
        -List~ElevatorCar~ cars
        -DispatchStrategy strategy
        +handleRequest(request)
        -findBestCar(request)
    }
    
    class ElevatorCar {
        -int currentFloor
        -Direction direction
        -State state
        -InternalButtons buttons
        +move()
        +stop()
    }
    
    class Request {
        -int floor
        -Direction direction
        -RequestType type
    }

    class DispatchStrategy {
        <<interface>>
        +selectCar(cars, request)
    }

    ElevatorController --> ElevatorCar
    ElevatorController --> DispatchStrategy
    ElevatorCar --> Request

Diagram

1. Optimizing Movement (The Elevator Algorithm)

Section titled “1. Optimizing Movement (The Elevator Algorithm)”

Should an elevator stop for every floor in order (FCFS), or should it pick up everyone on the way (SCAN)?

Solution: Use the Strategy Pattern. Implement the SCAN algorithm (also known as the Elevator Algorithm), where the car continues in its current direction until all requests in that direction are fulfilled before reversing.

Assigning the nearest car isn’t always best if that car is already full or going in the opposite direction.

Solution: The ElevatorController should calculate a “cost” for each car based on:

  • Distance to the floor.
  • Current direction vs. request direction.
  • Number of pending stops.
  • Current load.

Multiple users on different floors might press buttons at the exact same millisecond.

Solution: Use thread-safe data structures like ConcurrentLinkedQueue for pending requests and ReentrantLock for updating the state of an individual elevator car.


By solving this problem, you’ll master:

  • Strategy Pattern - Making algorithms swappable and extensible.
  • State Management - Coordinating complex, independent units.
  • Concurrency - Building robust systems for high-contention environments.
  • Resource Optimization - Balancing user wait time vs. energy efficiency.

Ready to see the full implementation? Open the interactive playground to access:

  • 🎯 Step-by-step guidance through the 8-step LLD approach
  • 📊 Interactive UML builder to visualize your design
  • 💻 Complete Code Solutions in Python, Java, C++, TypeScript, JavaScript, C#
  • 🤖 AI-powered review of your design and code

After mastering the Elevator System, try these similar problems: