← ELI5 中文
GOT IT AT A GLANCE

The line
that never
hangs up

For people who have never heard of it · why some messages
arrive instantly and others take seconds
No. 5Inside Computers & the InternetPart 3 of 20
1

In one line

A normal web page works like "you ask, it answers." This one is a phone call that stays on: whoever has news just speaks up.

It's called a WebSocket. The name doesn't matter. What matters is that the line never hangs up.

2

How is it
different?

BEFORE
Every few seconds,
ask: "Anything new?"
Like sending an assistant to knock on the kitchen door every five seconds and ask. Even when there is nothing new, he has to run. Out of a hundred trips, ninety-nine may be wasted, and when a real job shows up you may wait a full round before hearing about it.
NOW
The line stays open.
Whoever has news shouts.
No asking, no running. The moment something arrives, the other end speaks and this end hears it right away. You save ninety-nine wasted trips, and "wait up to five seconds" becomes "rings as soon as it happens."

Put simply: one is running over again and again to ask, the other is keeping the phone line open.

3

How does
it work?

① Knock firstThe first step is just like opening any web page: this side knocks, that side opens the door.
② Agree not to hang upOnce the door is open, both sides agree: "Let's keep this line open." From that moment it is no longer question and answer.
③ Whoever has news speaksEither end can speak first, without waiting to be asked. This is the biggest difference from the old way.
④ Redial when it dropsLines always drop: switching WiFi, stepping into an elevator, a machine restarting. So it has to notice the drop and redial by itself, with no human involved.
4

You use it daily
without noticing

Chat messagesYour phone buzzes the moment they send it
Stock prices, scoresNumbers tick by themselves, no refresh
Kitchen ticket printerAn order is placed up front, paper comes out here
Kitchen screenNo refresh button, new orders just pop up
Shared documentsThey type a letter, it appears on yours
Remote switchesTap your phone, the light turns on over there

Whenever something on screen changes by itself without you touching it, there is probably a line like this open underneath.

5

Sometimes
it isn't worth it

An open line has to be kept up Both ends must keep someone waiting by the phone the whole time, and with lots of machines and lots of connections that cost adds up.

It also doesn't promise never to drop: an elevator, a network switch, a restart, and it's gone. So the sensible approach is: use the line while it's up, and keep a plain old backup for when it drops. Don't bet everything on it.

If something only needs checking "once every few hours," plain question and answer is simpler. No need for this.
So what did it actually change?
From "I ask every five seconds and may wait five seconds to find out"
to "the moment it happens, the other side shouts to me."
The difference isn't just faster. It's whether anyone has to keep asking at all.
UP NEXT

GitHub, Explained

The whole toolkit: repos, commits, branches, pull requests, green squares. Treat it as save files in a video game and most of the jargon makes sense.

No. 6 · 5 minKeep going →
← Back to ELI5