MQTT load balancing method and system, and computer-readable storage medium

By using the service redirection function in the MQTT service cluster, the MQTT service requests are migrated to other suitable servers, which solves the problem of being unable to effectively perceive the back-end server load and implement balancing allocation in the existing technology, and realizes efficient and low-cost load balancing services.

WO2025123857A1PCT designated stage expired Publication Date: 2025-06-19HANGZHOU TUYA INFORMATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/121073
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-12
Filing Date
2024-09-25
Publication Date
2025-06-19

AI Technical Summary

Technical Problem

The existing MQTT load balancing technology cannot effectively sense the real load of the backend MQTT server, and cannot achieve balancing allocation of the backend server. It relies on the NLB or proxy service software of cloud vendors, which increases costs and cannot meet the business characteristics of the MQTT server.

Method used

By using the service redirection function of the MQTT server, the MQTT service request is migrated to other suitable MQTT servers to form an MQTT service cluster, the dedicated MQTT server connects the connection of the MQTT client, and allocates the general MQTT server to be provided to the client according to the preset allocation rules.

Benefits of technology

It realizes load balancing services for MQTT clients without relying on existing load balancing means, reduces the cost of load balancing, and easily and quickly achieves balancing allocation of MQTT service requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024121073_19062025_PF_FP_ABST
    Figure CN2024121073_19062025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to an MQTT load balancing method and system, and a computer-readable storage medium. The method is applied to a dedicated MQTT server, and comprises: receiving connection information from an MQTT client; on the basis of a first preset allocation rule, allocating to the MQTT client, from among a plurality of general MQTT servers, a general MQTT server waiting to provide a service; sending to the MQTT client address information of the general MQTT server waiting to provide the service; and breaking the connection with the MQTT client. In the solution of the present application, by means of the redirection function of the dedicated MQTT server and / or the general MQTT servers, an MQTT service cluster formed by the dedicated MQTT server and the plurality of general MQTT servers can provide load balancing for an MQTT request of the MQTT client, without the aid of existing load balancing means, thus preventing or reducing the dependence on the existing load balancing means, reducing the cost of load balancing, and realizing a simple and fast implementation process.
Need to check novelty before this filing date? Find Prior Art

Description

MQTT load balancing method, system, and computer-readable storage medium Technical Field

[0001] The present application relates to the field of computer software technology, and in particular to an MQTT load balancing method, system, and computer-readable storage medium. Background Art

[0002] In the existing technology, MQTT (Message Queuing Telemetry Transport) load balancing usually relies on the cloud vendor's NLB (Network Load Balancing), or uses proxy service software such as Envoy Nginx HAProxy as a reverse proxy. The load balancing strategies adopted include Round Robin, Static Round Robin, Least Connections, or Source IP Hash.

[0003] However, the existing MQTT load balancing has very obvious shortcomings. For example, it cannot perceive the actual load of the backend MQTT server (or MQTT broker), and cannot balance the backend MQTT server; additional services are required for load balancing, which increases costs; and it cannot meet the business characteristics of the MQTT server, such as combined isolation, and session management is difficult to implement more conveniently and cost-effectively.

[0004] Summary of the Invention

[0005] In response to the problems existing in MQTT load balancing in the prior art, this application provides an MQTT load balancing solution. This solution utilizes the service redirection function of the MQTT server to migrate MQTT service requests to other suitable MQTT servers. In the process of achieving load balancing of MQTT service requests, it reduces the dependence on existing load balancing methods such as NLB and proxy service software of cloud vendors.

[0006] According to a first aspect of the present application, there is provided an MQTT load balancing method, which is applied to a dedicated MQTT server and is characterized by comprising:

[0007] Receive connection information from the MQTT client;

[0008] Based on a first preset allocation rule, allocating a universal MQTT server to provide service to the MQTT client from among multiple universal MQTT servers;

[0009] Sending the address information of the universal MQTT server to be provided with services to the MQTT client, so that the universal MQTT server to be provided with services establishes a connection with the MQTT client and provides MQTT services; and

[0010] Disconnect from the MQTT client.

[0011] According to a second aspect of the present application, a method for MQTT load balancing is provided, which is applied to any one of a plurality of general MQTT servers, and is characterized by comprising:

[0012] Receive connection requests from MQTT clients;

[0013] Determining whether to provide MQTT service for the MQTT client;

