A method, system, device and storage medium for IOT cluster communication

By selecting IOT servers based on location information and using the Gossip protocol for data synchronization and local persistent storage, the delay and availability issues in MQTT cluster communication are solved, and efficient IOT cluster communication is achieved.

CN115766735BActive Publication Date: 2025-10-21CRRC INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211278500.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-19
Publication Date
2025-10-21
Estimated Expiration
2042-10-19

AI Technical Summary

Technical Problem

Existing MQTT cluster communication in a multi-regional environment leads to increased latency between devices and servers and message delivery delays, and its reliance on Redis and Zookeeper components leads to delays and unavailability issues.

Method used

The first IOT server is selected for connection based on location information, and data synchronization and local persistent storage are performed through the Gossip protocol, reducing dependence on remote components and realizing decentralized message routing and query.

Benefits of technology

It reduces the latency between devices and servers, improves system performance and availability, simplifies expansion, and supports message transmission for massive devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115766735B_ABST
    Figure CN115766735B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a method, system, device and storage medium for IOT cluster communication, which comprises: when a server receives a connection request containing location information sent by a client, selecting a first IOT server according to the location information in the connection request, and enabling the first IOT server to connect with the client; after the first IOT server connects with the client, obtaining a subscriber list related to a message sent by the client, and determining a second IOT server where each subscriber client in the subscriber list is located; and the first IOT server sends the message to each subscriber client via the second IOT server where each subscriber client is located according to the subscriber list.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet of Things communication technology, and in particular to a method, system, device and storage medium for Internet of Things cluster communication. Background Art

[0002] We are currently in the era of mobile IoT, with massive numbers of IoT devices connected to the IoT for communication. IoT servers mostly use the MQTT protocol. This massive influx of devices necessitates clustering of MQTT brokers. IoT device connections are stateful, and the massive number of IoT devices requires distributed server clusters across multiple locations. Therefore, the challenges of MQTT broker clustering lie in reducing message propagation latency, ensuring efficient message distribution, and ensuring communication within a multi-service cluster.

[0003] The existing solution provides an IoT cluster communication method based on routing mode and the MQTT protocol. The access layer primarily uses the Nginx minimum connection algorithm to determine the first IoT server to which the IoT device will connect. Device information on the device side, including information about the first IoT server to which it is connected, is stored in Redis. When the device sends a message to the first IoT server, the first IoT server persistently stores the message and then queries the subscription tree stored in Zookeeper based on the message topic. The IoT server queries Redis for the IP address of the IoT server to which the subscriber is connected based on the subscriber list, and routes the message to the second IoT server via an internal message. The second IoT server persists the message locally, searches for subscribers connected to the IoT server, and sends the message to the online subscriber via MQTT.

[0004] However, the prior art has the following disadvantages:

[0005] The access layer uses only the Nginx minimum connection algorithm. In a multi-region environment, this will increase the delay between devices and servers and the delay in transmitting messages between devices.

[0006] It relies on Redis and Zookeeper components, and requires the maintenance of two component clusters.

[0007] The device information and the information of the first connected IOT server are stored in Redis, which means that each time a message is sent, the remote Redis service and the remote Zookeeper service need to be accessed. In the case of a large number of devices, this will increase the delay and even cause the service to be unavailable. Summary of the Invention

[0008] The embodiments of the present application provide a method, system, device and storage medium for IoT cluster communication to solve the technical problems of existing device-MQTT cluster communication, uncontrollable device-to-device message delay, complex routing lookup, large delay and poor scalability.

[0009] According to a first aspect of an embodiment of the present application, a method for IoT cluster communication is provided, comprising:

[0010] When the server receives a connection request including location information from the client, it selects a first IOT server according to the location information in the connection request, and connects the first IOT server to the client;

[0011] After the first IOT server is connected to the client, obtaining a subscriber list related to the message according to the message sent by the client, and determining the second IOT server where each subscriber client in the subscriber list is located;

[0012] The first IOT server sends the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located.

[0013] According to a second aspect of an embodiment of the present application, a system for IoT cluster communication is provided, including:

[0014] Sending client, used to send a connection request containing location information to the server;

[0015] The server side is configured to, upon receiving a connection request containing location information sent by a client, select a first IOT server according to the location information in the connection request, and connect the first IOT server to the client; after the first IOT server is connected to the client, obtain a subscriber list related to the message according to the message sent by the client, and determine the second IOT server where each subscriber client in the subscriber list is located; the first IOT server sends the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located;

[0016] Multiple subscriber clients are used to receive the message sent by the second IOT server where they are located.

