xwinus
xwinus

Reputation: 916

Best way for real-time HTML/AJAX/PHP chat

I have to create a little AJAX chat in my web application and I'm dealing with problem of real-time communication between javascript client and PHP server. I want my js client to be able to catch new messages from the server as quick as possible. My first idea was to create AJAX request for example each 5 sec. to see whether there are new messages. However, I'm not sure what happens if my application use for example 1000 people, it must be huge load to Apache httpd. I also know about technique called 'long-polling' request, but when I tried that locally on my server, I've completely shooted down my Apache (I've read sth about problems with apache and long-polling). The next way I know about is WebSocket. However, is it true that I have to be able to open port on webserver to use it? Because on regular web hosting, I thing it's not possible and I cant change any Apache/PHP settings on my hosting. Do you have any suggestions how to solve it?

Thank you and excuse my english please, I'm not native.

Upvotes: 4

Views: 25909

Answers (2)

user2081972
user2081972

Reputation:

It is real time comments system. You can use it as chat Real time chat

Upvotes: 3

George Violaris
George Violaris

Reputation: 315

You should use php comet and push from the server instead of doing requests.

Check out this question also

Upvotes: 0

Related Questions