Podcast
Questions and Answers
Which of the following best describes short polling?
Which of the following best describes short polling?
- The client requests data and the resource keeps the connection open until data is available.
- The resource pushes data to the client whenever there is a change.
- The client opens a continuous connection to the resource.
- The client makes continuous requests to the resource at a specified interval. (correct)
In which scenario is short polling considered acceptable?
In which scenario is short polling considered acceptable?
- When the server needs to push data to the client immediately.
- When low latency is required.
- During rapid application prototyping. (correct)
- When there is a high volume of data being transferred.
How does long polling work?
How does long polling work?
- The client maintains a constant open connection.
- The client requests data and the resource responds immediately if it has data or holds the request open. (correct)
- The client sends data to the resource at fixed intervals.
- The resource immediately sends data to the client.
Which characteristic makes long polling a good choice in many circumstances?
Which characteristic makes long polling a good choice in many circumstances?
How do web sockets function?
How do web sockets function?
In what situation are web sockets particularly useful?
In what situation are web sockets particularly useful?
Which of the following is a drawback of using web sockets?
Which of the following is a drawback of using web sockets?
In the context of data transmission, what is a 'resource'?
In the context of data transmission, what is a 'resource'?
Which method gives the resource server the most control over when to send data to the client?
Which method gives the resource server the most control over when to send data to the client?
Which of the following is MOST important for a webchat application?
Which of the following is MOST important for a webchat application?
Flashcards
Short Polling
Short Polling
The client continuously makes calls to the resource at a specified interval, and the resource responds every time, repeating on short cycles.
Long Polling
Long Polling
Client initiates a request; the resource keeps the connection open until data is available, then responds. If data exists, it responds right away.
Web Sockets
Web Sockets
A persistent connection is established between the client and resource, allowing bidirectional data flow at any time.
Why Short Polling is Bad
Why Short Polling is Bad
Signup and view all the flashcards
When to Use Long Polling
When to Use Long Polling
Signup and view all the flashcards
When to Use Web Sockets
When to Use Web Sockets
Signup and view all the flashcards
Study Notes
- Web sockets are a slight variation of long polling.
- Web sockets open a highway between the client and the resource through a connection.
- With web sockets, the resource server is in complete control.
- Data events can come into the resource, and the resource can push events back into the client at any time.
- There is a bidirectional relationship where data can pass freely between the resource and the client.
- Web sockets are advantageous because the resource is in control and can push data as it sees fit.
- A disadvantage of web sockets is that a connection is being used between the client and the resource at all times.
Comparison of Techniques
- Short Polling:
- The client continuously makes calls to the resource at a specified interval.
- The resource responds every time.
- Repeats on very short cycles.
- Long Polling:
- The client initiates a request to the resource.
- If the resource doesn't have data, it keeps the connection open to respond later.
- If the resource has data, it responds right away.
- Web Sockets:
- A connection is established between the client and the resource.
- As data changes on the back end, that data gets pushed into the client at the resource's discretion.
When to Use Each Technique
- Short Polling:
- Almost always a bad idea for passing data between a client and a resource at any kind of regular interval.
- Acceptable if you're trying to prototype an application quickly.
- Acceptable if there is a long delay between network calls.
- Long Polling:
- Generally a good idea to use.
- Works well when there's very little traffic and can scale up quickly when traffic gets high.
- A good choice in most circumstances.
- Web Sockets:
- Useful in specific circumstances.
- If you have low latency requirements between your client and resource.
- If you have a webchat application with many users.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Explore web sockets and polling techniques for real-time data transfer. Understand the advantages and disadvantages of short polling, long polling, and web sockets. Learn how each method handles client-server communication and data updates.