This website uses cookies and similar technologies to understand visitors' experiences. By continuing to use this website, you accept our use of cookies and similar technologies,Terms of Use, and Privacy Policy.

Jul 13 2011 - 06:59 PM
The Architecture of Real-Time Notification System
As a member of Vialogues team, I am more than happy to see the release of the new Vialogues. Many thanks to everyone who help us in developing this new version! I am working with Pranav on the notification system of Vialogues. In this version, new notices occur when the page is reloaded. For next version, we will enable real-time notification so that users no longer need to reload the page. This real-time technology can also be used in other scenarios of our products, e.g. the real-time update of Vialogues' comment list, making our system more interactive. In this blog, I will briefly introduce the architecture and related technologies of the system. 1. Introduction Real-time notification system enable the user to receive notices simultaneously when certain event occurs. To implement this functionality, we need to maintain a connection between server and each client. The server will use these connections to push notices to the clients immediately when the event occurs. 2. Technologies Our system is based on Node.js for both the server side and the client side. We chose this framework because it is simple and provides abundant modules to support all the functionalities we anticipated. The Node.js modules we may use include: Socket IO, connect, nodejitsu/node-http-proxy, node-mysql, and node-websocket-server. The most interesting module is Socket IO. It enables user to define a socket without caring about browser support and HTML version. The API is neat and seamlessly embedded in Node.js structure. The Node.js server is isolated from existing server Apache. We can either use proxy (node-http-proxy) to direct http and ws requests to different ports, or simply construct Node.js on another IP address. 3. Structure In this section, I will introduce the new server and client of this real-time notification system. 1) Server The server maintains a connection with each authenticated client, and a connection table for each connected user. A connection is set up when a webpage is initialized, and destroyed when a web page is closed. The server monitors the notice table of the database. Whenever a new notice is added to that table, the server will check the connection table to see if there are connections for each receiver (receiver of the new notice). If so, an alert will be sent through each connection. For now, this alert only indicates that number of new notices, and we may put more information into it in future. 2) Client Each client maintains a connection with the server. The connection is set for receiving alerts of new notices. When a new alert arrives, the client will update the number of new notices on the header of the page, or even make an ajax call to the server to fetch the details of the notice. The connection request is sent when an authenticated user opens a new page. When the connection is set up, it is maintained until the page is destroyed.
Thank you for your interest in real-time notification system. If you have any questions or comments, please contact Pranav or Me.
Posted in: TechnologyWork Progress|By: Wei An|9647 Reads