Iot platform load balancing method, system, storage medium and electronic device

By setting multiple layers of load levels and load threshold parameters in the IoT platform, combining the consistent hashing algorithm to build a hash ring, and dynamically adjusting the load score, the load balancing problem when IoT devices are connected is solved, server breakdown is prevented, and the processing efficiency and stability of the platform are improved.

CN119835272BActive Publication Date: 2025-10-24FIBERHOME TELECOMMUNICATION TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411780410.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-10-24
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

How to achieve load balancing when IoT devices are connected to the IoT platform to ensure efficiency and stability and prevent the server from being overwhelmed when devices are connected quickly.

Method used

By setting multiple layers of load levels and load threshold parameters, periodically collecting load indicator data, adjusting the load levels, and using the consistent hashing algorithm to construct the original hash ring and the logical hash ring, the allocation probability of IoT devices is dynamically adjusted according to the load score to achieve adaptive load balancing.

Benefits of technology

It effectively prevents the server from being overwhelmed when devices are quickly connected, achieves dynamic load balancing between access processing nodes, and improves the processing efficiency and stability of the IoT platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119835272B_ABST
    Figure CN119835272B_ABST
Patent Text Reader

Abstract

The present disclosure belongs to the technical field of Internet of Things communication, and provides an Internet of Things platform load balancing method, system, storage medium and electronic device. The method comprises the following steps: setting a multi-layer load level of an access processing node and corresponding load threshold parameters; adjusting the load level according to load index data and the load threshold parameters of the current access processing node; determining the load score of the access processing node according to the load index data, the load threshold parameters of the current access processing node and a load calculation coefficient; adding the access processing node with a load score less than a preset threshold to a blank hash ring to generate an original hash ring; calculating the logical node number of the access processing node according to the load score of the access processing node, and distributing the logical nodes of the access processing node on the logical hash ring according to the logical node number. This method prevents server breakdown, adjusts the distribution probability of Internet of Things devices according to the load condition of the access processing node, and effectively balances the load conditions among the access processing nodes.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure belongs to the technical field of Internet of Things communication, and particularly relates to an Internet of Things platform load balancing method, system, storage medium and electronic device. BACKGROUND

[0002] The Internet of Things platform accesses a large number of Internet of Things devices to realize centralized management, data collection and analysis, remote control and device data security guarantee of the Internet of Things devices. With the explosive growth of the number of Internet of Things devices and the explosive growth of data traffic, how to ensure the efficiency and stability of the Internet of Things device access processing node and ensure the load balancing of each access processing node has become a key challenge faced by the Internet of Things system. Therefore, there is an urgent need for a method for safely and efficiently realizing load balancing of an Internet of Things platform when Internet of Things devices access the Internet of Things platform. SUMMARY

[0003] To solve the above problems, the present disclosure provides an Internet of Things platform load balancing method, system, storage medium and electronic device, which sets a multi-layer load level of an access processing node, sets a load threshold parameter corresponding to each layer of the load level, determines load index data according to the load condition, compares the load index data with the load threshold parameter of the current load level, adjusts the load level after a period of time, and can effectively prevent the server from being broken down in the scenario of rapid device access. Based on the load score of the access processing node, an original hash ring is constructed, and the number of logical nodes of the processing node on the logical hash ring is dynamically adjusted through the load score of the processing node, so as to dynamically adjust the distribution probability of the Internet of Things device, and the distribution probability of the Internet of Things device can be adaptively adjusted according to the load condition of the access processing node, so as to more effectively balance the load condition between the access processing nodes.

[0004] The present application is realized by the following technical solutions:

[0005] In a first aspect, the embodiments of the present disclosure provide an Internet of Things platform load balancing method, which comprises,

[0006] setting a multi-layer load level of an access processing node, setting a load threshold parameter corresponding to each layer of the load level, determining a load calculation coefficient of the access processing node;

[0007] periodically counting the load condition of the access processing node, determining load index data, and adjusting the load level according to the load index data and the load threshold parameter of the current access processing node;

[0008] determining a preset threshold of the load score, determining the load score of the access processing node according to the load index data, the load threshold parameter of the current access processing node and the load calculation coefficient;

[0009] create a blank hash ring, add the access processing node with a load score less than a preset threshold to the blank hash ring, and generate an original hash ring;

[0010] copy the original hash ring to obtain a logical hash ring, calculate a logical node number of the access processing node according to the load score of the access processing node, and allocate a logical node of the access processing node on the logical hash ring according to the logical node number.

[0011] Further,

[0012] set the n-layer load level of the access processing node according to the server and hardware specifications of the access processing node; wherein n is a natural number greater than 0;

[0013] set the load threshold parameter corresponding to each layer of the load level, and the load threshold parameter is greater as the load level is higher, and the load threshold parameter includes a CPU usage rate threshold, a memory usage rate threshold, a device connection number threshold, and a message backlog number threshold;

[0014] determine the load calculation coefficient of the access processing node, and the load calculation coefficient includes a CPU usage rate index weight, a memory usage rate index weight, a device connection number index weight, and a message backlog number index weight.

[0015] Further,

[0016] periodically determine load index data by periodically counting the load, and the load index data includes a CPU usage rate, a memory usage rate, a device connection number, and a message backlog number;

[0017] compare the load index data with the load threshold parameter of the i-layer load level, and when the load index data continuously is less than the load threshold parameter of the i-layer load level, increase the load level of the access processing node to the i+1-layer, wherein 0

[0018] when the load index data continuously is less than the load threshold parameter of the i-1-layer load level, decrease the load level of the access processing node to the i-1-layer, wherein 0

[0019] Further,

[0020] when the load index data is greater than or equal to the load threshold parameter of the current access processing node, determine that the preset threshold of the load score is reached;

[0021] If the load index data is less than the load threshold parameter of the current access processing node, a load score is calculated using the preset threshold, the load index data, the load threshold parameter of the current access processing node, and a load calculation coefficient.

