I was wondering how to make the server send events to the browser(client) when database is updated? Google and facebook have it with their chat systems but I couldn't really understand how they work because after the page was sent, the connection is terminated. So how can I set up something that will receive data on database update? Thanks in advance, Astrazone
Lets think about it for a sec... Facebook has 750,000,000 users and 50% are active all the time, so its 375,000,000 users that need to send a request about every second no server in the world can handle it, 22500000000 requests per minute. And I read about it somewhere that they are using something that can receive data from the server like this http://dev.w3.org/html5/eventsource/. Did anyone ever used it? because I cant understand what do I need to use it. Update : I also found this, but I have no idea how to set it up and what do I need for it. looking for good advice about all of this
Yes, your right that can't be handled by a single server but Facebook has multiple servers, each server handle requests on a certain number of users. That's why it can handle those millions of users. On to your first question, checking database statuses like in chat are constantly checked with a certain interval. Sometimes this checking is done using Flash instead of Javascript intervals because it takes a big load to the browser. Flash will then call a certain javascript function to tell the browser that there's an update in the chat.
I think that I am more interested in something like WebSync or CometD. But I dont know how to install CometD and the instructions aren't helping...
The only way to do this from server side is to allow connections from the server to the client and have a port listening on the client. This would require opening firewalls etc.
I agree with you Farbyte, but I think that a server application would be faster than simply doing an AJAX request every second. I just need a simple guide on how to set it up on my server/XAMPP.