[0017] Due to the adoption of the above technical solutions, the embodiments of the present application have the following technical effects: reducing the delay of the existing technology and improving the performance of the existing technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0019] Figure 1 A flow chart of an IOT cluster communication method provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of an IOT cluster communication system provided in an embodiment of the present application;

[0021] Figure 3 This is a structural block diagram of the IOT cluster provided in an embodiment of the present application;

[0022] Figure 4 This is a flow chart of establishing a connection between a device and an IOT server provided in an embodiment of the present application;

[0023] Figure 5 This is a schematic diagram of synchronization of key data based on the Gossip protocol provided in an embodiment of the present application;

[0024] Figure 6 This is a flow chart of an IOT cluster communication optimization method based on the Gosiip protocol provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the technical solutions and advantages of the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, and are not an exhaustive list of all the embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other unless they conflict.

[0026] Gossip is a decentralized, fault-tolerant protocol that guarantees eventual consistency. The protocol's implementation is initiated by a seed node. When a seed node has a message to update other nodes in the network, it randomly selects several nearby nodes to broadcast the message. The nodes that receive the message repeat this process until all nodes in the network have received the message. This process can take time, as there's no guarantee that all nodes will receive the message at any given moment. However, in theory, all nodes will eventually receive the message, making Gossip an eventual consistency protocol.

[0027] Example 1

[0028] like Figure 1 As shown, a flow chart of an IOT cluster communication method according to an embodiment of the present application includes:

[0029] Step S101: When a server receives a connection request including location information from a client, the server selects a first IOT server according to the location information in the connection request, and connects the first IOT server to the client.

[0030] Step S102: After the first IOT server is connected to the client, according to the message sent by the client, a subscriber list related to the message is obtained, and a second IOT server where each subscriber client in the subscriber list is located is determined;

[0031] Step S103: the first IOT server sends the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located.

[0032] An embodiment of the present application also includes: selecting M IOT servers from an IOT cluster having N IOT servers, and setting the M IOT servers as seed nodes respectively, and setting (NM) IOT servers as ordinary nodes respectively, and periodically performing information synchronization processing with the seed nodes after each ordinary node is started; wherein, N and M are both positive integers, and N is greater than M.

[0033] Furthermore, the periodic information synchronization processing with the seed node after each ordinary node is started includes: after each ordinary node is started, periodically reading information containing key data, IOT service cluster list and current connection status with the client, and sending the information to the seed node for information synchronization processing, and at the same time persistently storing the key data locally; wherein, the key data includes: device-side service mapping information, subscription tree information, IOT server connection information, geographic location information and affiliated IDC computer room information.

[0034] Specifically, the server side selects a first IOT server according to the location information in the connection request, so that the first IOT server is connected to the client, including: the server side obtains the IDC computer room closest to the location information according to the location information in the connection request; the server side selects the IOT server with the least current number of connections as the first IOT server based on the current number of connections of each IOT server in the IDC computer room, and sends the first IOT server information to the client, so that the client is connected to the first IOT server according to the first IOT server information.

[0035] In an embodiment of the present application, after the first IOT server is connected to the client, the first IOT server persistently stores the device information and IP information of the client on the server side, and synchronizes the device information and IP information of the client to all other IOT servers in the IOT cluster.

[0036] Furthermore, the first IOT server obtains a subscriber list related to the message sent by the client, and determines the second IOT server where each subscriber client in the subscriber list is located, including: the first IOT server parses the message sent by the client to obtain the message subject, and obtains the subscriber list corresponding to the message subject based on the subscription tree information stored in the local persistent storage; the first IOT server determines the second IOT server where each subscriber client in the subscriber list is located based on the subscriber list.

[0037] Furthermore, the first IOT server sends the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located, including: the first IOT server routes the message to the second IOT server where each subscriber client is located through an internal message according to the subscriber list, so that each second IOT server that receives the message forwards the message to its corresponding subscriber client.

[0038] Example 2

[0039] like Figure 2 As shown, a system diagram of an IOT cluster communication in an embodiment of the present application includes: a sending client 201, used to send a connection request containing location information to a server side; a server side 202, used to, when receiving a connection request containing location information sent by the client, select a first IOT server according to the location information in the connection request, so that the first IOT server is connected to the client; after the first IOT server is connected to the client, according to the message sent by the client, obtain a subscriber list related to the message, and determine the second IOT server where each subscriber client in the subscriber list is located; the first IOT server sends the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located; multiple subscriber clients 203, used to receive the message sent by the second IOT server where they are located.

[0040] An embodiment of the present application provides an electronic device, comprising: a memory; a processor; and a computer program; wherein the computer program is stored in the memory and is configured to be executed by the processor to implement an IOT cluster communication method.

[0041] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon; the computer program is executed by a processor to implement an IOT cluster communication method.

