The best way to chat HTML / AJAX / PHP in real time

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.

+4
source share
2 answers

This is a real-time comment system. You can use it as a live chat.

+3
source

You should use php compilation and click from server instead of executing requests.

Check this question and

0
source

All Articles