Short vs Long Polling vs Web Sockets
10 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the primary purpose of short polling, long polling, and web sockets?

  • To encrypt data transmissions.
  • To compile code.
  • To manage server infrastructure.
  • To retrieve data. (correct)

In the context of these techniques, what do 'client' and 'resource' typically represent?

  • User interface and database, respectively.
  • Frontend application and backend server, respectively. (correct)
  • Web browser and search engine, respectively.
  • Operating system and hardware, respectively.

What is the distinguishing characteristic of short polling?

  • The server queues requests.
  • The client continuously makes calls to the server. (correct)
  • The client maintains a persistent connection.
  • The server pushes updates to the client.

In short polling, what are the two possible responses from the resource server?

<p>Empty payload or data object. (C)</p> Signup and view all the answers

What is a major disadvantage of using short polling?

<p>It continuously uses up resources. (C)</p> Signup and view all the answers

How does long polling differ from short polling?

<p>The server keeps the connection open until data is available. (B)</p> Signup and view all the answers

In long polling, what happens if the resource server doesn't have data when the client makes a request?

<p>It keeps the connection open. (D)</p> Signup and view all the answers

What is an advantage of long polling over short polling?

<p>It utilizes less resources when there is no new data. (D)</p> Signup and view all the answers

Which technique involves the client initiating a request to the resource?

<p>Both short polling and long polling. (C)</p> Signup and view all the answers

What is a potential drawback of long polling?

<p>It can lead to increased server load due to open connections. (A)</p> Signup and view all the answers

Flashcards

Short Polling

A technique where the client continuously makes calls to the resource server to retrieve data, waiting a short time between each call.

Long Polling

A technique where the client makes a request to the resource, and the resource keeps the connection open until data is available, then responds.

Disadvantage of Short Polling

Client repeatedly makes calls to the resource server, wasting resources even when no data is available.

Potential Drawback of Long Polling

The connection between the client and resource is held open, potentially tying up server resources

Signup and view all the flashcards

Study Notes

  • Short polling, long polling, and web sockets are techniques for retrieving data.

Short Polling

  • A client, such as a JavaScript application, continuously makes calls to a resource server, like a Node.js backend, to retrieve data.
  • The resource server responds with either an empty payload or a data object.
  • After receiving the response, the client waits for a short interval (e.g., 3 seconds) and repeats the process.
  • Drawback: the client continuously uses up resources on both its side and the resource server's side.

Long Polling

  • The client makes a request to the resource server.
  • If the resource server has data, it responds immediately.
  • If the resource server doesn't have data, it keeps the connection open until data arrives.
  • Once data is available, the resource server sends it back to the client through the existing connection.
  • Advantage: avoids wasting cycles between the client and the resource server.
  • One call is made, and the resource responds when data arrives.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Description

Client-server communication techniques compared. Short polling continuously requests data, while long polling waits for data availability. WebSockets enable persistent, bidirectional communication, reducing resource waste.

More Like This

Use Quizgecko on...
Browser
Browser