How fast can I interrogate AJAX?

Say I'm updating some data on a page using Ajax. I need to call it by timer, so if the user is sitting on the page, he will continue to update. What is a reasonable rate for polling to try to maintain "real time" without starting up the CPU or preventing it in any other noticeable way?

+4
source share
1 answer

If you really want to maintain this level of sensation in real time, I highly recommend you check out Comet . Comet - also known as Reverse Ajax - enables client-side JavaScript to open a connection to the server, and the server maintains this connection until it is ready to send a response / update to the client.

This is often used in chat applications, and there are chat demos and other comet demons that demonstrate the concept.

If you poll for more than 10 seconds, you will be wasting bandwidth and CPU cycles. The overhead of opening and closing a connection and the load on your server will be intense.

+2
source

Source: https://habr.com/ru/post/1338048/


All Articles