This is the 26th day of my participation in the August More Text Challenge

One, foreword

Layered architecture, what are the issues to consider?

  1. Reliability: forIMSystem, key message reliable delivery, message is not lost. (Timeout, retransmission, confirmation)
  2. Availability: Availability7 * 24Hour service?
  3. Consistency: Data redundancy inevitably causes consistency problems. How to solve them?
  4. Scalability: Does adding machines increase storage and throughput?
  5. Balance: Is the load balanced among nodes in a cluster?


The architecture is layered as follows:

  • Application layer:IMThe system can support a lot of business, customer service system, sales system, similar to nail nail enterprise internalIMapplication
  • APILayer:Android/iOS SDK,H5 WebSocket
  • Access layer: connection establishment, request receiving, response and other processes
  • Functional layers:IMThe system provides a lot of functions: receive messages, push messages, group chat, red envelope, offline messages, security authentication and so on
  • Storage layer: Two types of message stores: instant messages and offline messages

Access layer

Why are TCP access systems and WebSocket access systems developed and deployed separately?

  • TCPAccess system: Mainly to connect with a large number of C-end users, such as e-commerceAPPMillions of users will be active every day, and hundreds of thousands of users will follow you every dayTCPConnect to the system and communicate with customer service.

TCP access system faces millions or even tens of millions of C-end users, the load is very high, so the deployment of a large number of machines

  • WebSocketAccess system is mainly connected with dozens or hundreds of customer service in the company, mainly customer service will open a web page through the browser, the web page throughHTML5WebSocket APIAnd with youWebSocketAccess System establishes a connection.

The WebSocket access system may only have a few hundred internal customer service, so the load is low, so there may not be a need to deploy a large number of machines

The protocols and technologies used are not quite the same, and the machine requirements deployed are not quite the same, so development needs to be developed separately.