[0022] Further,

[0023] The blank hash ring is created, an access processing node with a load score less than a preset threshold is determined, and a unique identifier of the access processing node is determined.

[0024] A consistent hash algorithm is used to calculate a hash value according to the unique identifier of the access processing node, and the access processing node is added to a corresponding position on the hash value on the blank hash ring.

[0025] After all access processing nodes with a load score less than a preset threshold are added to the blank hash ring, the original hash ring is generated.

[0026] Further,

[0027] The original hash ring is copied to obtain the logical hash ring, and the logical node number of the access processing node is calculated according to the load score of the access processing node. The specific calculation method of the logical node number is as follows:

[0028]

[0029] Wherein, LN is the logical node number, S is the load score, Floor function is a down rounding function, N is a natural number in the range of 1-100, and M is a natural number greater than 1.

[0030] A unique identifier LN is determined, a corresponding hash value is calculated, the access processing node is added to a corresponding position on the hash value on the logical hash ring, and the logical node of the access processing node is used.

[0031] All access processing nodes with a load score less than a preset threshold calculate the logical node number, and the logical node of the access processing node is distributed on the logical hash ring according to the logical node number.

[0032] Further,

[0033] When a new access processing node is added or the load score of an existing access processing node changes from greater than a preset threshold to less than a preset threshold, the access processing node is added in the original hash ring, the logical node number is determined according to the load score of the access processing node, and the logical hash ring is updated.

[0034] When the load fraction of the access processing node or the existing access processing node changes from being less than the preset threshold to being greater than or equal to the preset threshold, the corresponding access processing node is removed from the original hash ring, and a logical node is removed in the logical hash ring;

[0035] When the load fraction of the access processing node changes and is always not greater than the preset threshold, the number of logical nodes is re-determined according to the load fraction of the access processing node, and if the number of logical nodes changes, a logical node is added or removed in the logical hash ring according to the re-determined number of logical nodes.

[0036] In a second aspect, based on the same inventive concept, the embodiments of the present disclosure further provide an Internet of Things platform load balancing system, which comprises a node setting module, a plurality of access processing nodes, a load calculation module, a load balancing node and a registration center.

[0037] The node setting module is configured to set a multi-layer load level of the access processing node, set a load threshold parameter corresponding to each layer of the load level, and determine a load calculation coefficient of the access processing node.

[0038] The access processing node is configured to periodically calculate a load condition, determine load index data, and adjust the load level according to the load index data and the load threshold parameter of the current access processing node.

[0039] The load calculation module is configured to determine a preset threshold of the load fraction, determine the load fraction of the access processing node according to the load index data, the load threshold parameter of the current access processing node and the load calculation coefficient, and synchronize the load fraction of the access processing node to the registration center.

[0040] The load balancing node is configured to monitor the load fraction of all the access processing nodes through the registration center, create a blank hash ring, add the access processing node with a load fraction less than the preset threshold to the blank hash ring to generate an original hash ring, copy the original hash ring to obtain a logical hash ring, calculate the number of logical nodes of the access processing node according to the load fraction of the access processing node, distribute the logical nodes of the access processing node on the logical hash ring according to the number of logical nodes, monitor the access processing node of the Internet of Things platform in real time, and when a new access processing node or a reduced access processing node is monitored or the load fraction of the access processing node changes, update the original hash ring according to the load fraction of the access processing node, calculate the number of logical nodes of the access processing node according to the load fraction of the access processing node, and update the logical node in the logical hash ring.

[0041] In a third aspect, based on the same inventive concept, the present disclosure further provides a computer-readable storage medium storing one or more programs, which when executed, implement the foregoing load balancing method for an Internet of Things platform.

[0042] In a fourth aspect, based on the same inventive concept, the present disclosure further provides an electronic device, which includes a processor, a communication interface, the foregoing computer-readable storage medium, and a communication bus. The processor, the communication interface, and the computer-readable storage medium communicate with each other through the communication bus. The processor is configured to execute the program stored in the computer-readable storage medium.

[0043] Compared with the prior art, the present disclosure has the following advantages:

[0044] 1. The server can be effectively prevented from being broken down in the scenario of fast access of the device.

[0045] 2. The distribution probability of the Internet of Things device can be adaptively adjusted according to the load condition of the access processing node, so as to more effectively balance the load conditions among the access processing nodes.

[0046] Other features and advantages of the present disclosure will be described in the following description, and some will become apparent from the description, or will be learned through implementation of the present disclosure. The purpose and other advantages of the present disclosure can be achieved and obtained through the structure indicated in the specification, claims, and drawings. BRIEF DESCRIPTION OF DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings needed to be used in the embodiment or prior art description. Obviously, the drawings in the following description are some embodiments of the present disclosure, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0048] Figure 1 A structure schematic diagram of the Internet of Things device connecting the Internet of Things platform provided by the present disclosure embodiment;

[0049] Figure 2 A flowchart of the load balancing method for the Internet of Things platform provided by the present disclosure embodiment;

[0050] Figure 3 A schematic diagram of the original hash ring provided by the present disclosure embodiment;

[0051] Figure 4 A schematic diagram of the logical hash ring provided by the present disclosure embodiment;

[0052] Figure 5A schematic diagram of an IoT device selection node provided by an embodiment of the present disclosure is shown in FIG. 1. DETAILED DESCRIPTION

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some but not all of the embodiments of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present disclosure.

[0054] Figure 1 A structure schematic diagram of an IoT device connecting an IoT platform provided by an embodiment of the present disclosure is shown in FIG. 2. Figure 1 As shown in FIG. 2, the IoT platform includes a device access layer, and the IoT device establishes a connection in the device access layer. The device access layer includes a load balancing node and a plurality of access processing nodes. When a physical network device establishes a connection with the IoT platform, it first accesses and acquires the address of the access processing node through the load balancing node, and then initiates an actual connection with the IoT platform through the access processing node.

