Grokking the System Design Interview
Vote

0% completed

Long-Polling vs WebSockets vs Server-Sent Events

HTTP was built for one direction. The client asks, the server answers, and the exchange ends. That fits a user who clicks a link and waits for a page.

It does not fit a different question. Something happened on the server. A message arrived, a price moved, a job finished. How does the server tell the client?

The server cannot start the conversation. It has no open connection to the browser. Every option below is a way to keep a connection open, or to ask often enough that the delay is small.

This lesson covers four options: short polling, long polling, WebSockets, and server-sent events.

.....

.....

.....

Like the course? Get enrolled and start learning!
Andre Hildinger

Andre Hildinger

· 5 months ago

"Polling is a standard technique used by the vast majority of AJAX applications"

I don't think this is true at all.

Most web applications don't perform any polling or other continuous data-receiving tasks. They are mostly reactive apps. User does something; a request is sent; the browser/JS code acts on the response; the end.

T

thomhickey

· 2 years ago

Does anyone really call them ajax requests anymore?

D

dev.interview.93

· 2 years ago

Added diagrams are irrelevant and serve no purpose in understanding

P

pushkar312

· 3 years ago

It would be more beneficial for the readers to add any real-world examples for each concept. For examples ride sharing apps vs chat application like WhatsApp etc.

E

E

· 4 years ago

On #3. "The server sends... on the open request". This should be connection, right?

Reading Progress

0%