[0014] When it is determined that the MQTT service is not to be provided for the MQTT client, allocating another universal MQTT server to provide service to the MQTT client from the plurality of universal MQTT servers based on a second preset allocation rule;

[0015] Sending the address information of the universal MQTT server to be provided to the MQTT client; and

[0016] Disconnect from the MQTT client.

[0017] According to a third aspect of the present application, a method for MQTT load balancing is provided, which is applied to an MQTT client and is characterized by comprising:

[0018] Sending connection information to a service entry of an MQTT service cluster, wherein the MQTT service cluster includes a dedicated MQTT server and multiple general MQTT servers;

[0019] Receive first address information of a first universal MQTT server to be provided with service, which is sent by the dedicated MQTT server; and

[0020] A connection request is sent to the first universal MQTT server to provide services according to the first address information.

[0021] According to a fourth aspect of the present application, an MQTT load balancing system is provided, characterized in that it includes:

[0022] A dedicated MQTT server, used to execute the method described in the first aspect;

[0023] Multiple general MQTT servers, used to execute the method as described in the second aspect; and

[0024] The MQTT client is used to execute the method described in the third aspect.

[0025] According to the fifth aspect of the present application, a non-transitory computer storage medium is provided, which stores a computer program. When the computer program is executed by multiple processors, the processors execute the methods described in the first aspect, the second aspect and the third aspect.

[0026] According to the MQTT load balancing method, system and computer-readable storage medium provided by the present application, an MQTT service cluster is formed by a dedicated MQTT server and multiple general servers. In the MQTT service cluster, the dedicated MQTT server connects to the connection of the MQTT client and allocates the MQTT server to be provided with services to the MQTT client according to the preset allocation rules. In the MQTT service cluster, after receiving the assignment from the dedicated MQTT server, the general MQTT server can provide MQTT services to the MQTT client, or allocate other MQTT servers to be provided with services to the MQTT client. In this way, the MQTT service cluster can provide load balancing for the MQTT requests of the MQTT client without the help of existing load balancing means through the redirection function of the dedicated MQTT server and / or the general MQTT server, thereby avoiding or reducing the dependence on the existing load balancing means, reducing the cost of load balancing, and making the implementation process simple and fast. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without exceeding the scope of protection required by this application.

[0028] FIG1a is a schematic diagram of an MQTT load balancing system according to an embodiment of the present application.

[0029] FIG1 b is a schematic diagram of an MQTT load balancing system according to another embodiment of the present application.

[0030] FIG2 is a flowchart of an MQTT load balancing method implemented by a dedicated MQTT server according to an embodiment of the present application.

[0031] FIG3 is a flowchart of an MQTT load balancing method implemented by a general MQTT server according to an embodiment of the present application.

[0032] FIG4 is a flowchart of an MQTT load balancing method implemented by an MQTT client according to an embodiment of the present application.

[0033] FIG5 is a flowchart of an MQTT load balancing method implemented by an MQTT client according to another embodiment of the present application.

[0034] FIG6 is a structural diagram of an electronic device provided by this application. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.

[0036] Figure 1a is a schematic diagram of an MQTT load balancing system according to one embodiment of the present application. As shown in Figure 1a, the system includes a dedicated MQTT server, multiple general-purpose MQTT servers, and an MQTT client. The MQTT client can be a variety of devices requiring MQTT services, such as IoT devices. The dedicated MQTT server assigns an appropriate general-purpose MQTT server to the MQTT client, and the general-purpose MQTT server can provide MQTT services to the MQTT client and can also select other general-purpose MQTT servers for the MQTT client when needed.

[0037] A dedicated MQTT server and multiple general MQTT servers form an MQTT service cluster. According to some embodiments, in the MQTT service cluster, the dedicated MQTT server can be made public on the public network to provide a service entry for the MQTT client. When the MQTT client needs the MQTT service, it sends the connection information of the MQTT service it wants to obtain to the dedicated MQTT server. After receiving the connection information, the dedicated MQTT server authenticates the MQTT client. After the authentication is passed, the MQTT server to be provided with service is allocated to the MQTT client from multiple general MQTT servers according to the preset allocation rules; if the authentication fails, the connection with the MQTT client is disconnected. This application does not impose any restrictions on the preset allocation rules, for example, it can be polling allocation, random allocation, fixed allocation of a general MQTT server to a MQTT client, and so on.

