Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Building notification system in NodeJS + Redis

7.539 Aufrufe

Veröffentlicht am

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

Building notification system in NodeJS + Redis

  1. 1. BUILDING NOTIFICATION, FEEDINGSYSTEM USE NODE.JS + REDIS Lê Việt Đức 19/04/2012
  2. 2. Content• Intro• Design Systems• Redis Replication• Demo• Discussion
  3. 3. Solution 1 1 node.js thread: ~ 1000 CCU Client 1 Redis->subcribe Play.go.vn Client 2 Redis Server Application Server Node.js Server Client n
  4. 4. Node.js Scriptclient1 = redis.createClient(6379,117.103.196.26); client1.subscribe("notify"); client1.on("message", function (channel, message) { var objmsg = eval(message); nowjs.getGroup(channel).now.receiveNotifyPlaying(objmsg.clientId,ob jmsg.userid,objmsg.name,objmsg.room_notify,objmsg.app_title,objms g.app_url,objmsg.action_title); });
  5. 5. Server Script (PHP) $notify_server = array( host=>117.103.196.20, port => 6381, database => 3 ); $Redis_notify = new Predis_Client($notify_server); $msg = ({"clientId":".time().","userid":".$userid.","name":". $displayname.","room_notify":"notify","app_title":". $title.","app_url":".$link.","action_title":".$action_title."}); $rt = $Redis_notify->publish(array(notify,$msg));
  6. 6. Solution 2 Re dis ->s ub cri be Client 1 Node.js Server Redis->publish() Play.go.vn Client 2 Node.js Server Redis Server Application Server Client n Node.js Server
  7. 7. Solution 3 Redis->subcribe Client 1 Redis Server Node.js Server Redis->subcribe Redis->publish() Play.go.vn Client 2 Node.js Server Redis Server Application Server Client n Node.js Server Redis Server
  8. 8. Redis ReplicationRedis replication is a very simple to use and configure master-slave replicationthat allows slave Redis servers to be exact copies of master servers
  9. 9. Redis Replication•A master can have multiple slaves.•Slaves are able to accept other slaves connections.•Redis replication is non-blocking on the master side, this means that the master willcontinue to serve queries when one or more slaves perform the first synchronization.•Replication is non blocking on the slave side: while the slave is performing the firstsynchronization it can reply to queries using the old version of the data set, assuming youconfigured Redis to do so in redis.conf.•Replications can be used both for scalability, in order to have multiple slaves for read-onlyqueries.
  10. 10. Configuration slaveof 192.168.1.1 6379 masterauth <password>
  11. 11. Solution 4 Redis->subcribe Client 1 Node.js Server Redis Slave Server Redis->subcribe Play.go.vn Redis->publish() Client 2 Node.js Server Redis Slave Server Redis Master Server Application Server Redis Slave Server Client n Node.js Server
  12. 12. Discussion
  13. 13. QUESTIONS?

×