[0055] Specifically, the IoT device accesses the load balancing node, the load balancing node allocates an accessible access processing node according to the load conditions of the plurality of access processing nodes, and returns the IP (Internet Protocol) address or MAC (Media Access Control) address of the allocated access processing node to the IoT device. The IoT device establishes a connection with the corresponding access processing node, and further establishes a connection with the IoT platform.

[0056] In a first aspect, an embodiment of the present disclosure provides an IoT platform load balancing method, Figure 2 A flowchart of an IoT platform load balancing method provided by an embodiment of the present disclosure is shown in FIG. 3. Figure 2 As shown in FIG. 3, the IoT platform load balancing method of the present embodiment includes:

[0057] S1: setting a multi-layer load level of the access processing node, setting a load threshold parameter corresponding to each load level, and determining a load calculation coefficient of the access processing node.

[0058] S2: periodically counting the load condition, determining load index data, and adjusting the load level according to the load index data and the load threshold parameter of the current access processing node.

[0059] S3: determining a preset threshold of the load score, determining the load score of the access processing node according to the load index data, the load threshold parameter of the current access processing node and the load calculation coefficient.

[0060] S4: creating a blank hash ring, adding the access processing node with the load score less than the preset threshold into the blank hash ring to generate an original hash ring.

[0061] S5: copying the original hash ring to obtain a logical hash ring, calculating the logical node number of the access processing node according to the load score of the access processing node, and allocating the logical node of the access processing node on the logical hash ring according to the logical node number.

[0062] In the embodiments of the present disclosure, the access processing node is divided into multiple load levels, each load level corresponds to a set of load threshold parameters, the load level of the access processing node can be adjusted according to the load condition of the access processing node, and the load capacity of the access processing node is adjusted; the load score of the access processing node is calculated, and the logical node number is determined according to the load score of the access processing node, so that load balancing is realized in the process of connecting the Internet of Things device to the Internet of Things platform.

[0063] In order to realize load balancing in the working process of the Internet of Things platform, the Internet of Things platform load balancing method in the embodiments of the present disclosure further comprises:

[0064] S6: real-time monitoring of the access processing node of the Internet of Things platform, when the newly added or reduced access processing node is monitored, or the load score of the access processing node changes, updating the original hash ring according to the load score of the access processing node, and calculating the logical node number of the access processing node according to the load score of the access processing node, and updating the logical node in the logical hash ring.

[0065] The following is a further implementation of the Internet of Things platform load balancing method provided in the embodiments of the present disclosure.

[0066] In some examples, a multi-layer load level of the access processing node is set, and a load threshold parameter corresponding to each load level is set, a load calculation coefficient of the access processing node is determined, specifically including:

[0067] S11: setting n-layer load level of the access processing node according to the server and hardware specifications of the access processing node; wherein n is a natural number greater than 0.

[0068] S12: setting the load threshold parameter corresponding to each load level, and the higher the load level, the larger the load threshold parameter, and the load threshold parameter includes: CPU usage threshold, memory usage threshold, device connection number threshold and message backlog number threshold.

[0069] Specifically, n levels of load levels correspond to a set of load threshold parameters respectively, which can be represented by an array, [{CPth1, MPth1, DCth1, MCth1}, {CPth2, MPth2, DCth2, MCth2}, …, {CPth n , MPth n , DCth n , MCth n}]. Taking the i-th level of load level as an example, where CPth i represents the CPU usage threshold of the i-th level, MPth i represents the memory usage threshold of the i-th level, DCth i represents the device connection threshold of the i-th level, and MCth i represents the message retention threshold of the i-th level. The higher the load level, the larger the i value, and the larger the corresponding load threshold parameter. Understandably, the parameter types contained in a set of load threshold parameters can be adjusted according to actual conditions, and can only contain CPU usage threshold and memory usage threshold, or can include CPU usage threshold, memory usage threshold, device connection threshold and message retention threshold and other parameter types.

[0070] S13: Determine the load calculation coefficient of the access processing node, including: CPU usage index weight, memory usage index weight, device connection number index weight and message retention number index weight.

[0071] Specifically, the load calculation coefficients CPw, MPw, DCw and MCw are determined, w is a natural number greater than 0, wherein CPw represents the CPU usage index weight, MPw represents the memory usage index weight, DCw represents the device connection number index weight, and MCw represents the message retention number index weight. Understandably, the load calculation coefficient is set according to the server and hardware specifications of the access processing node, and is related to the processing performance of the access processing node. The specific setting of the load calculation coefficient, as well as the parameter types and index weights contained in the load calculation coefficient, can be adjusted according to actual conditions.

[0072] In some examples, according to the load condition, the load index data is determined, and according to the load index data and the load threshold parameter of the current access processing node, the load level is adjusted, specifically including:

[0073] S21: Periodically statistics load condition, determine load index data, including: CPU usage, memory usage, device connection number and message retention number;

[0074] Specifically, in order to realize dynamic load balancing, it is necessary to periodically count the load situation, determine load index data according to the load situation, and the load index data includes: CPU usage, memory usage, device connection number and message retention number. The CPU usage is denoted as CP; the memory usage is denoted as MP; the device connection number is denoted as DC; and the message retention number is denoted as MC.

[0075] S22: comparing the load index data with the load threshold parameter of the i-th load level, and when the load index data continuously is less than the load threshold parameter of the i-th load level, the load level of the access processing node is increased to i+1, wherein 0

[0076] Specifically, taking the load level of the access processing node as the i-th level as an example, the load index data is compared with the load threshold parameter of the i-th load level; when the load index data continuously is less than the load threshold parameter of the i-th load level, that is, the state of CP≤CPth i and MP≤MPth i is maintained for a certain time, the load level is adjusted to i+1, and more devices are allowed to access until the highest level, that is, the n-th level; wherein 0

