I have a website that is implemented in php/mysql, and is hosted at hostmonster (shared hosting).
I am planning to incorporate a chat feature in my website, that enables users to chat with each other. There are approx. 1000 users on my site. Currently, i have implemented an ajax strategy that sends requests to the server on a periodical basis (say, every 4 seconds) to get the json response about online users and messages.
This is the sample code that sends requests:
var timer, delay = 4000;
timer = setInterval(function(){
$.ajax({
type: 'POST',
url: 'update.php?user_id=2',
success: function(html){
$('.chat_messages').append(html);
}
});
}, delay);
But as i see, more the number of users, more the requests for every 4 seconds, and more burden on Apache server and database to deliver the response.
So i am planning for an alternate solution, that has no overhead on the server. I have heard about few servers like APE, Nginx, Node.js, StreamHub that use COMET/reverse ajax technology to serve the requests, and are efficient for my purpose.
But the problem is that, i dont have permission to install a third party server on my hostmonster cpanel. Is there any other way around, like HTML5 web sockets?
EDIT: By the way, i am also interested to rebuild my application on Java, if there is a viable solution.