What is Short polling and what problems do we have with it?

Technology CommunityCategory: WebSocketsWhat is Short polling and what problems do we have with it?
VietMX Staff asked 3 years ago

Short Polling or Ajax Polling is a technique when we have the client ping the server repeatedly, say, every 500ms (or over some fixed delay). That way, you get new data every 500ms:

  1. client requests a webpage from a server using regular HTTP.
  2. The client receives the requested webpage and executes the JavaScript on the page which requests a file from the server at regular intervals (e.g. 0.5 seconds).
  3. The server calculates each response and sends it back, just like normal HTTP traffic.

There are a few obvious downsides to this:

  • there’s a 500ms delay,
  • it consumes server resources with a barrage of requests, and most requests will return empty if the data isn’t frequently updated.