[0077] S23: when the load index data continuously is less than the load threshold parameter of the i-1-th load level, the load level of the access processing node is decreased to i-1, wherein 0

[0078] Specifically, when all the load index data is less than the load threshold parameter corresponding to the current load level, part of the load index data can be selected to be compared with the corresponding load threshold parameter to determine whether the load level can be decreased; for example: when DC is decreased and the state of DCth i-2 ≤DC<DCth i-1 is maintained for a certain time, the load level is decreased to i-1, wherein 0

[0079] In some examples, a preset threshold of the load score is determined, and the load score of the access processing node is determined according to the load index data, the load threshold parameter of the current access processing node and the load calculation coefficient, and specifically includes:

[0080] S31: When the load indicator data is greater than or equal to the load threshold parameter of the current access processing node, it is determined that the preset threshold of the load score is reached.

[0081] S32: If the load indicator data is less than the load threshold parameter of the current access processing node, the load score is calculated using the preset threshold, the load indicator data, the load threshold parameter of the current access processing node, and the load calculation coefficient.

[0082] Specifically, the preset threshold of the load score is determined. When any load indicator data is greater than the corresponding load threshold parameter, it is determined that the preset threshold of the load score is reached without calculation. If all load indicator data of the parameter type is less than the load threshold parameter of the current access processing node, the load score is calculated using the preset threshold, the load indicator data, the load threshold parameter of the current access processing node, and the load calculation coefficient.

[0083] Taking 100 as an example of the preset threshold of the load score of the access processing node, when the load level of the access processing node is determined to be the i-th layer, the specific calculation method of the load score of the access processing node is as follows:

[0084]

[0085] When the load level of the access processing node is the i-th layer, the CPU usage is greater than or equal to the CPU usage threshold of the i-th layer, the memory usage is greater than or equal to the memory usage threshold of the i-th layer, the device connection number is greater than or equal to the device connection number threshold of the i-th layer, and the message backlog number is greater than or equal to the message backlog number threshold of the i-th layer, the load score is 100, and the access processing node no longer allocates new devices to access. When the load score is less than 100, new Internet of Things devices can continue to be allocated to access the access processing node. If all load indicator data is less than the load threshold parameter of the current access processing node, the load score is calculated using the preset threshold, the load indicator data, the load threshold parameter of the current access processing node, and the load calculation coefficient according to the above formula (1). According to the calculation result of the load score of the access processing node, for the access processing node with a load score greater than or equal to 100, no new Internet of Things devices are allocated to access; and for the access processing node with a load score less than 100, new Internet of Things devices continue to be allocated to access. Understandably, when the load indicator data of the access processing node changes, the load score may also change accordingly, so the calculation of the load score of the access processing node should also be a periodic process, which can be consistent with the period of determining the load indicator data.

[0086] In some examples, a blank hash ring is created, and access processing nodes with a load score less than a preset threshold are added to the blank hash ring to generate an original hash ring, specifically including:

[0087] S41: create a blank hash ring, determine the access processing node whose load score is less than the preset threshold, and determine the unique identifier of the access processing node.

[0088] Specifically, a blank hash ring is created, and the load scores of all access processing nodes are monitored through the registration center. The access processing node whose load score is less than the preset threshold is determined, and the unique identifier of the access processing node is determined, taking 100 as the preset threshold for example.

[0089] S42: using a consistent hash algorithm, calculating the hash value according to the unique identifier of the access processing node, and adding the access processing node to the corresponding position of the hash value on the blank hash ring.

[0090] Specifically, taking the access processing node a as an example, its unique identifier is ID a , and the load score is S a . When S a is less than 100, the hash value H a = Hash (ID a ) is calculated, where Hash is a hash calculation function. It can be understood that any kind of consistent hash algorithm with good balance can be used to calculate the hash value. The access processing node a is added to the corresponding position of the hash value H a in the hash ring; when S a is greater than or equal to 100, the access processing node is ignored.

[0091] S43: after all access processing nodes whose load scores are less than the preset threshold are added to the blank hash ring, the original hash ring is generated.

[0092] Specifically, steps S41 and S42 are used to traverse all access processing nodes, and all access processing nodes whose load scores are less than the preset threshold are added to the blank hash ring to generate the original hash ring.

[0093] In some examples, the original hash ring is copied to obtain a logical hash ring, the logical node number of the access processing node is calculated according to the load score of the access processing node, and the logical node of the access processing node is allocated on the logical hash ring according to the logical node number, which specifically includes:

[0094] S51: copying the original hash ring to obtain a logical hash ring, calculating the logical node number of the access processing node according to the load score of the access processing node, and the specific calculation method of the logical node number is:

[0095]

[0096] Where LN is the number of logical nodes, S is the load fraction, and the Floor function rounds down the calculated result. N ranges from 1 to 100, reflecting the dynamic changes in the access processing node load. M represents the coefficient for expanding the logical nodes, and its value range is a natural number greater than 1. The selection of the number of logical nodes is crucial to the performance and load balancing of the entire IoT platform. The appropriate constants M and N should be determined based on the actual situation.

[0097] Specifically, the lower the load score of an access processing node, the smaller the load on the access processing node and the fewer access devices. Therefore, more devices can be allocated. Taking the preset threshold of the load score of the access processing node as 100 as an example, it can be seen from calculation formula (2) that the lower the load score of the access processing node, the more logical nodes are calculated. The more logical nodes are allocated on the hash ring, the higher the probability of being allocated to a device. In the process of copying the original hash ring, the access processing nodes must be copied at the same time. Therefore, the logical hash ring includes all the access processing nodes and corresponding logical nodes in the original hash ring. The logical nodes in the logical hash ring are all regarded as corresponding access processing nodes.

[0098] S52: Determine LN unique identifiers, calculate corresponding hash values ​​respectively, add the access processing node to the corresponding positions of all hash values ​​on the logical hash ring, and use it as the logical node of the access processing node.