[0042] Example 3

[0043] like Figure 3 As shown in the figure, a structural block diagram of an IOT cluster provided by an embodiment of the present invention is shown, including: a communication layer, a business layer, a transport layer, a data synchronization layer, and a storage layer.

[0044] The communication layer uses Netty, and sends and receives messages between devices and subscribers based on Netty's MQTT. It also implements intra-cluster persistent connection establishment and message routing based on Netty's custom protocol.

[0045] The business layer is the business logic processing layer required by the MQTT protocol. Based on the MQTT service quality, after the message is persisted, it goes to the message routing decision module, which checks whether the subscriber is local or remote. (If the subscriber is local, the message is sent to the subscriber on that server; if the subscriber is remote, the message is sent to the remote server where the subscriber is located, and then the remote service forwards the message on its behalf.) After passing through the message routing decision module, a batch of subscribers is generated and transferred to the transport layer.

[0046] The transport layer is a module that sends messages to subscribers or routes messages to other services in the cluster.

[0047] The data synchronization layer is implemented using the Netty-based Gossip protocol to synchronize key information such as server lists, subscription trees, and the correspondence between server and device identifiers.

[0048] The storage layer uses Rocksdb to store the above key information persistently locally.

[0049] Please see the attached Figure 4 , which shows a schematic diagram of a process for establishing a connection between a device and an IOT server according to an embodiment of the present invention. Applied to the device, the method includes:

[0050] S201, the device is ready to connect to the service end (server end) and report location information;

[0051] S202, the device obtains the nearest IDC room information from the server;

[0052] Based on the location information reported by the device, the server matches the nearest IDC room from the locally stored key information, selects the server with the least number of connections, and notifies the device of this information.

[0053] S203, the device sends a connection request to the IDC room;

[0054] S203, the device end is connected to the first IOT server of the IDC computer room through Nginx by the Nginx minimum connection algorithm, and the first IOT server stores the device information of the device end and the IP information of the first IOT server persistently on the server, and then synchronizes the information to all IOT servers through the Gossip-based data synchronization method.

[0055] Please see the attached Figure 5 , which shows a schematic diagram of synchronization of key data based on the Gossip protocol provided by an embodiment of the present invention, applied to the server, the method includes:

[0056] Set several (usually three) nodes in the cluster as seed nodes. After each IOT server is started, it will communicate with the seed node as soon as possible to synchronize key data, IOT server cluster list and connection status (connection status between the device side and the IOT service). After synchronization is completed, the key data will be persistently stored locally; among them, key data refers to device-side service mapping information, subscription tree information, IOT server connection information, geographic location information, and IDC room information.

[0057] Each IOT server periodically performs hash calculations on its own key data to generate summary information, and then randomly sends it to N IOT servers in the cluster except itself.

[0058] After receiving the summary information, each IOT server compares the time with the summary information stored persistently on its own. If the data is not the latest, it goes to the source server of the summary information to synchronize the data. Otherwise, no processing is performed.

[0059] In the above solution, assuming that the entire cluster consists of 1,000 IOT servers, then a data update requires log N (1000) rounds are enough to complete the propagation.

[0060] Please see the attached Figure 6 , which shows a flow chart of an IoT cluster communication optimization method based on the Gosiip protocol provided by an embodiment of the present invention, applied to the server, the method comprising:

[0061] S401, the device connects to the first IOT server;

[0062] S402, the device sends a message to the first IOT server;

[0063] The device sends a message to the first IOT server to which it is connected;

[0064] S403: The first IOT server obtains the message subject by parsing the message, obtains the subscriber list through the locally persistent subscription tree, and then obtains the list of IOT servers to which the subscriber belongs from the server-subscriber mapping stored in the local persistent storage through the subscriber list; that is, the first IOT server obtains the list of IOT servers to which the subscriber belongs based on the subscriber list;

[0065] S404: The IOT server routes the message to the corresponding server according to the IOT server list, and attaches a subscriber list corresponding to the IP address; that is, the IOT server routes the message to the second IOT through an internal message according to the IOT server list to which the subscriber belongs;

[0066] S405, the IOT server that receives the routing message sends the message to the corresponding subscriber according to the subscriber list corresponding to the above IP, that is, the second IOT server sends the message to the selected subscriber (subscriber client) connected to the server.

[0067] In summary, the beneficial effects of the present invention are as follows: the device side selects the nearest server for connection according to the region, thereby reducing the delay between the server and the device side; in the process of querying the subscription tree and querying the mapping between subscribers and IOT servers, messages are retrieved based on local persistent storage, without the need to access the middleware cluster located at the remote end, which greatly improves query concurrency, changes centralized queries to decentralized queries, reduces query delays, and eliminates the need for network interaction; removes the component dependencies of Redis and Zookeeper, saves key data in a decentralized manner, and improves the availability of the system; the entire method adopts a decentralized architecture, reduces the difficulty of expanding IOT services, and more easily supports the transmission of massive devices and messages.