[0038] According to some embodiments, a dedicated MQTT server may obtain the service characteristics of an MQTT client and / or resource usage information of multiple general MQTT servers, wherein the service characteristics of the MQTT client may be set by the user, for example, for different tenants or different categories, and this application does not impose any restrictions on this. The resource usage information of the general MQTT server may include the CPU, memory load, and MQTT connection information of the general MQTT server, and this application does not impose any restrictions on this. As shown in Figure 1a, an MQTT management center can be set up in the system to collect the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers in real time. The dedicated MQTT server can obtain the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers through the MQTT management center; or, the dedicated MQTT server can collect the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers in real time without going through the MQTT management center; or, the general MQTT server in the system can collect the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers in real time without going through the MQTT management center, and the dedicated MQTT server can obtain the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers through the general MQTT server.

[0039] After obtaining the business characteristics of the MQTT client or the resource occupancy information of multiple universal MQTT servers, allocation rules can be set based on the business characteristics of the MQTT client or the resource occupancy information of multiple universal MQTT servers. According to one embodiment, the business characteristics of the MQTT client are different tenants, and the preset allocation rules can achieve isolation of different tenants; according to another embodiment, the business characteristics of the MQTT client are different categories, and the preset allocation rules can achieve allocation of different categories of equipment to different universal MQTT servers. For example, electrical lighting can use the same universal MQTT server, and a sweeper can use its own exclusive universal MQTT server; according to another embodiment, the business session of the current MQTT client already exists in a universal MQTT server. When receiving the MQTT request of the current MQTT client, the preset allocation rules can assign the universal MQTT server to continue providing services for it. According to one embodiment, when the resource occupancy information of the universal MQTT server is memory occupancy, the preset allocation rule can allocate the MQTT client to the universal MQTT server with less current memory occupancy; according to one embodiment, when the resource occupancy information of the universal MQTT server is MQTT connection information, the preset allocation rule can allocate the MQTT client to the universal MQTT server with less current MQTT connection number.

[0040] According to some embodiments, a dedicated MQTT server can integrate the business characteristics of the MQTT client and the resource occupancy information of multiple general MQTT servers, and determine a preset allocation rule based on the two. For example, an MQTT client with business characteristics that occupies more resources is allocated to a general MQTT server that currently occupies less memory, and so on.

[0041] Those skilled in the art will understand that the allocation rules for the above-mentioned business characteristics based on the MQTT client and / or resource occupancy information of multiple general MQTT servers are not limited to the preset methods given in the above-mentioned embodiments, but can be set according to actual needs. This application does not impose any restrictions on this.

[0042] After determining the MQTT server to provide the service, the dedicated MQTT server can return a CONNACK Reason code set to 0x9D (Server moved), send the address information of the MQTT server to provide the service to the MQTT client, guide the MQTT client to reconnect to the appropriate general MQTT server, and then disconnect from the MQTT client. According to some embodiments, the address information may include an IP address or domain name.

[0043] The MQTT client sends a connection request to the universal MQTT server specified by the address information provided by the dedicated MQTT server. After receiving the connection request, the universal MQTT server can directly accept the request and provide MQTT services to the MQTT client, or further determine whether to provide MQTT services to the MQTT client.

[0044] According to some embodiments, in the case of determining to provide the MQTT service to the MQTT client, the universal MQTT server provides the MQTT service according to the MQTT request.

[0045] According to some embodiments, the universal MQTT server may determine not to provide MQTT services to the MQTT client based on its own situation or preset conditions, such as the current load is too high or no service is desired. In the case of determining not to provide MQTT services to the MQTT client, the universal MQTT server may be similar to the dedicated MQTT server, and according to the preset allocation rules, allocate the MQTT server to be provided with services to the MQTT client from other universal MQTT servers. Among them, the preset allocation rules have been described above, and may be allocation rules independent of the business characteristics of the MQTT client and the resource occupancy information of multiple universal MQTT servers, or may be allocation rules based on the business characteristics of the MQTT client and / or the resource occupancy information of multiple universal MQTT servers after obtaining the business characteristics of the MQTT client and / or the resource occupancy information of multiple universal MQTT servers, which will not be repeated here. It should be noted that, in the process of allocating MQTT servers to provide services, the specific preset allocation rules adopted by the general MQTT server and the dedicated MQTT server may be the same or different. For example, the preset allocation rules of the general MQTT server and the dedicated MQTT server may be based on the category of the MQTT client, and devices of different categories may be allocated to different general MQTT servers. Alternatively, the preset allocation rule of the general MQTT server is based on the category of the MQTT client, while that of the dedicated MQTT server is based on the memory usage of the general MQTT server.

