The Internet: Queuing
The Internet: Queuing
If you went to the midnight premier of How the Shoe Falls: A Documentary at your favorite indie theater, you know what being stuck in a queue for hours—literally hours—feels like.
(Was that a marketing move to make people buy official shoes from the documentary? Or just a coincidence?)
In fact, if you’re British, you'd have already called that line a queue, so cheers.
Let's step back for a minute and think about what that whole queue thing is. A queue could be a place to wait for the highest-rated documentary of the month, or it could be a type of data structure. If you hear about queues in the computer science sense, you're probably dealing with a data structure—a place that holds information for you in a program.
Queues work as First-In-First-Out (or FIFO) structures. If you want to, you could also think of them as first come, first served. If you show up before anyone else to the movie that reviewers call "definitely not the worst movie out there about shoes," you better hope you get first dibs at seating.
(Even if you're the only one in the theater, it's worth it.)
Sound intuitive? It is. Still, some data structures work the opposite way. For example, a stack of dishes would be a Last-In-First-Out (LIFO) structure because you have to add and take dishes from the top if you don't want to end up with a floor full of broken glass. Computer science has these guys in digital form, too, and they're called—wait for it—stacks.
Okay, but back to the internet for a minute. Servers—which are giant computers that hold web data—are basically like the employee at the ticket counter of your movie theater. They have plenty to deal with—like whether or not that bulgy sweater is actually hiding a bag of Twizzlers or if that customer just asked for a 3-D screening—meaning that the queue fills up quickly if they have even a minor issue.
Luckily for us (and them), servers don’t work alone on the internet.
Just like how multiple ticket counters keep customers and their extra-large and suspicious sweaters from piling up and causing a ruckus (most of the time), queues help keep the internet afloat by scheduling when data passes through the different parts of its infrastructure—when routers redirect packets, or when servers handle certain requests. Thanks to them, that important content gets where it needs to go without overworking the system.
That means less time waiting and more time watching the other shoe fall. Now in 3D!