Copy
You're reading the Ruby/Rails performance newsletter by Speedshop.

Looking for an audit of the perf of your Rails app? I've partnered with Ombu Labs to do do just that.

このメールマガジンは、日本語でも配信しています。過去のメールはこちらです

If queue times are getting long, consider optimizing the 95th percentile.

I had the wildest experience on an airplane last week.

I was flying domestic in Japan from Tokyo to Sapporo, on the northern island of Hokkaido. It's a very short flight, something like 90 minutes.

When boarding, I definitely noticed that we seemed to spend less time boarding than usual, but I wasn't sure why. I did notice that the boarding groups seemed to follow our actual position on the plane, rather than loyalty status or other arbitrary groupings, which follows CGP Grey's excellent recommendations on "how to board a plane fast".

But what really shocked me was how quickly we deboarded. I estimate that the time between the doors opening and everyone being off the plane was no less than 90 seconds. How could this be possible?

First, realize that boarding or unboarding (deboarding? deplaning? whatever) is essentially a queue. You have 200+ people that need to get through 1 small opening (the door). Sitting in an aluminum tube is not very fun, and the airplane has places to go, so both processes should happen quickly.

But why is it that on a U.S. domestic flight it takes upwards of 10 to 15 minutes to completely deboard everyone?

The aisles of my flight weren't wider than American ones. We had the same basic problem of getting 200 people through one small door.

I noticed two critical differences on my Japanese flight:

1. Almost no one had bags in the overhead bin.
2. People who had special needs (bags in the overhead bin, children, old, etc) waited until everyone else got off.

It takes every person roughly the same amount of time to walk the length of the airplane's aisles. And, when you're deboarding, we don't have to worry about what order people leave in, since people from the window seats can't climb over the people in the aisle seats to try to leave first. So, that means that any delays to deboarding occur when the entire queue is stopped because someone enters the queue (enters the aisle). 

Why did no one have bags in the overhead bin? The airline I was taking (Airdo) had an interesting baggage policy quite unlike most low-cost carriers: unlimited checked bags under 45 lbs. Yes, that's right, you could check as many bags as you wished, as long as they weighed under 45 lbs! So, that's what everyone did, and the overhead bins were again used for coats and laptop bags, but mostly they were just empty.

The second point is more cultural, I think - Japanese people are generally more content to sit and wait rather than inconvenience everyone else around them. It's the positive side of the old saying: "the nail that sticks out gets hammered".

Both of these changes had one major effect: the 95th percentile time of how long it takes 1 person to enter the queue to get off the plane was greatly reduced, probably to the point where it was only slightly longer than the median/50th percentile.

Queueing systems are highly sensitive to 95th percentiles. You've probably also seen this in other queues: the one person in front with a strange situation needs extra help and spends 30 minutes clogging up the system, so the line gets extremely long behind them. This result has been proven mathematically in queueing theory for quite some time. 

Sometimes in a queueing system, like Sidekiq, or our web application deployment, we can't do too much about the the median. That might feel like too much work, since by definition you need to change the most common scenarios, which are often the most complicated and difficult to change. Focusing on the 95th percentile can often give us the same result that we want, but allow us to focus only on a few outliers.

Until next time,

-Nate
You can share this email with this permalink: https://mailchi.mp/railsspeed/to-reduce-queues-reduce-the-95th-percentile?e=[UNIQID]

Copyright © 2023 Nate Berkopec, All rights reserved.


Want to change how you receive these emails?
You can update your preferences or unsubscribe from this list.