You press the elevator button and watch the floor indicators tick up and down one by one. You might think it’s just bad luck—but in reality, you’re looking at an optimization problem that computer scientists and engineers have been studying for over a century.
Yesterday (August 1), web developer John Allsopp published an interactive explanation of elevator algorithms that quickly reached the top of Hacker News, continuing to spark active discussion on Lobsters today (52 points, 6 comments). Instead of breaking shocking news, the post turned complex elevator dispatching logic into a hands-on, drag-and-drop simulator. Its popularity stems from answering a question everyone has asked while waiting in a lobby: When I press the button, does the elevator actually hear me?
Yes, it hears you. It just has a lot on its mind.
What Elevators Optimize For: Why Averages Lie
How do you measure whether an elevator algorithm is doing a good job?
The intuitive answer is “average wait time.” But when you plot the wait times of thousands of simulated rides, average numbers turn out to be deeply deceptive. John’s simulator highlights two key metrics: a p50 wait time of 1 minute (meaning half of all passengers get on within a minute) and a p90 wait time of 2 minutes (meaning 90% wait no longer than two minutes).
That single extra minute between p50 and p90 holds the central secret of the elevator industry: human memory doesn’t track averages; it remembers the worst-case scenario. That 10% tail of excruciatingly long waits looms disproportionately large in our minds. As a result, the feeling that “the elevator never comes” is largely an illusion produced jointly by statistical distributions and cognitive bias. In reality, your elevator arrives within a minute half the time.
Engineering trade-offs are equally intricate. Average wait time, maximum wait time, and overall energy consumption directly conflict with one another. Sending elevators exclusively to pick up the nearest passenger minimizes average wait times, but in extreme edge cases, someone on another floor might end up waiting 5 minutes. Sacrificing a bit of average performance to eliminate “endless wait” outliers is the pragmatic choice made by most commercial office towers. There is no free lunch—elevator manufacturers simply select a trade-off matrix you rarely think about.
Figure: Wait time distribution generated from thousands of simulations in the original post. Source: john.fun
The Oldest Rule: Ride to the End, Then Turn Around
Before algorithms took over, elevators were operated by humans. Elevator operators were common well into the mid-20th century: opening doors, asking for your floor, and manually steering the cab to its destination. When automation arrived, operators vanished, rules were codified into machines, and scheduling shifted from human judgment to pure mathematics.
The earliest automated rules were astonishingly simple. Patented in 1961, the SCAN algorithm dictates that an elevator departs from the lobby, sweeps continuously upward picking up and dropping off passengers along the way, until it hits the top floor before reversing direction—repeating this cycle indefinitely. Later engineers realized it was wasteful to travel all the way to the top when no requests remained, leading to the LOOK algorithm: the elevator only travels as far as the highest requested floor before turning around. Today, most people take this logic for granted without realizing it is a formal algorithm.
It also shares a famous sibling in computer science: hard disk drive head scheduling. When a mechanical disk head seeks data across magnetic platters, it moves in almost exactly the same pattern. Computer science adopted the term directly, calling it the “Elevator Algorithm.” A patent from over 60 years ago continues to run inside both your hard drive and your building’s elevator shafts today—proving that simple rules often outlive most modern software.
However, single-elevator rules break down during morning peak hours. Imagine an office building at 9:00 AM: hundreds of employees press the up button in the main lobby simultaneously. If a naive system dispatched every cab straight to the lobby, three cars would open their doors at once and depart upwards half-empty. To prevent this, dispatchers must perform counter-intuitive actions—such as sending an empty cab on a detour to fetch passengers on another floor. You might stand on Floor 15 and watch an elevator speed past you without stopping: it heard your call, but it is serving a larger global optimization plan.
Figure: Interactive demo on the homepage—a single elevator making trips in a 4-story building, watchable at 25x speed. Source: john.fun
Multi-Elevator Coordination: Re-Scoring Every 5 Seconds
When multiple elevators operate in parallel, the problem becomes exponentially harder: Which car should take which call?
Modern group control systems (such as Otis’s RSR algorithm) employ dynamic scoring models. Every elevator is continuously assigned a candidate score based on estimated arrival time, current load, proximity to other cars, direction of travel, and idle state. The elevator with the lowest cost score receives the assignment. The brilliance of this scoring system lies in its flexibility to recalculate: every 5 seconds, the algorithm re-evaluates the entire building. If your assigned elevator gets delayed by crowded doors, your request can be seamlessly reassigned to a different cab.
John’s simulation revealed a counter-intuitive finding: under extremely heavy traffic, the classic, simple LOOK rule actually begins to outperform complex algorithms like RSR. Simple rules also dominate in smaller buildings with fewer shafts. “Sometimes keeping things simple works better”—this straightforward insight stands out as one of the most valuable takeaways from the analysis.
Destination Dispatch: More Information, Slower Service?
In recent years, high-end office buildings have popularized destination dispatch: before entering the elevator bank, passengers select their destination floor on a lobby touchscreen, which instructs them, for instance, to “Board Car 3.” It sounds superior on paper: if the system knows everyone’s exact destination in advance, surely it can optimize routing far better?
The simulation results proved quite the opposite: in the vast majority of scenarios, destination dispatch yields worse average wait times than traditional up/down call buttons. The only scenario where destination dispatch wins is in supertall skyscrapers operating large banks of 8 or more elevators. The reason? The real-time flexibility of re-optimizing every 5 seconds is locked away the moment the screen orders you to wait for a specific cab. 30 seconds after you touch the screen, traffic conditions across the building may change, but the system can no longer revise its commitment.
Engineers on Lobsters chimed in with real-world anecdotes. User vbernat noted that destination dispatch requires every passenger to conscientiously register their floor on the screen so the controller can estimate cab capacity. Impatient users frequently tap the screen multiple times, causing two separate elevators to arrive at the same floor. mitsuhiko (creator of the Flask framework) added that in practice, passengers boarding the wrong elevator or missing their assigned car are common occurrences. Some users noted positive experiences when integrated with keycards—swiping instantly assigns a car, enabling frictionless morning rushes. But the trade-off is often waiting several minutes for down trips, as the system allocates nearly all its resources to solving the office building’s most painful peak hour.
This points to a vital lesson: giving a system more data does not guarantee it can utilize that data effectively. A system’s global optimum frequently conflicts with an individual’s desire for an immediate arrival. In the eyes of a dispatcher algorithm, your individual minute and the combined minutes of hundreds of building occupants are very different assets.
Why Waiting Feels Endless: The Psychology of Waiting
Finally, elevator manufacturers discovered decades ago that “perceived wait time” matters just as much as actual wait time. Psychological research indicates that the more bored a person feels while waiting, the slower time appears to pass. A classic architectural remedy was placing large mirrors next to elevator banks—a trick adopted by office managers with noticeable success. Half of your impatience while waiting for an elevator stems from the algorithm, but the other half is generated by your own brain.
There is also a perplexing phenomenon: since elevators travel up and down equal numbers of times, why does it always feel like the car is traveling in the opposite direction when you arrive? Part of the answer lies in peak-hour traffic dynamics: fully loaded elevators bypass intermediate floors without stopping when they reach capacity. Your memory selectively retains vivid impressions of crowded cabs speeding past you.
Returning to our original question: Did the elevator hear your button press? Yes, it did. It is simply evaluating hundreds of destinations, load capacities, energy limits, and fairness constraints every 5 seconds. Next time you wait for an elevator and it heads elsewhere first, think of it as an algorithm working through global optimization: on its ledger, it balances your single minute against the collective time of everyone in the building.
Reference Links:
- John Allsopp: Elevators (Interactive Guide)
- Lobsters Discussion (s/jxqf1w/elevators)
- Wikipedia: Elevator algorithm
- Signal v. Noise: Defining the problem of elevator waiting times
- Scientific American: The reason why elevators feel slow