Reputation: 63
I'm currently coding a quite standard Apache/PHP/mySQL website using Symfony2 and considering using Node and socket.io for a special need : a notification bar. Nothing too fancy, a notification is lit when you've got a new friend request, a new mail...
I'm not too fond of periodically requesting my DB from an ajax loop; I'd like this feature to be fully scalable and to have a minimal footprint.
Thus I'm considering having a single periodical request on my DB, server-side, feeding my list of open sockets in Node with a push notification to each concerned user.
Am I going the right way ?
Cheers
Upvotes: 6
Views: 730
Reputation: 27247
You're definitely on the right track, but I suggest putting the notification stuff in your app, rather than polling your database. For example of friend request, do it when the friend request is sent:
function send_friend_request($from, $to) {
$mysqli->whatever you do with that;
send_notification($to, 'You have a friend request!');
}
where send_notification
is a method that sends a POST request to your nodejs server. Your nodejs server receives the POST and forwards the message to whatever is listening to $to
.
Upvotes: 3