Podcast
Questions and Answers
In short polling, who initiates the request for data?
In short polling, who initiates the request for data?
- The resource server
- Both client and server simultaneously
- Neither client nor server
- The client (correct)
What is a potential drawback of short polling?
What is a potential drawback of short polling?
- Immediate data delivery
- Efficient use of resources
- Reduced server load
- Continuous resource wastage (correct)
In short polling, what might a resource server respond with if there is no new data?
In short polling, what might a resource server respond with if there is no new data?
- A connection timeout
- A data object
- An error message
- An empty payload (correct)
What is the primary difference between short polling and long polling?
What is the primary difference between short polling and long polling?
In long polling, what happens if the resource server does not have data immediately available when a client requests it?
In long polling, what happens if the resource server does not have data immediately available when a client requests it?
Which polling method is generally more efficient in terms of resource usage when there are long periods without new data?
Which polling method is generally more efficient in terms of resource usage when there are long periods without new data?
What is the role of the 'client' in the context of polling?
What is the role of the 'client' in the context of polling?
What is the role of the 'resource' in the context of polling?
What is the role of the 'resource' in the context of polling?
Which method reduces redundant requests when data updates are infrequent?
Which method reduces redundant requests when data updates are infrequent?
What is a typical interval a client might wait before re-requesting data in short polling?
What is a typical interval a client might wait before re-requesting data in short polling?
Flashcards
Short Polling
Short Polling
Client repeatedly requests data from a resource server, which responds with either an empty payload or the requested data, after which the client waits briefly before repeating the request.
Long Polling
Long Polling
Client makes a request to the resource, which responds immediately if data is available or holds the connection open until data becomes available, then sends the data to the client.
Study Notes
- Short polling, long polling, and web sockets are techniques to retrieve data.
Short Polling
- Involves a client (e.g., JavaScript front end) and a resource (e.g., Node.js back end).
- The client continuously makes calls to the resource server to retrieve data.
- The resource server responds with either an empty payload or a data object.
- After receiving a response, the client waits for a short interval (e.g., 3 seconds) and repeats the process.
- This method is inefficient as the client continuously uses up resources on both ends.
Long Polling
- Similar to short polling, but with a different approach.
- The client makes a request to the resource.
- If the resource has data, it responds immediately.
- If not, it keeps the connection open until data is available.
- Once data arrives, the resource sends it back to the client.
- Advantageous because it avoids wasting cycles, as the resource responds only when data is available.
- It ties up a connection between the client and the resource.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Explore the differences between short polling, long polling, and web sockets. Understand how each technique is used to retrieve data from a resource, and their advantages or disadvantages. Learn how long polling avoids wasting system resources by keeping the connection open.