Alex Rivera | Logout

PHP - AJAX jQuery Server "Push" System

Asked 2012-02-04T04:06:24.297
8

I am creating a web app that requires a live notification system. How would I set up my server to pull data from a mySQL database and then push it to the browser. I have absolutely NO idea how to do this. If anybody can help, it would be much appreciated! Thank you so much!

EDIT: I should probably be more specific, I am pulling data as in XYZ recently created an account, XZY recently ... Thanks so much!

Edit
Report

1 Answer

7

You can create a push notification service for your website utilizing websockets and graceful degradation to a long polling fallback for browsers that don't support websockets. This does require a healthy amount of technical/programming knowledge.

Some good resources for this are: http://socket.io (which uses a node.js backend for the web sockets and handles degradation) http://pusherapp.com (a commercial solution if you don't want to roll and maintain your own service)

For a list of browsers that support websockets, you can search for "caniuse" -- which provides great details to features supported by browser versions

Note: For multi-million user applications like Facebook, I would assume they've weighed the advantages of running websockets for 50+ million simultaneous users and concluded that keeping data consistent across all the nodes connected to the millions of sockets would be too much. I can imagine it would be a logic nightmare to do that on a socket system instead of a basic action sql-like infrastructure. I can't speak on their behalf though, this is simply my assumption. However, you'd be surprised how many sites have been using push and polling systems lately :)

answered 2012-03-28T19:44:23.340

Your Answer