SlideShare a Scribd company logo
1 of 13
BUILDING NOTIFICATION, FEEDING
SYSTEM USE NODE.JS + REDIS




                        Lê Việt Đức
                        19/04/2012
Content
•   Intro
•   Design Systems
•   Redis Replication
•   Demo
•   Discussion
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
Node.js Script
client1 = 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);
 });
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));
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
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
Redis Replication
Redis replication is a very simple to use and configure master-slave replication
that allows slave Redis servers to be exact copies of master servers
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 will
continue 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 first
synchronization it can reply to queries using the old version of the data set, assuming you
configured Redis to do so in redis.conf.
•Replications can be used both for scalability, in order to have multiple slaves for read-only
queries.
Configuration


   slaveof 192.168.1.1 6379

   masterauth <password>
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
Discussion
QUESTIONS?

More Related Content

Viewers also liked

Notifications - Building a transparent system
Notifications - Building a transparent systemNotifications - Building a transparent system
Notifications - Building a transparent system
João Lopes
 
Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN App
MongoDB
 

Viewers also liked (20)

Going realtime with Socket.IO
Going realtime with Socket.IOGoing realtime with Socket.IO
Going realtime with Socket.IO
 
Going real time with Socket.io
Going real time with Socket.ioGoing real time with Socket.io
Going real time with Socket.io
 
Websocket + Redis pubsub
Websocket + Redis pubsubWebsocket + Redis pubsub
Websocket + Redis pubsub
 
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, InuitReal Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
 
Learn node.js by building projects
Learn node.js by building projectsLearn node.js by building projects
Learn node.js by building projects
 
Notifications - Building a transparent system
Notifications - Building a transparent systemNotifications - Building a transparent system
Notifications - Building a transparent system
 
Socket io - JSZurich
Socket io - JSZurichSocket io - JSZurich
Socket io - JSZurich
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
 
Node js oc meetup 2 socket io intro
Node js oc meetup 2 socket io introNode js oc meetup 2 socket io intro
Node js oc meetup 2 socket io intro
 
Realtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIORealtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIO
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tdd
 
tea
teatea
tea
 
Data visualization
Data visualizationData visualization
Data visualization
 
Transforming WebSockets
Transforming WebSocketsTransforming WebSockets
Transforming WebSockets
 
Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN App
 
Socket.io (part 1)
Socket.io (part 1)Socket.io (part 1)
Socket.io (part 1)
 
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
 
laravel websocket(use redis pubsub) [Laravel meetup tokyo]
laravel websocket(use redis pubsub) [Laravel meetup tokyo]laravel websocket(use redis pubsub) [Laravel meetup tokyo]
laravel websocket(use redis pubsub) [Laravel meetup tokyo]
 
Socket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time ApplicationSocket.IO - Alternative Ways for Real-time Application
Socket.IO - Alternative Ways for Real-time Application
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 

Similar to Building notification system in NodeJS + Redis

Cloud Foundry Open Tour China
Cloud Foundry Open Tour ChinaCloud Foundry Open Tour China
Cloud Foundry Open Tour China
marklucovsky
 
Supporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStackSupporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStack
Donal Lafferty
 
Developing polyglot persistence applications (SpringOne India 2012)
Developing polyglot persistence applications (SpringOne India 2012)Developing polyglot persistence applications (SpringOne India 2012)
Developing polyglot persistence applications (SpringOne India 2012)
Chris Richardson
 
Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)
marklucovsky
 
Developing polyglot persistence applications (SpringOne China 2012)
Developing polyglot persistence applications (SpringOne China 2012)Developing polyglot persistence applications (SpringOne China 2012)
Developing polyglot persistence applications (SpringOne China 2012)
Chris Richardson
 
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using NdbjWriting Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
MySQLConference
 
Handling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeperHandling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeper
ryanlecompte
 

Similar to Building notification system in NodeJS + Redis (20)

Service Discovery & Load-Balancing under Docker 1.12.0 @ Docker Meetup #22
Service Discovery & Load-Balancing under Docker 1.12.0 @ Docker Meetup #22Service Discovery & Load-Balancing under Docker 1.12.0 @ Docker Meetup #22
Service Discovery & Load-Balancing under Docker 1.12.0 @ Docker Meetup #22
 
Cloud Foundry Open Tour China
Cloud Foundry Open Tour ChinaCloud Foundry Open Tour China
Cloud Foundry Open Tour China
 
Supporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStackSupporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStack
 
Developing polyglot persistence applications (SpringOne India 2012)
Developing polyglot persistence applications (SpringOne India 2012)Developing polyglot persistence applications (SpringOne India 2012)
Developing polyglot persistence applications (SpringOne India 2012)
 