[0099] Specifically, based on the calculated number of logical nodes of the access processing node, the consistent hash algorithm is used to calculate the hash values ​​of all logical nodes and add them to the logical hash ring. Taking access processing node a as an example, for its load score S a , when S a When it is less than 100, calculate the number of logical nodes LN a and with ID a Create LN as a basis a A unique identifier for this LN a LN is calculated for each unique identifier a Hash value, and then add access processing node a to LN a The corresponding position of the hash value on the logical hash ring is used as the LN of the access processing node a logical nodes.

[0100] S53: Calculate the number of logical nodes for all access processing nodes whose load scores are less than a preset threshold, and allocate logical nodes of the access processing nodes on the logical hash ring according to the number of logical nodes.

[0101] Specifically, all access processing nodes with a load score less than a preset threshold are calculated according to the formula, and according to the logical node number of the access processing node obtained by calculation, a consistent hashing algorithm is used to calculate the hash value of all logical nodes and add them to the logical hash ring.

[0102] In some examples, the access processing nodes of the Internet of Things platform are monitored in real time. When a new access processing node is added or an access processing node is reduced, or the load score of an access processing node changes, the original hash ring is updated according to the load score of the access processing node, and the logical node number of the access processing node is calculated according to the load score of the access processing node, and the logical node in the logical hash ring is updated. Specifically, it includes:

[0103] S61: When a new access processing node is added or the load score of an existing access processing node changes from greater than a preset threshold to less than a preset threshold, the access processing node is added in the original hash ring, and the logical node number is determined according to the load score of the access processing node, and the logical hash ring is updated.

[0104] Specifically, in order to dynamically adjust the load balancing of the Internet of Things platform, the load balancing node needs to monitor the access processing node in real time. When a new access processing node is added or the load score of an existing access processing node changes from greater than a preset threshold to less than a preset threshold, the access processing node is added in the original hash ring; the load score of the access processing node is calculated according to formula (1), the logical node number is determined according to the load score of the access processing node using formula (2), and the logical hash ring is updated using a consistent hashing algorithm.

[0105] S62: When an access processing node is reduced or the load score of an existing access processing node changes from less than a preset threshold to greater than or equal to a preset threshold, the corresponding access processing node is removed from the original hash ring, and the logical node is removed in the logical hash ring.

[0106] S63: When the load score of the access processing node changes and is always not greater than a preset threshold, the logical node number is re-determined according to the load score of the access processing node. If the logical node number changes, the corresponding logical node is added or reduced in the logical hash ring according to the re-determined logical node number.

[0107] Specifically, the load balancing node needs to monitor the access processing node in real time. When the access processing node with a load score not greater than a preset threshold changes the load score, the logical node number of the access processing node is re-determined according to formula (2), and the logical hash ring is updated using a consistent hashing algorithm according to the changed logical node number.

[0108] In the embodiments of the present disclosure, when the Internet of Things device sends a load balancing guide request to the load balancing node, the load balancing node needs to return the connection address information of at most k available access processing nodes to the device, that is, return k access processing nodes with load scores less than the preset threshold to the Internet of Things device; according to the unique identifier of the device, the hash value thereof is calculated and added to the logical hash ring, and then the nearest k non-repeating nodes are found counterclockwise from the hash value as the starting point, and the connection address information thereof is returned to the device. When k is greater than or equal to the number of currently available access processing nodes, the connection address information of all available access processing nodes is directly returned to the device; for example, k is set to 3, and the Internet of Things platform includes 10 access processing nodes, of which 8 access processing nodes have load scores greater than or equal to the preset threshold, so only 2 access processing nodes can be returned to the Internet of Things device, and at this time, the connection address information of the 2 access processing nodes with load scores less than the preset threshold is returned to the Internet of Things device.

[0109] In the embodiments of the present disclosure, the consistent hash algorithm is used to add access processing nodes on the original hash ring and logical nodes on the logical hash ring, and the hash value of the Internet of Things device is also used in the process of connecting the Internet of Things device to select the access processing node; in the case that the number of access processing nodes does not change, the load score of the access processing node does not change greatly, and the number of logical nodes does not change, the same access processing node is allocated to the same Internet of Things device when the Internet of Things device accesses the load balancing node. The randomness in the process of connecting the Internet of Things device is eliminated as much as possible, and the Internet of Things device can be reconnected to the same access processing node under the condition that the overall load of the Internet of Things platform is stable.

[0110] In the embodiments of the present disclosure, a multi-layer load level of the access processing node is set, and a load threshold parameter corresponding to each layer load level is set, the load index data is determined according to the load condition, the load index data is compared with the load threshold parameter of the current load level, and after a period of time, the load level is adjusted, which can effectively prevent the server from being broken down in the scenario of rapid access of the device. Based on the load score of the access processing node, the original hash ring is constructed, and the number of logical nodes of the processing node on the logical hash ring is dynamically adjusted through the load score of the processing node, so as to achieve dynamic adjustment of the allocation probability of the Internet of Things device, and the allocation probability of the Internet of Things device can be adaptively adjusted according to the load condition of the access processing node, so as to more effectively balance the load condition among the access processing nodes.

[0111] Embodiment 1:

