Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔮[RFC #0000]: Cluster Mode Design #890

Closed
YuanJey opened this issue Aug 17, 2023 · 3 comments
Closed

🔮[RFC #0000]: Cluster Mode Design #890

YuanJey opened this issue Aug 17, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request feature Categorizes issue or PR as related to a new feature. RFC Project design proposal

Comments

@YuanJey
Copy link
Contributor

YuanJey commented Aug 17, 2023

[RFC #0000] OpenIMSDK Cluster Management Component Design

Meta

  • Name: OpenIM Cluster Management Component
  • Start Date: 2023-08-17
  • Author(s): [Your Github Username]
  • Status: Draft
  • RFC Pull Request:
  • OpenIMSDK Pull Request:
  • OpenIMSDK Issue:
  • Supersedes: N/A

📇Topics

Summary

The proposal introduces a Cluster Management Component for the OpenIM-Server to enhance messaging scalability and adaptability. This is achieved by adding a message cluster management component that studies the XMPP protocol, introducing 'from' and 'to' fields in the message body. The design aims to efficiently manage the flow of messages across multiple nodes and facilitate ease of expansion.

Weixin Image_20230817100950

Definitions

  • XMPP Protocol: An open XML technology for real-time communication.
  • Cluster Management Service: The primary service responsible for routing messages between various IM nodes.
  • IM Node: An instance of the OpenIM-Server.

Motivation

  • Improve the scalability and flexibility of OpenIM-Server by introducing a distributed architecture.
  • Streamline the flow of messages across nodes.
  • Introduce the capability for plug-and-play expansion, allowing nodes to be added or removed effortlessly.
  • Enhance the user experience and performance by efficiently routing messages.

What it is

The design introduces a Cluster Management Component in OpenIM-Server. This component is responsible for routing messages between nodes, ensuring efficient delivery. Taking inspiration from the XMPP protocol, the message body will now contain 'from' and 'to' fields indicating the source and destination nodes respectively.

How it Works

  1. Each IM Node establishes a long connection with the Cluster Management Service.
  2. When a user connects to an IM node, the node sends a message to the Cluster Management Service to update its information.
  3. If multiple Cluster Management Services exist, they can use caching to maintain the location information of users on all nodes or use an MQ to broadcast to other Cluster Management Services.
  4. When a node receives a message from a client, it first saves it to the database.
  5. If the recipient is on the same node, the message is directly distributed. If not, it is sent to the Cluster Management Service.
  6. If the Cluster Management Service cannot find the node where the user is located, it assumes the user is offline and discards the message, treating it as an offline message.

Migration

Existing users of OpenIM-Server would need to update their instances to the version supporting the Cluster Management Component. Additionally, a guide on setting up the Cluster Management Service and connecting IM nodes to it would be provided.

Drawbacks

  • Introducing a new component may increase the complexity of the system.
  • Potential overhead in terms of maintaining the synchronization among multiple Cluster Management Services.
  • Initial learning curve for those familiar with the current monolithic design.

Alternatives

  • Maintaining the current design without distributed architecture.
  • Employing different messaging protocols other than XMPP.
  • Using third-party cluster management solutions.

Prior Art

The XMPP protocol has been extensively used in various instant messaging systems, proving its efficacy in managing real-time communication. Many distributed architectures employ similar cluster management solutions to maintain scalability.

Unresolved Questions

  • How to efficiently manage synchronization among multiple Cluster Management Services?
  • How would offline messages be treated in a situation where the Cluster Management Service cannot determine the user's location for an extended period?
  • What would be the performance implications when scaling to a large number of nodes?

Spec. Changes (OPTIONAL)

  • New fields, 'from' and 'to', would be added to the OpenIM message body.
  • The introduction of the Cluster Management Service would necessitate changes in the OpenIM-Server's configuration to facilitate connections.

History

N/A

This proposal aims to ensure that OpenIM-Server becomes more scalable and can handle a distributed environment efficiently. As OpenIM continues to grow and attract more users, it's essential to consider such enhancements for the platform.

@YuanJey YuanJey added enhancement New feature or request feature Categorizes issue or PR as related to a new feature. proposal RFC Project design proposal labels Aug 17, 2023
@kubbot
Copy link
Contributor

kubbot commented Oct 17, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@cubxxw
Copy link
Contributor

cubxxw commented Oct 17, 2023

May I kindly remind you that the lifecycle of this issue requires refreshing

@kubbot
Copy link
Contributor

kubbot commented Mar 1, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature Categorizes issue or PR as related to a new feature. RFC Project design proposal
Projects
None yet
Development

No branches or pull requests

3 participants