AJAX / Reverse AJAX: polling or clicking?

Studied a ton on AJAX because I am making a real-time application from Javascript and PHP. It should be updated without refreshing the page and in real time.

I tried polling the server using setInterval (), but for this to be fast, I had to have it every second. However, it seems to use a ton of bandwidth. However, it works, and I have a plan with my hosting provider for "unlimited bandwidth." This seems like a lot of stress on the site, although I wanted to use Push technology.

Learning how to configure Push was extremely difficult. From what I was able to figure out, you need to host some type of push or comet server. I also looked into websockets, but there you also had to place it yourself. I don’t understand how to do this when I do not have a server computer, and there is no documentation about this on my site of hosting providers.

Do you have a host server host provider? Is there a way to get the server without hosting it? This seems like a much better poll choice, but at the same time it seems very confusing.

+6
source share
1 answer

Do you have a host server host provider? Is there a way to get the server without hosting it? This seems like a much better poll choice, but at the same time it seems very confusing.

Yes, I work for Pusher who offer such a service. You can see the quick start guide here . There are other real-time hosting services that you could read.

I also recommend that you take a look at:

My opinion, expressed in the first link, is that PHP is not a good technology for real-time web applications. It is best to have either different components that you use as your real-time web infrastructure. It should be either a self-configuring or hosted solution, such as the Pusher for which I work. What for? PHP + Apache was not created to support long-term connections. There are standalone WebSocket solutions in PHP, but you are 80% likely to use Apache and 20% nginx, which do not yet support WebSockets (but soon). Even then, I'm not sure how they will integrate with the standard PHP request / response request stream.

+4
source

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


All Articles