[0112] According to the server and hardware specifications of the access processing node, set the n-layer load level of the access processing node, where n is a natural number greater than 0. Each load level corresponds to a set of load threshold parameters; the n-layer load levels correspond to their own set of load threshold parameters, which can be represented by an array, [{CPth1, MPth1, DCth1, MCth1}, {CPth2, MPth2, DCth2, MCth2}, ..., {CPth n , MPth n , DCth n , MCth n Taking the i-th load level as an example, CPth i Indicates the CPU usage threshold of layer i, MPth i Indicates the memory usage threshold of layer i, DCth i Indicates the threshold value of the number of device connections at layer i, MCth i Indicates the message retention threshold of the i-th layer. The higher the load level, the larger the i value is, and the corresponding load threshold parameter is larger.

[0113] Determine the load calculation coefficient of the access processing node. The load calculation coefficients include: CPw, MPw, DCw, and MCw, where w is a natural number greater than 0. CPw represents the CPU usage indicator weight, MPw represents the memory usage indicator weight, DCw represents the device connection number indicator weight, and MCw represents the message retention number indicator weight.

[0114] Access processing nodes periodically collect statistics on their own load and determine load metrics, which include CPU utilization, memory utilization, number of device connections, and number of retained messages. CPU utilization is denoted as CP; memory utilization is denoted as MP; number of device connections is denoted as DC; and number of retained messages is denoted as MC.

[0115] Taking the load level of the access processing node as layer i as an example, the load index data is compared with the load threshold parameter of the i-th load level. When the load index data is continuously less than the load threshold parameter of the i-th load level, that is, CP≤CPth i and MP≤MPth i After a certain period of time, the load level is adjusted to the i+1th layer, allowing more devices to be connected until the highest layer, that is, the nth layer, is reached. Among them, 0<i≤n.

[0116] When the load indicator data is continuously less than the load threshold parameter of the i-1th load level, the load level of the access processing node is reduced to the i-1th level, where 0<i≤n. For example: when DC decreases and maintains DCth i-2 ≤DC <DCth i-1After a certain period of time, the load level is adjusted to i-1, where 0 < i < n, and the value of DCth0 is fixed to 0.

[0117] The preset threshold of the load score is determined, the load score of each access processing node is calculated according to the load index data counted by each access processing node, the load threshold parameter and the load calculation coefficient of the current access processing node are comprehensively considered, and the load score is synchronized to the registration center. The load score of each access processing node is periodically calculated, so as to dynamically monitor the load condition of the access processing node and timely adjust.

[0118] When any load index data is greater than the corresponding load threshold parameter, it is not necessary to calculate, and it is determined that the preset threshold of the load score is reached. If all the load index data is less than the load threshold parameter of the current access processing node, the load score is calculated using the preset threshold, the load index data, the load threshold parameter of the current access processing node and the load calculation coefficient. Taking the load level of the access processing node as the i-th layer as an example, the specific calculation method of the load score is as follows:

[0119]

[0120] When the load level of the access processing node is the i-th layer, the CPU usage is greater than or equal to the CPU usage threshold of the i-th layer, the memory usage is greater than or equal to the memory usage threshold of the i-th layer, the device connection number is greater than or equal to the device connection number threshold of the i-th layer, and the message retention number is greater than or equal to the message retention number threshold of the i-th layer, the load score is 100, and the node no longer allocates new device access. When the load score is less than 100, new device access can continue to be allocated. If all the load index data is less than the load threshold parameter of the current access processing node, the load score is calculated using the preset threshold, the load index data, the load threshold parameter of the current access processing node and the load calculation coefficient. According to the calculation result of the load score of the access processing node, for the access processing node with the load score greater than or equal to 100, new Internet of Things device access is no longer allocated; and for the access processing node with the load score less than 100, new Internet of Things device access is continued to be allocated.

[0121] Figure 3 The original hash ring diagram provided by the embodiment of the disclosure is shown in FIG. 1. Figure 3 As shown in FIG. 1, a blank hash ring is created, and the load scores of all access processing nodes are monitored through the registration center. The access processing nodes with the load score less than 100 are counted, the hash values of the nodes are calculated through the consistent hash algorithm, the access processing nodes with the load score less than 100 are added to the blank hash ring, and the original hash ring is generated. The access processing nodes with the load score less than 100 on the original hash ring include node a, node b, node c and node d.

[0122] Taking access processing node a as an example, its unique identifier is ID a , the load fraction is S a When S a If it is less than 100, calculate its hash value H a =Hash(ID a ), where the Hash function is a hash calculation function. It is understandable that any well-balanced consistent hashing algorithm can be used to calculate the hash value. The access processing node a is added to the hash ring. The hash value H a In the corresponding position; when S a If the load score is greater than or equal to 100, the access processing node is ignored. All access processing nodes are traversed and all access processing nodes with a load score less than a preset threshold are added to the blank hash ring to generate the original hash ring.

[0123] The original hash ring is copied and used as a logical hash ring. Based on the load score of each node, the logical node number LN of all access processing nodes is calculated. The specific calculation formula is:

[0124]

[0125] Where LN is the number of logical nodes, S is the load score, and the Floor function rounds down the calculated result. N ranges from 1 to 100, and M ranges from 1 to 1. Access processing nodes with lower load scores experience lower loads and fewer connected devices, allowing for more device allocation. The calculation formula shows that the lower the load score of an access processing node, the greater the number of logical nodes calculated. The more logical nodes allocated on the hash ring, the higher the probability of device allocation.

[0126] Based on the calculated logical node number of the access processing node, the consistent hashing algorithm is used to calculate the hash values ​​of all logical nodes and add them to the logical hash ring. The remaining access processing nodes are calculated according to the formula. Based on the calculated logical node number of the access processing node, the consistent hashing algorithm is used to calculate the hash values ​​of all logical nodes and add them to the logical hash ring.

[0127] Taking access processing node a as an example, for its load score S a , when S a When it is less than 100, calculate the number of logical nodes LN a , the specific formula is as follows:

[0128]

[0129] By ID a Create LN as a basisa A unique identifier for this LN a Calculate the hash value of each unique identifier, and then add the access processing node a to the LN a The corresponding position of the hash value on the logical hash ring is used as the LN of the access processing node a logical nodes. When S a If it is greater than or equal to 100, the access processing node is ignored.

[0130] Figure 4 A schematic diagram of a logical hash ring provided in an embodiment of the present disclosure is shown in FIG. Figure 4 As shown, the logical hash ring includes access processing nodes and corresponding logical nodes. The access processing nodes include node a, node b, node c and node d, where the load score relationship of the four nodes is node d>node a>node b>node c. The number of logical nodes is calculated for node a, node b, node c and node d, and the aforementioned method is used to add the logical nodes to the logical hash ring; the logical node of node a is added to the logical hash ring, and only logical node a1 and logical node a2 are shown in the figure; the logical nodes of two node b are added to the logical hash ring, and only logical node b1 and logical node b2 are shown in the figure; the logical node of node c is added to the logical hash ring, and only logical node c1, logical node c2 and logical node c3 are shown in the figure; the logical node of node d is added to the logical hash ring, and only logical node d1 is shown in the figure. Since the load score of node d is large, the calculated number of logical nodes is small, and fewer logical nodes are added to the logical hash ring. When the IoT device is connected, the probability of being selected is low; conversely, since the load score of node c is small, the calculated number of logical nodes is large, and more logical nodes are added to the logical hash ring. When the IoT device is connected, the probability of being selected is high.

[0131] The load balancing node continuously monitors the access processing nodes. When a new access processing node is detected, or the load score of the access processing node drops from greater than or equal to 100 to less than 100, the aforementioned method is used to determine the number of logical nodes and add the logical node to the logical hash ring; when a reduction in the access processing node is detected, or the load score of the access processing node increases from less than 100 to greater than or equal to 100, the access processing node is removed from the original hash ring and the logical hash ring; when a change in the load score of the access processing node is detected, and this causes a change in the number of logical nodes, the corresponding number of access processing nodes is added or reduced in the logical hash ring.

[0132] When an IoT device sends a load balancing boot request to a load balancing node, the load balancing node needs to return the connection address information of up to k available access processing nodes to the device, that is, return k access processing nodes with load scores less than a preset threshold to the IoT device; when k is greater than or equal to the current number of available access processing nodes, the connection address information of all available access processing nodes is directly returned to the device. Based on the unique identifier of the device, its hash value is calculated and added to the logical hash ring. Then, starting from the hash value, the nearest k non-repeating nodes are searched counterclockwise and their connection address information is returned to the device. Figure 5 As shown in the figure, each logical node in the logical hash ring is regarded as a corresponding access processing node. If three access processing nodes need to be selected, in the logical hash ring, starting from the location of the hash value of the IoT device, the three nodes found in the counterclockwise direction are node c, node a, and node b. During the search process, if a duplicate node c is encountered, it is skipped directly and no longer added.

[0133] On the second aspect, based on the same inventive concept, the embodiment of the present disclosure also provides an Internet of Things platform load balancing system, which includes: a node setting module, multiple access processing nodes, a load calculation module, a load balancing node and a registration center.

[0134] The node setting module is used to set the multi-layer load level of the access processing node, set the load threshold parameters corresponding to each load level, and determine the load calculation coefficient of the access processing node.

[0135] The access processing node is used to periodically collect statistics on the load situation, determine load index data, and adjust the load level according to the load index data and the load threshold parameters of the current access processing node.

[0136] The load calculation module is used to determine the preset threshold of the load score, determine the load score of the access processing node based on the load indicator data, the load threshold parameter of the current access processing node and the load calculation coefficient, and synchronize the load score of the access processing node to the registration center.

[0137] The load balancing node is configured to monitor the load scores of all access processing nodes through the registration center, create a blank hash ring, add the access processing nodes with the load scores less than a preset threshold to the blank hash ring to generate an original hash ring, copy the original hash ring to obtain a logical hash ring, calculate the logical node number of the access processing nodes according to the load scores of the access processing nodes, and allocate the logical nodes of the access processing nodes on the logical hash ring according to the logical node number. The load balancing node is configured to monitor the access processing nodes of the Internet of Things platform in real time, and when a new access processing node is added or an access processing node is reduced or the load score of an access processing node changes, update the original hash ring according to the load score of the access processing node, calculate the logical node number of the access processing node according to the load score of the access processing node, and update the logical nodes in the logical hash ring.

[0138] In the embodiments of the present disclosure, the access processing node determines the load index data at a certain period, and adjusts the load level in real time according to the load index data and the load threshold parameter of the current access processing node. At the same time, the load operation module also calculates the load score of the access processing node at a certain period, so that the load balancing node can update the original hash ring and the logical hash ring in real time, thereby dynamically adjusting the load balancing of the Internet of Things platform.

[0139] In a third aspect, based on the same inventive concept, the embodiments of the present disclosure also provide a computer readable storage medium, which stores one or more programs, and when the one or more programs are executed, the foregoing Internet of Things platform load balancing method can be implemented.

[0140] In a fourth aspect, based on the same inventive concept, the embodiments of the present disclosure also provide an electronic device, which includes a processor, a communication interface, the foregoing computer readable storage medium and a communication bus. The processor, the communication interface and the computer readable storage medium communicate with each other through the communication bus. The processor is configured to execute the program stored in the computer readable storage medium.

[0141] It should be noted that the electrical connection between the above-mentioned units does not necessarily mean the connection between the lines, and the indirect connection mode can be applied to the embodiments of the present disclosure as long as the purpose of the present disclosure is achieved.

[0142] Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalent features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. An Internet of Things platform load balancing method, characterized in that, The method comprises, setting a multi-layer load level of an access processing node, setting a load threshold parameter corresponding to each layer of the load level, and determining a load calculation coefficient of the access processing node; periodically counting the load of the access processing node to determine load index data, and adjusting the load level according to the load index data and the load threshold parameter of the current access processing node; determining a preset threshold of the load score, determining the load score of the access processing node according to the load index data, the load threshold parameter of the current access processing node, and the load calculation coefficient; creating a blank hash ring, adding the access processing node with a load score less than the preset threshold to the blank hash ring to generate an original hash ring; copying the original hash ring to obtain a logical hash ring, calculating the logical node number of the access processing node according to the load score of the access processing node, and distributing the logical node of the access processing node on the logical hash ring according to the logical node number; when a new access processing node is added or an access processing node is reduced, or the load score of the access processing node changes, updating the original hash ring according to the load score of the access processing node.

2. The method of claim 1, wherein, The method comprises: setting the n-layer load level of the access processing node according to the server and hardware specifications of the access processing node; wherein n is a natural number greater than 0; setting the load threshold parameter corresponding to each layer of the load level, and the load threshold parameter is greater as the load level is higher; the load threshold parameter comprises a CPU usage threshold, a memory usage threshold, a device connection number threshold, and a message backlog number threshold; determining the load calculation coefficient of the access processing node, which comprises a CPU usage index weight, a memory usage index weight, a device connection number index weight, and a message backlog number index weight.

3. The method of claim 1, wherein, The method comprises: periodically counting the load to determine the load index data, which comprises CPU usage, memory usage, device connection number, and message backlog number; comparing the load index data with the load threshold parameter of the i-layer load level; when the load index data continuously is less than the load threshold parameter of the i-layer load level, the load level of the access processing node is increased to i+1; wherein 0 when the load index data continuously is less than the load threshold parameter of the i-1-layer load level, the load level of the access processing node is decreased to i-1; wherein 0 The method comprises:

4. The method of claim 1, wherein, determining the preset threshold of the load score, determining the load score of the access processing node according to the load index data, the load threshold parameter of the current access processing node, and the load calculation coefficient. determining that a preset threshold of a load score is reached when the load indicator data is greater than or equal to a load threshold parameter of the current access processing node; calculating a load score using the preset threshold, the load indicator data, a load threshold parameter of the current access processing node and a load calculation coefficient when the load indicator data is less than the load threshold parameter of the current access processing node.

5. The method of claim 1, wherein, the creating of the blank hash ring, the adding of the access processing nodes with the load scores less than the preset threshold to the blank hash ring, and the generating of an original hash ring, comprising: the creating of the blank hash ring, the determining of the access processing nodes with the load scores less than the preset threshold, and the determining of unique identifiers of the access processing nodes; the using of a consistent hash algorithm, the calculating of hash values according to the unique identifiers of the access processing nodes, and the adding of the access processing nodes to corresponding positions on the hash values on the blank hash ring; the generating of the original hash ring after all the access processing nodes with the load scores less than the preset threshold are added to the blank hash ring.

6. The method of claim 1, wherein, the copying of the original hash ring to obtain a logical hash ring, the calculating of a logical node number of the access processing node according to the load score of the access processing node, and the allocating of a logical node of the access processing node on the logical hash ring according to the logical node number, comprising: the copying of the original hash ring to obtain the logical hash ring, the calculating of the logical node number of the access processing node according to the load score of the access processing node, and the specific calculation method of the logical node number being: ; wherein LN is the logical node number, S is the load score, the Floor function is a function of taking down the calculation result, N is a natural number in the range of 1-100, and M is a natural number greater than 1; the determining of LN unique identifiers, the calculating of corresponding hash values, and the adding of the access processing nodes to corresponding positions on all the hash values on the logical hash ring as logical nodes of the access processing nodes; all the access processing nodes with the load scores less than the preset threshold calculate the logical node number and allocate the logical nodes of the access processing nodes on the logical hash ring according to the logical node number.

7. The method of claim 1, wherein, the method further comprises: when a new access processing node is added or the load score of an existing access processing node changes from being greater than the preset threshold to being less than the preset threshold, adding the access processing node in the original hash ring and determining the logical node number according to the load score of the access processing node to update the logical hash ring; when an access processing node is reduced or the load score of an existing access processing node changes from being less than the preset threshold to being greater than or equal to the preset threshold, removing the corresponding access processing node from the original hash ring and removing the logical node in the logical hash ring; when the load score of the access processing node changes and is always not greater than the preset threshold, redetermining the logical node number according to the load score of the access processing node, and if the logical node number changes, adding or reducing the logical node in the logical hash ring according to the redetermined logical node number.

8. An Internet of Things platform load balancing system, characterized in that, The system comprises a node setting module, a plurality of access processing nodes, a load calculation module, a load balancing node and a registration center. The node setting module is configured to set a multi-layer load level of the access processing nodes, set a load threshold parameter corresponding to each layer of the load level, and determine a load calculation coefficient of the access processing nodes. The access processing node is configured to periodically calculate a load condition and determine load index data, and adjust the load level according to the load index data and a current load threshold parameter of the access processing node. The load calculation module is configured to determine a preset threshold of a load score, determine a load score of the access processing node according to the load index data, the current load threshold parameter of the access processing node and the load calculation coefficient, and synchronize the load score of the access processing node to the registration center. The load balancing node is configured to monitor the load score of all the access processing nodes through the registration center, create a blank hash ring, add the access processing node with a load score less than the preset threshold to the blank hash ring to generate an original hash ring, copy the original hash ring to obtain a logical hash ring, calculate a logical node number of the access processing node according to the load score of the access processing node, distribute a logical node of the access processing node on the logical hash ring according to the logical node number, monitor the access processing node of the Internet of Things platform in real time, and when a new access processing node is added or an access processing node is reduced or the load score of an access processing node changes, update the original hash ring according to the load score of the access processing node, calculate the logical node number of the access processing node according to the load score of the access processing node, and update the logical node in the logical hash ring.

9. A computer readable storage medium storing one or more programs, wherein when the one or more programs are executed, the method of claim 1-7 is implemented. The processor, the communication interface and the computer readable storage medium communicate with each other through the communication bus. 10.An electronic device comprising a processor, a communication interface, the computer readable storage medium of claim 9, and a communication bus; wherein, The processor is configured to execute the program stored in the computer readable storage medium. ​ ​

Citation Information

Patent Citations

  • Node position determination method and device, computer equipment and storage medium

    CN112492008A

  • Load balancing method and device and electronic equipment

    CN115766737A