I need to create a little AJAX chat in my web application and I am dealing with the problem of real-time communication between the javascript client and the PHP server. I want my js client to be able to detect new messages from the server faster. My first idea was to create an AJAX request, for example, every 5 seconds. to see if there are new posts. However, I'm not sure what will happen if my application will use, for example, 1000 people, it should be a huge load for Apache httpd. I also know about a method called "long polling", but when I tried locally on my server, I completely knocked down my Apache (I read an article about apache problems and long polling). The next way I know about is WebSocket. However, is it true that I have to open a port on a web server in order to use it? Because on regular web hosting, I cannot do this, and I cannot change any Apache / PHP settings on my hosting. Do you have any suggestions for solving it?
Thank you and sorry my English, please, I'm not native.
source share