[0046] After the universal MQTT server determines the MQTT server to provide services, the universal MQTT server can return a CONNACK Reason code set to 0x9D (Server moved), send the address information of the MQTT server to provide services to the MQTT client, guide the MQTT client to reconnect to the appropriate universal MQTT server, and then disconnect from the MQTT client.

[0047] According to some embodiments, in order to further ensure the stability of the load balancing system and prevent single point failures, multiple dedicated MQTT servers can be deployed in the system. In this case, the system needs to provide a clear service entry for the MQTT client. As shown in Figure 1b, the system may also include a load balancer, such as NLB, proxy service software, etc. The load balancer can be the service entry of the system. After the load balancer receives the connection information of the MQTT client, it selects a dedicated MQTT server for the MQTT client from multiple dedicated MQTT servers, and sends the connection information to the selected dedicated MQTT server. The dedicated MQTT server determines the general MQTT server that provides services for the MQTT client based on the above-mentioned load balancing method. In this embodiment, the load balancer only selects a dedicated MQTT server for the MQTT client. After determining the dedicated MQTT server, subsequent MQTT requests and services do not need to pass through the load balancer, thereby not generating a large amount of traffic and costs.

[0048] According to some embodiments, for scenarios requiring cross-universal MQTT server communication, technologies such as message bridging may be used to enable message delivery between different MQTT servers.

[0049] On the basis of the above-mentioned load balancing system, according to one aspect of the present application, an MQTT load balancing method implemented by a dedicated MQTT server is provided, as shown in FIG2 , and the method includes the following steps.

[0050] Step S201, receiving connection information of the MQTT client;

[0051] Step S202: allocating a universal MQTT server to provide service to the MQTT client from among multiple universal MQTT servers based on a first preset allocation rule;

[0052] Step S203, sending the address information of the universal MQTT server to be provided with services to the MQTT client, so that the universal MQTT server to be provided with services establishes a connection with the MQTT client and provides MQTT services; and

[0053] Step S204: disconnecting from the MQTT client.

[0054] A dedicated MQTT server and multiple general MQTT servers form an MQTT service cluster. According to some embodiments, in the MQTT service cluster, the dedicated MQTT server can be made public on the public network to provide a service entry for the MQTT client. When the MQTT client needs the MQTT service, it sends the connection information of the MQTT service it wants to obtain to the dedicated MQTT server. After receiving the connection information, the dedicated MQTT server authenticates the MQTT client. After the authentication is passed, the MQTT server to be provided with service is allocated to the MQTT client from multiple general MQTT servers according to the preset allocation rules; if the authentication fails, the connection with the MQTT client is disconnected. This application does not impose any restrictions on the preset allocation rules, for example, it can be polling allocation, random allocation, fixed allocation of a general MQTT server to a MQTT client, and so on.

[0055] After determining the MQTT server to provide services, the dedicated MQTT server can return a CONNACK Reason code set to 0x9D (Server moved), send the address information of the MQTT server to provide services to the MQTT client, guide the MQTT client to reconnect to the appropriate universal MQTT server, and then disconnect from the MQTT client. Based on the address information provided by the dedicated MQTT server, the MQTT client sends a connection request to the universal MQTT server pointed to by the address information. The universal MQTT server pointed to by the address information establishes a connection with the MQTT client and provides MQTT services.

[0056] According to some embodiments, a dedicated MQTT server may obtain the service characteristics of an MQTT client and / or resource usage information of multiple general MQTT servers, wherein the service characteristics of the MQTT client may be set by the user, for example, for different tenants or different categories, and this application does not impose any restrictions on this. The resource usage information of the general MQTT server may include the CPU, memory load, and MQTT connection information of the general MQTT server, and this application does not impose any restrictions on this. As shown in Figure 1a, an MQTT management center can be set up in the system to collect the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers in real time. The dedicated MQTT server can obtain the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers through the MQTT management center; or, the dedicated MQTT server can collect the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers in real time without going through the MQTT management center; or, the general MQTT server in the system can collect the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers in real time without going through the MQTT management center, and the dedicated MQTT server can obtain the business characteristics of the MQTT client and / or the resource occupancy information of multiple general MQTT servers through the general MQTT server.

