1

I've been searching on the internet about using interval ajax polling for live web pages and I've been using it along with SignalR. Now I always read an article online about using ajax polling for live web pages that there could be an impact on your server or maybe there's a downside effect when using ajax polling if you have heavy traffic on your site and/or when you're polling large data from the database.

If this would be true, I guess my questions are, what are the server impacts that they are talking about that could lead to any downside effect on your site? and how to avoid those server impacts if you choose to use ajax polling for your live web pages?

  • use web sockets instead! – Lucius Oct 15 '15 at 9:20
1

The server impact is simply the request volume. Each time you poll the server, it has to handle the request. If you've got five widgets on your page and each one is polling for updates, that means that each user is generating five requests every second (or whatever your polling interval is). For many (possibly most) applications, this isn't a big deal, unless the requests cause a bottleneck on the server (e.g., if each request triggers a database read). However, if you're writing a commercial app that you hope will be used by thousands of people, it probably isn't a good idea. To mitigate the impact, you could implement some form of request throttling, increasing the polling delay when the system gets busy, but that's going to lead to some complex heuristics on the client side. As @Li Yin Kong suggested, you're better off using something like websockets for periodic updates.

  • So as far as I understand your explanation since I'm expecting to have large audience on my site and by using the interval ajax polling is always poking the data from the database for real time updates so basically there's a downside effect on this. So I just would like to know exactly the downside effect of having this? Like would it end up crashing my website or my browser? What could may possibly happen if the system gets busy? – timmack Oct 15 '15 at 12:46
  • Depends on your environment, but it would be similar to a DDOS attack. The server winds up with so many connections pending that they start to time out, or it starts refusing connections, or (worst case) it runs out of resources and crashes. This article gives some more information, including mitigation techniques. – TMN Oct 15 '15 at 13:09
  • So once the server crashes there's no chance of recovery unless you eliminate your overloading script like the interval ajax polling right? – timmack Oct 15 '15 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.