Search⌘ K

Predecessor to WebSockets

Explore the role of long polling in real-time web applications as a viable alternative to WebSockets. Understand its operation, advantages for load balancing and poor network conditions, and limitations affecting performance and scalability. Gain insight into how Phoenix supports both long polling and WebSocket communication for adaptable application design.

Long polling, a real-time alternative

WebSocket is not the only real-time communication technology used in your applications. We may have restrictions in our application’s environment that prevent using a WebSocket, such as having very inconsistent client connectivity due to our application’s user profile. Since this course was published, there may even be a newly emerged technology that provides even better two-way web communication. It is crucial for our application maintenance that we do not design it solely around WebSocket usage.

Note: We have a WebSocket-powered application, not a WebSocket application.

A less efficient but still viable real-time communication layer is HTTP long polling. Phoenix ships with long polling support out-of-the-box, which means we can quickly add it to our server when necessary. We can even run WebSockets in tandem with HTTP long polling. Let’s look at how long polling works, where it’s helpful, and where it can ...