[0057] According to some embodiments, after obtaining the service characteristics of the MQTT client and / or the resource usage information of multiple universal MQTT servers, the dedicated MQTT server can set allocation rules based on the service characteristics of the MQTT client or the resource usage information of multiple universal MQTT servers. According to other embodiments, the dedicated MQTT server can combine the service characteristics of the MQTT client and the resource usage information of multiple universal MQTT servers to determine a preset allocation rule based on the two. Then, according to the preset allocation rule, the MQTT client is allocated a universal MQTT server to be provided with service from among the multiple universal MQTT servers.

[0058] Thus, step S202 may specifically include:

[0059] Obtaining service characteristics of the MQTT client and / or resource occupancy information of the plurality of general MQTT servers; and

[0060] According to the service characteristics of the MQTT client and / or the resource occupancy information of the multiple universal MQTT servers, and in accordance with the first preset allocation rule, a universal MQTT server to be provided for the MQTT client from among the multiple universal MQTT servers is allocated.

[0061] On the basis of the above-mentioned load balancing system, according to another aspect of the present application, an MQTT load balancing method implemented by a general MQTT server is provided, as shown in FIG3 , and the method includes the following steps.

[0062] Step S301, receiving a connection request from an MQTT client;

[0063] Step S302, determining whether to provide MQTT service for the MQTT client;

[0064] Step S303: When it is determined that the MQTT service is not provided for the MQTT client, allocating another general MQTT server to provide service to the MQTT client from among the multiple general MQTT servers based on a second preset allocation rule;

[0065] Step S304, sending the address information of the universal MQTT server to be provided with services to the MQTT client; and

[0066] Step S305: disconnecting from the MQTT client.

[0067] The MQTT client sends a connection request to the universal MQTT server specified by the address information provided by the dedicated MQTT server. After receiving the connection request, the universal MQTT server can directly accept the request and provide MQTT services to the MQTT client, or further determine whether to provide MQTT services to the MQTT client.

[0068] According to some embodiments, in the case of determining to provide the MQTT service to the MQTT client, the universal MQTT server provides the MQTT service according to the MQTT request.

[0069] According to some embodiments, the universal MQTT server may determine not to provide MQTT services to the MQTT client based on its own circumstances or preset conditions, such as when the current load is too high or the service is not desired. In the event that it is determined not to provide MQTT services to the MQTT client, the universal MQTT server may, similar to a dedicated MQTT server, allocate an MQTT server to be provided to the MQTT client from other universal MQTT servers according to preset allocation rules.

[0070] After the universal MQTT server determines the MQTT server to provide services, the universal MQTT server can return a CONNACK Reason code set to 0x9D (Server moved), send the address information of the MQTT server to provide services to the MQTT client, guide the MQTT client to reconnect to the appropriate universal MQTT server, and then disconnect from the MQTT client.

[0071] According to some embodiments, the universal MQTT server may obtain service characteristics of the MQTT client and / or resource usage information of other universal MQTT servers. After obtaining the service characteristics of the MQTT client and / or resource usage information of other universal MQTT servers, the universal MQTT server adopts allocation rules based on the service characteristics of the MQTT client and / or resource usage information of other universal MQTT servers.

[0072] Thus, step S303 may specifically include:

[0073] Obtaining service characteristics of the MQTT client and / or resource usage information of other general MQTT servers; and

[0074] According to the service characteristics of the MQTT client and / or the resource occupancy information of other universal MQTT servers, and in accordance with the second preset allocation rule, a universal MQTT server to be provided for the MQTT client is allocated from other universal MQTT servers of the multiple universal MQTT servers.

[0075] On the basis of the above-mentioned load balancing system, according to another aspect of the present application, an MQTT load balancing method implemented by an MQTT client is provided, as shown in FIG4 , and the method includes the following steps.

[0076] Step S401: Send connection information to a service entry of an MQTT service cluster, where the MQTT service cluster includes a dedicated MQTT server and multiple general MQTT servers.

[0077] Step S402, receiving first address information of a first universal MQTT server to be provided with a service sent by the dedicated MQTT server; and

[0078] Step S403: Send a connection request to the first universal MQTT server to provide service according to the first address information.