QEWD Update
QEWD UpdateQEWD Update
QEWD Update
 
Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)
 
Developing polyglot persistence applications (SpringOne China 2012)
Developing polyglot persistence applications (SpringOne China 2012)Developing polyglot persistence applications (SpringOne China 2012)
Developing polyglot persistence applications (SpringOne China 2012)
 
Developing polyglot persistence applications #javaone 2012
Developing polyglot persistence applications  #javaone 2012Developing polyglot persistence applications  #javaone 2012
Developing polyglot persistence applications #javaone 2012
 
Redis Day TLV 2018 - Redis cluster manager
Redis Day TLV 2018 - Redis cluster managerRedis Day TLV 2018 - Redis cluster manager
Redis Day TLV 2018 - Redis cluster manager
 
redis basics
redis basicsredis basics
redis basics
 
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using NdbjWriting Efficient Java Applications For My Sql Cluster Using Ndbj
Writing Efficient Java Applications For My Sql Cluster Using Ndbj
 
IP Virtual Server(IPVS) 101
IP Virtual Server(IPVS) 101IP Virtual Server(IPVS) 101
IP Virtual Server(IPVS) 101
 
Dockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarmDockertaipei 20150528-dockerswarm
Dockertaipei 20150528-dockerswarm
 
Sharding Redis at Flite
Sharding Redis at FliteSharding Redis at Flite
Sharding Redis at Flite
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redis
 
Handling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeperHandling Redis failover with ZooKeeper
Handling Redis failover with ZooKeeper
 
NFS Diagram.pptx
NFS Diagram.pptxNFS Diagram.pptx
NFS Diagram.pptx
 
Orchestrating Redis & K8s Operators
Orchestrating Redis & K8s OperatorsOrchestrating Redis & K8s Operators
Orchestrating Redis & K8s Operators
 
Managing Redis with Kubernetes - Kelsey Hightower, Google
Managing Redis with Kubernetes - Kelsey Hightower, GoogleManaging Redis with Kubernetes - Kelsey Hightower, Google
Managing Redis with Kubernetes - Kelsey Hightower, Google
 
sVirt: Hardening Linux Virtualization with Mandatory Access Control
sVirt: Hardening Linux Virtualization with Mandatory Access ControlsVirt: Hardening Linux Virtualization with Mandatory Access Control
sVirt: Hardening Linux Virtualization with Mandatory Access Control
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Building notification system in NodeJS + Redis

  • 1. BUILDING NOTIFICATION, FEEDING SYSTEM USE NODE.JS + REDIS Lê Việt Đức 19/04/2012
  • 2. Content • Intro • Design Systems • Redis Replication • Demo • Discussion
  • 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. Node.js Script client1 = 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. 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. 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. 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. Redis Replication Redis replication is a very simple to use and configure master-slave replication that allows slave Redis servers to be exact copies of master servers
  • 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 will continue 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 first synchronization it can reply to queries using the old version of the data set, assuming you configured Redis to do so in redis.conf. •Replications can be used both for scalability, in order to have multiple slaves for read-only queries.
  • 10. Configuration slaveof 192.168.1.1 6379 masterauth <password>
  • 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

Editor's Notes

  1. This template can be used as a starter file for presenting training materials in a group setting. Sections Right-click on a slide to add sections. Sections can help to organize your slides or facilitate collaboration between multiple authors. Notes Use the Notes section for delivery notes or to provide additional details for the audience. View these notes in Presentation View during your presentation. Keep in mind the font size (important for accessibility, visibility, videotaping, and online production) Coordinated colors Pay particular attention to the graphs, charts, and text boxes. Consider that attendees will print in black and white or grayscale. Run a test print to make sure your colors work when printed in pure black and white and grayscale. Graphics, tables, and graphs Keep it simple: If possible, use consistent, non-distracting styles and colors. Label all graphs and tables.
  2. Give a brief overview of the presentation. Describe the major focus of the presentation and why it is important. Introduce each of the major topics. To provide a road map for the audience, you can repeat this Overview slide throughout the presentation, highlighting the particular topic you will discuss next.
  3. This is another option for an Overview slides using transitions.
  4. Add slides to each topic section as necessary, including slides with tables, graphs, and images. See next section for sample table, graph, image, and video layouts.
  5. This is another option for an Overview slide.
  6. What will the audience be able to do after this training is complete? Briefly describe each objective how the audience will benefit from this presentation.
  7. Microsoft Engineering Excellence Microsoft Confidential
  8. Use a section header for each of the topics, so there is a clear transition to the audience.
  9. Microsoft Engineering Excellence Microsoft Confidential