System Design Fundamentals

0% completed

Difference Between Long-Polling, WebSockets, and Server-Sent Events

Long-Polling, WebSockets, and Server-Sent Events are popular communication protocols between a client like a web browser and a web server. First, let’s start with understanding what a standard HTTP web request looks like. Following are a sequence of events for regular HTTP request:

  1. The client opens a connection and requests data from the server.
  2. The server calculates the response.
  3. The server sends the response back to the client on the opened request.

Ajax Polling

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

.....

.....

.....

Like the course? Get enrolled and start learning!
H

heybenross

· 3 years ago

When should each be used? What are the pros and cons of each?

Show 2 replies
D

dominikcubic

· 2 years ago

In this description of AJAX polling, is the "requested webpage" the same as the "Client"?

  1. Client requests data from a server using regular HTTP.
  2. The requested webpage opens a connection to the server.
  3. The server sends the data to the client whenever there's new information available.
Vu Tong

Vu Tong

· 2 months ago

It's worth to mention that to avoid performance impact, the server should have some kind of asynchronous processing for incoming requests. If the server uses a traditional thread-per-request model and every client holds a long-lived connection, that will hurt the overall performance.

Show 1 reply