[0079] A dedicated MQTT server and multiple general MQTT servers form an MQTT service cluster. According to some embodiments, in the MQTT service cluster, the dedicated MQTT server can be publicly available on the public network to provide a service entry for the MQTT client. When the MQTT client needs the MQTT service, it sends the connection information of the MQTT service it wants to obtain to the dedicated MQTT server. After receiving the connection information, the dedicated MQTT server authenticates the MQTT client. After the authentication is passed, the dedicated MQTT server is assigned to the MQTT client from among multiple general MQTT servers according to the preset allocation rules; if the authentication fails, the connection with the MQTT client is disconnected.

[0080] According to other embodiments, multiple dedicated MQTT servers may be deployed in the system. In this case, the system needs to provide a clear service entry point for the MQTT client. The load balancing system may also include a load balancer. The load balancer may be the service entry point of the system. Upon receiving the connection information from the MQTT client, the load balancer selects a dedicated MQTT server from multiple dedicated MQTT servers for the MQTT client and sends the connection information to the selected dedicated MQTT server. The dedicated MQTT server then determines a general MQTT server that provides services to the MQTT client based on the load balancing method described above.

[0081] After determining the MQTT server to provide services, the dedicated MQTT server can send the address information of the MQTT server to the MQTT client, guiding the MQTT client to reconnect to the appropriate universal MQTT server, and then disconnect from the MQTT client. The MQTT client sends a connection request to the universal MQTT server pointed to by the address information provided by the dedicated MQTT server.

[0082] FIG5 is a flow chart of an MQTT load balancing method implemented by an MQTT client according to another embodiment of the present application. Compared with FIG4 , steps S501 to S503 of FIG5 are the same as steps S401 to S403 of FIG4 , except that the method of FIG5 further includes:

[0083] Step S504: receiving second address information of a second universal MQTT server to be provided with services sent by the currently connected universal MQTT server; and

[0084] Step S505: Send a connection request to the second universal MQTT server to provide service according to the second address information.

[0085] According to some embodiments, the universal MQTT server may determine not to provide MQTT services to the MQTT client based on its own circumstances or preset conditions, such as when the current load is too high or the service is not desired. In the event that it is determined not to provide MQTT services to the MQTT client, the universal MQTT server may, similar to a dedicated MQTT server, allocate an MQTT server to be provided to the MQTT client from other universal MQTT servers according to preset allocation rules.

[0086] After the universal MQTT server determines the MQTT server to provide services, it can send the address information of the MQTT server to the MQTT client, guide the MQTT client to reconnect to the appropriate universal MQTT server, and then disconnect from the MQTT client. The MQTT client sends a connection request to the other universal MQTT server pointed to by the address information provided by the universal MQTT server.

[0087] According to the MQTT load balancing method and system provided by the present application, an MQTT service cluster is formed by a dedicated MQTT server and multiple general servers. In the MQTT service cluster, the dedicated MQTT server connects to the connection of the MQTT client and allocates the MQTT server to be provided with services to the MQTT client according to the preset allocation rules. In the MQTT service cluster, after receiving the assignment from the dedicated MQTT server, the general MQTT server can provide MQTT services to the MQTT client, or allocate other MQTT servers to be provided with services to the MQTT client. In this way, the MQTT service cluster can provide load balancing for the MQTT requests of the MQTT client without the help of existing load balancing means through the redirection function of the dedicated MQTT server and / or the general MQTT server, thereby avoiding or reducing the dependence on existing load balancing means, reducing the cost of load balancing, and making the implementation process simple and fast.

[0088] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0089] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all optional embodiments, and the actions and modules involved are not necessarily required by this application.

[0090] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical connection or other forms.

[0091] Referring to FIG6 , FIG6 provides an electronic device including a processor and a memory. The memory stores computer instructions, which, when executed by the processor, enable the processor to execute the computer instructions to implement the method and detailed solutions shown in FIG2 to FIG5 .

[0092] It should be understood that the above-described device embodiments are merely illustrative, and the devices disclosed herein may also be implemented in other ways. For example, the division of units / modules described in the above-described embodiments is merely a logical functional division, and actual implementations may employ alternative divisions. For example, multiple units, modules, or components may be combined or integrated into another system, or some features may be omitted or not implemented.

[0093] In addition, unless otherwise specified, the functional units / modules in the various embodiments of the present invention may be integrated into a single unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The aforementioned integrated units / modules may be implemented in the form of hardware or software program modules.

[0094] If the integrated unit / module is implemented in hardware, the hardware may be a digital circuit, an analog circuit, or the like. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, or the like. Unless otherwise specified, the processor or chip may be any appropriate hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, or the like. Unless otherwise specified, the on-chip cache, off-chip memory, and storage may be any appropriate magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), or the like.

