How instant messaging system guarantees high reliability news

Reliable messaging is instant messaging system in the most basic, is one of the most central part, but also to measure an important indicator of the quality of the communication system. This paper describes the realization of the principle of common communication system model, analyze common problems affecting the reliability of message transmission, and describes how there is a degree of instant messaging service system to achieve highly reliable message delivery mechanisms through architecture and technical details.
Express systems model is a common model of instant messaging system, the main structure as shown below:
How instant messaging system guarantees high reliability news
Message sending process of the model is not a completed transaction, the problem of lost messages will appear the following scenarios:
1, ClientA the message to the Server, Server after receiving the reply ClientA sent successfully, the subsequent transfer from the Server protection Server process at this time if the restart, the message is not stored in the memory, the message appears lost.
2, ClientA successfully sent a message to the Server, Server forwarded to ClientB, received a reply after receiving the network layer ClientB success, but ClientB have not saved the message to the database, then ClientB process closes, will also appear the message is lost;
3, will ClientA the message was successfully sent to the Server, Server found ClientB offline, send messages to offline messaging, offline message service reply is received successfully, but not saved offline messages into the top disk processes abnormal exit, lost the message will also appear;
behind the emergence of a improved model, this improvement can protect the network layer does not lose the message, but the overall point of view there are still loopholes in the system architecture, network programming architecture roughly as follows:
How instant messaging system guarantees high reliability news
the network layer (net) receiving the request, the other reply message has been received, the next Logic layer throw request, to save the message layer Logic layer was thrown Store UI layer.
Through practice found, Net respond to each other after the message has been received, the message is not saved to the database before program exits, will appear the message is lost.
If you are offline messaging services, network layer receives a lot of offline messages thrown layer Logic, Logic floor disk speed, if not keep up, the queue will accumulate Logic news, then restart the service, Logic queue offline messages are not saved You will be lost.
This evolution to solve the problems of the original system of 1, 2, 3, but the problem did not solve, express-style instant messaging system message arrival rate is difficult to effectively protect, easily the intermediate links, news programming as a result of the loss.
Mail service is a long history of communications systems, the client sends the message is a complete transaction, after the successful landing returns only the message, in the middle of any one link fails have failed to reply, the model can guarantee message is not lost, if the guarantee recipients can successfully pull to the message, the evolution of a more extreme message reaches the high rate solution, mail service model is as follows: How instant messaging system guarantees high reliability news
there are degrees of instant messaging system reference model for e-mail services, messaging server roaming, will transform the mail polling mechanism push for the new message notification, the system uses micro-service model design, deploy and support server cluster expansion, and use a variety of measures to protect the message arrival rate.
I.e., the system design uses advanced data storage technology in the message storage server, as long as the server receives the acknowledgment message, the message remains stored in the server, as the user will not remove read. In the network anomaly, abnormal client device, acquired by the secondary still request message.
Micro traffic service architecture is split into a plurality of independent services may be deployed extension, this model can be efficient fault isolation to enhance the overall reliability and availability of services.
Each session participant message data is shared, to avoid sending to the recipient to be successful conversion of the received message from a sender failure problems, as long as the message transmitted Success (i.e. storage), the entire session participants will be able to pull the messages.
The client by calling RESTFUL API interfaces when sending messages. API interfaces guarantee success reply that is put in storage. When a client call interface failure or timeout retry mechanism will be used many times, failed to send a clear message client will be given a prompt to tell the sender.
Message storage server mechanism of evolution after many, from the beginning of the evolution of MySQL storage to the present Redis + Leveldb, its acceptance of ultimate reliability. The client sends a message storage immediately written to memory data storage operation comprising a table (table double buffering) and pending log (abnormal protection), is converted to read-only and persistence, is the use of efficient persistent memory data table is full the order storage (LevelDB benefit from the implementation mechanism), and can use a backup server for data master-slave synchronization, ensure disaster recovery when the file system failure recovery.
Client pull message via the notification event server will auto-complete the full message recording while getting the message. Fluctuations occur in the network, the client will re-establish a connection and immediately pulled all unread.

Guess you like

Origin blog.51cto.com/14735721/2480430