[0068] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0069] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0070] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0071] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0072] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.

[0073] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.

Claims

1. A method for IoT cluster communication, characterized in that: include: When the server receives a connection request including location information from the client, it selects a first IOT server according to the location information in the connection request, and connects the first IOT server to the client; After the first IOT server is connected to the client, obtaining a subscriber list related to the message according to the message sent by the client, and determining the second IOT server where each subscriber client in the subscriber list is located; The first IOT server sends the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located; The method also includes: Select M IOT servers from an IOT cluster with N IOT servers, and set the M IOT servers as seed nodes respectively. At the same time, set (NM) IOT servers as ordinary nodes respectively. After each ordinary node is started, it periodically synchronizes information with the seed node. Wherein, N and M are both positive integers, and N is greater than M; The periodic information synchronization process with the seed node after each common node is started includes: After each common node is started, it periodically reads information including key data, a list of IoT service clusters, and the current connection status with the client, and sends the information to the seed node for information synchronization, while persistently storing the key data locally; The key data includes: device-side service mapping information, subscription tree information, IOT server connection information, geographic location information, and IDC room information; The server side selects a first IOT server according to the location information in the connection request, and connects the first IOT server to the client, comprising: The server side obtains the IDC room closest to the location information according to the location information in the connection request; The server side selects the IOT server with the least number of current connections as the first IOT server based on the current number of connections of each IOT server in the IDC computer room, and sends the first IOT server information to the client, so that the client connects to the first IOT server based on the first IOT server information.

2. The method according to claim 1, characterized in that After the first IOT server is connected to the client, the method further includes: The first IOT server persistently stores the device information and IP information of the client on the server side, and synchronizes the device information and IP information of the client to all other IOT servers in the IOT cluster.

3. The method according to claim 2, characterized in that The first IOT server obtains a subscriber list related to the message according to the message sent by the client, and determines that the second IOT server where each subscriber client in the subscriber list is located includes: The first IOT server parses the message sent by the client to obtain a message subject, and obtains a subscriber list corresponding to the message subject from the subscription tree information stored in local persistent storage; The first IOT server determines, according to the subscriber list, a second IOT server where each subscriber client in the subscriber list is located.

4. The method according to claim 3, characterized in that The first IOT server sending the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located includes: The first IOT server routes the message to the second IOT server where each subscriber client is located through an internal message according to the subscriber list, so that each second IOT server that receives the message forwards the message to its corresponding subscriber client.

5. An IOT cluster communication system, characterized in that: include: Sending client, used to send a connection request containing location information to the server; The server side is configured to, upon receiving a connection request containing location information sent by a client, select a first IOT server according to the location information in the connection request, and connect the first IOT server to the client; after the first IOT server is connected to the client, obtain a subscriber list related to the message according to the message sent by the client, and determine the second IOT server where each subscriber client in the subscriber list is located; the first IOT server sends the message to each subscriber client according to the subscriber list and via the second IOT server where each subscriber client is located; Multiple subscriber clients, configured to receive the message sent by the second IOT server where they are located; Select M IOT servers from an IOT cluster with N IOT servers, and set the M IOT servers as seed nodes respectively. At the same time, set (NM) IOT servers as ordinary nodes respectively. After each ordinary node is started, it periodically synchronizes information with the seed node. Wherein, N and M are both positive integers, and N is greater than M; The periodic information synchronization process with the seed node after each common node is started includes: After each common node is started, it periodically reads information including key data, a list of IoT service clusters, and the current connection status with the client, and sends the information to the seed node for information synchronization, while persistently storing the key data locally; The key data includes: device-side service mapping information, subscription tree information, IOT server connection information, geographic location information, and IDC room information; The server side selects a first IOT server according to the location information in the connection request, and connects the first IOT server to the client, comprising: The server side obtains the IDC room closest to the location information according to the location information in the connection request; The server side selects the IOT server with the least number of current connections as the first IOT server based on the current number of connections of each IOT server in the IDC computer room, and sends the first IOT server information to the client, so that the client connects to the first IOT server based on the first IOT server information.

6. An electronic device, characterized in that: include: Memory; processor; and computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that A computer program is stored thereon; the computer program is executed by a processor to implement the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Distributed service presentation system and method based on IMS architecture

    CN110087227A

  • Method for cross-regional data consistency of distributed Internet of Things equipment and service cluster

    CN112711635A