[0095] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions for enabling a computer electronic device (which can be a personal computer, a server or a network electronic device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned memory includes: various media that can store program codes, such as a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0096] An embodiment of the present application also provides a non-transitory computer storage medium storing a computer program. When the computer program is executed by multiple processors, the processors execute the method and detailed solutions shown in Figures 2 to 5.

[0097] The embodiments of the present application are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core ideas of the present application. At the same time, changes or modifications made by those skilled in the art based on the ideas of the present application, the specific implementation methods, and the scope of application of the present application, all fall within the scope of protection of the present application. In summary, the contents of this specification should not be construed as limiting the present application.

Claims

1. A MQTT load balancing method, applied to a dedicated MQTT server, characterized in that: include: Receive connection information from MQTT client; Based on a first preset allocation rule, allocating a universal MQTT server to be provided with services to the MQTT client from among a plurality of universal MQTT servers; Sending the address information of the universal MQTT server to be provided to the MQTT client, so that the universal MQTT server to be provided establishes a connection with the MQTT client and provides the MQTT service; and Disconnect from the MQTT client.

2. The method according to claim 1, characterized in that The allocating a universal MQTT server to be provided with services to the MQTT client from among a plurality of universal MQTT servers based on a first preset allocation rule comprises: Obtaining service characteristics of the MQTT client and / or resource occupancy information of the plurality of general MQTT servers; and According to the service characteristics of the MQTT client and / or the resource occupancy information of the multiple universal MQTT servers, and in accordance with the first preset allocation rule, a universal MQTT server to be provided for the MQTT client is allocated among the multiple universal MQTT servers.

3. A method for MQTT load balancing, applied to any one of a plurality of general MQTT servers, characterized in that: include: Receive connection requests from MQTT clients; Determine whether to provide MQTT service for the MQTT client; In the case where it is determined that the MQTT service is not provided for the MQTT client, based on a second preset allocation rule, allocating other general MQTT servers to provide services to the MQTT client from among the multiple general MQTT servers; Send the address information of the universal MQTT server to be provided to the MQTT Clients; and Disconnect from the MQTT client.

4. The method according to claim 3, characterized in that The allocating other general MQTT servers to provide services to the MQTT client from among the multiple general MQTT servers based on the second preset allocation rule includes: Obtaining service characteristics of the MQTT client and / or resource occupancy information of other general MQTT servers; and According to the service characteristics of the MQTT client and / or the resource occupancy information of other universal MQTT servers, and in accordance with the second preset allocation rule, a universal MQTT server to be provided for the MQTT client is allocated from other universal MQTT servers among the multiple universal MQTT servers.

5. A method for MQTT load balancing, applied to an MQTT client, characterized in that: include: Sending connection information to a service entry end of an MQTT service cluster, wherein the MQTT service cluster includes a dedicated MQTT server end and a plurality of general MQTT servers end; Receive first address information of a first universal MQTT server to be provided with services, which is sent by the dedicated MQTT server; as well as Send a connection request to the first universal MQTT server to provide service according to the first address information.

6. The method according to claim 5, characterized in that Also includes: Receive second address information of a second universal MQTT server to be provided with services sent by the currently connected universal MQTT server; as well as Send a connection request to the second universal MQTT server to provide service according to the second address information.

7. An MQTT load balancing system, characterized in that: include: A dedicated MQTT server, used to execute the method according to claim 1 or 2; A plurality of general MQTT servers, for executing the method according to claim 3 or 4; as well as An MQTT client, used to execute the method according to claim 5 or 6.

8. The system according to claim 7, characterized in that Also includes: The MQTT management center is used to collect the service characteristics of the MQTT client and / or the resource occupancy information of the multiple general MQTT servers in real time.

9. The system according to claim 7 or 8, characterized in that The number of the dedicated MQTT server is multiple, and the system further includes: The load balancer is used to send the connection information of the MQTT client to one of the multiple dedicated MQTT servers.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method, device and equipment for implementing load balancing, and readable storage medium

    CN109639796A

  • Active streaming media distribution load method

    CN116366555A

  • Server dynamic load balancing method and device and electronic equipment

    CN116680079A

  • MQTT load balancing method and system and computer readable storage medium

    CN117714447A

  • A system and method for MQTT client based high availability

    WO2022031162A1