Internet of Things platform load balancing method and system, storage medium and electronic equipment

By setting multi-layer load levels and building hash rings on the IoT platform, dynamically adjusting the allocation probability of IoT devices, the problem of rapid access to IoT devices leads to server breakdown, and the load balancing of each access processing node is achieved.

CN119835272AActive Publication Date: 2025-04-15FIBERHOME TELECOMMUNICATION TECHNOLOGIES CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

How to prevent servers from being broken down in the scenario of fast access to IoT devices and realize load balancing of each access processing node of the IoT platform.

Method used

By setting the multi-layer load level and corresponding load threshold parameters of the access processing node, the load situation is periodically counted, the load level is adjusted, and the original hash ring and logical hash ring are constructed through the load score, and the allocation probability of IoT devices is dynamically adjusted to achieve load balancing.

Benefits of technology

It effectively prevents the server from being broken down during rapid access to the device, and adaptively adjusts the allocation probability of IoT devices, achieving effective balance of load between each access processing node.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119835272A_ABST
    Figure CN119835272A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of Internet of Things communication, and provides an Internet of Things platform load balancing method and system, a storage medium and electronic equipment, and the method comprises the steps: setting multiple load levels of an access processing node and corresponding load threshold parameters; adjusting a load level according to the load index data and a load threshold parameter of the current access processing node; 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; adding the access processing nodes of which the load fractions are smaller than a preset threshold value into a blank hash ring to generate an original hash ring; and calculating the number of logic nodes of the access processing nodes according to the load fractions of the access processing nodes, and allocating the logic nodes of the access processing nodes on the logic hash ring according to the number of the logic nodes. According to the method, server breakdown is prevented, the distribution probability of the Internet of Things equipment is adjusted according to the load conditions of the access processing nodes, and the load conditions among the access processing nodes are effectively balanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of Internet of Things communication technology, and in particular, relates to an Internet of Things platform load balancing method, system, storage medium and electronic device. Background Art

[0002] The IoT platform accesses a large number of IoT devices to achieve centralized management, data collection and analysis, remote control, and device data security. With the surge in the number of IoT devices and the surge in data traffic, how to ensure the efficiency and stability of IoT device access processing nodes and ensure the load balancing of each access processing node has become a key challenge facing the IoT system. Therefore, there is an urgent need for a method to safely and efficiently achieve load balancing of the IoT platform when IoT devices are connected to the IoT platform. Summary of the invention

[0003] To solve the above problems, the present disclosure provides a load balancing method, system, storage medium and electronic device for an Internet of Things platform to set up multiple load levels for access processing nodes, and set load threshold parameters corresponding to each load level, determine load index data according to the load situation, compare the load index data with the load threshold parameters of the current load level, and adjust the load level after maintaining for a period of time; it 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, the original hash ring is constructed, and the number of logical nodes on the logical hash ring is dynamically adjusted by the load score of the processing node 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 situation of the access processing node, so as to more effectively balance the load situation between the access processing nodes.

[0004] The present invention is achieved through the following technical solutions:

[0005] In a first aspect, an embodiment of the present disclosure provides a method for load balancing of an Internet of Things platform, the method comprising:

[0006] Setting multiple load levels of the access processing node, and setting load threshold parameters corresponding to each load level, and determining a load calculation coefficient of the access processing node;

[0007] Periodically collecting statistics on the load of the access processing node, determining load index data, and adjusting the load level according to the load index data and a current load threshold parameter of the access processing node;

[0008] Determine a preset threshold value of the load score, and determine the load score of the access processing node according to the load indicator data, the current load threshold parameter of the access processing node and the load calculation coefficient;

[0009] Creating a blank hash ring, adding the access processing node whose load score is less than a preset threshold to the blank hash ring, and generating an original hash ring;

[0010] The original hash ring is copied to obtain a logical hash ring, the number of logical nodes of the access processing node is calculated according to the load score of the access processing node, and the logical nodes of the access processing node are allocated on the logical hash ring according to the number of logical nodes.

[0011] Furthermore,

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

[0013] The load threshold parameters corresponding to the load levels of each layer are set, and the higher the load level, the larger the load threshold parameters are. The load threshold parameters include: CPU usage threshold, memory usage threshold, device connection number threshold, and message retention number threshold;

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

[0015] Furthermore,

[0016] Periodically collect statistics on load conditions to determine load indicator data, which includes: CPU usage, memory usage, number of device connections, and number of message retention;

[0017] Comparing the load indicator data with a load threshold parameter of the i-th load level, and when the load indicator data is continuously less than the load threshold parameter of the i-th load level, raising the load level of the access processing node to the i+1-th level, where 0<i≤n;

[0018] When the load indicator data is continuously smaller 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.

[0019] Furthermore,

[0020] 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;

[0021] 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.

[0022] Furthermore,

[0023] Creating the blank hash ring, determining an access processing node whose load score is less than a preset threshold, and determining a unique identifier of the access processing node;

[0024] Using a consistent hashing algorithm, a hash value is calculated according to a unique identifier of the access processing node, and the access processing node is added to a corresponding position of the hash value on the blank hash ring;

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

[0026] Furthermore,

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

[0028]

[0029] Wherein, LN is the number of logical nodes, S is the load fraction, Floor function is a function that rounds down the calculation result, the value range of N is a natural number between 1 and 100, and the value range of M is a natural number greater than 1;

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

[0031] All access processing nodes whose load scores are less than a preset threshold calculate the number of logical nodes, and allocate logical nodes of the access processing nodes on the logical hash ring according to the number of logical nodes.

[0032] Furthermore,

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

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

[0035] When the load score of the access processing node changes and is always less than a preset threshold, the number of logical nodes is redetermined according to the load score of the access processing node. If the number of logical nodes changes, logical nodes are added or reduced in the logical hash ring according to the redetermined number of logical nodes.

[0036] In 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, the Internet of Things platform load balancing system includes: a node setting module, multiple access processing nodes, a load calculation module, a load balancing node and a registration center;

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

[0038] The access processing node is used to periodically collect statistics on load conditions, 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 used to determine a preset threshold value of the load score, determine the load score of the access processing node according to the load indicator 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;

[0040] The load balancing node is used to monitor the load scores of all the access processing nodes through the registration center; create a blank hash ring, add the access processing nodes with load scores less than a preset threshold to the blank hash ring, and 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 score of the access processing node, and allocate the logical nodes of the access processing node on the logical hash ring according to the number of logical nodes; monitor the access processing nodes of the Internet of Things platform in real time, and when it is monitored that the access processing nodes are added or reduced and the load scores of the access processing nodes change, update the original hash ring according to the load scores of the access processing nodes, and calculate the number of logical nodes of the access processing nodes according to the load scores of the access processing nodes, and update the logical nodes in the logical hash ring.

[0041] On the third aspect, based on the same inventive concept, the embodiment of the present disclosure also provides a computer-readable storage medium, storing one or more programs, which, when executed, can implement the aforementioned Internet of Things platform load balancing method.

[0042] In a fourth aspect, based on the same inventive concept, an embodiment of the present disclosure further provides an electronic device, including a processor, a communication interface, the aforementioned computer-readable storage medium, and a communication bus. The processor, the communication interface, and the computer-readable storage medium communicate with each other via the communication bus. The processor is used to execute the program stored in the aforementioned computer-readable storage medium.

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

[0044] 1. It can effectively prevent the server from being broken down when the device is quickly accessed.

[0045] 2. The allocation probability of IoT devices can be adaptively adjusted according to the load conditions of the access processing nodes, 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 partly become apparent from the description, or be understood by implementing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0048] Figure 1 A schematic diagram of the structure of an Internet of Things device connected to an Internet of Things platform provided in an embodiment of the present disclosure;

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

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

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

[0052] Figure 5A schematic diagram of selecting nodes for an Internet of Things device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0054] Figure 1 The schematic diagram of the structure of the Internet of Things device connected to the Internet of Things platform provided in the embodiment of the present disclosure is as follows: Figure 1 As shown in FIG. 1 , the IoT platform includes a device access layer, and IoT devices establish connections at the device access layer. The device access layer includes a load balancing node and multiple access processing nodes. When a physical network device establishes a connection with the IoT platform, it first accesses and obtains 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, and the load balancing node allocates an accessible access processing node according to the load conditions of multiple 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 then establishes a connection with the IoT platform.

[0056] In a first aspect, the present disclosure provides a method for load balancing of an Internet of Things platform. Figure 2 A flow chart of a load balancing method for an Internet of Things platform provided by an embodiment of the present disclosure is as follows: Figure 2 As shown, the Internet of Things platform load balancing method of the embodiment of the present disclosure includes:

[0057] S1: setting multiple load levels of the access processing node, setting load threshold parameters corresponding to each load level, and determining the load calculation coefficient of the access processing node.

[0058] S2: Periodically collect statistics on the load situation, determine the 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.

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

[0060] S4: Create a blank hash ring, add access processing nodes whose load scores are less than a preset threshold to the blank hash ring, and generate an original hash ring.

[0061] S5: 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 score of the access processing node, and allocate the logical nodes of the access processing node on the logical hash ring according to the number of logical nodes.

[0062] In the disclosed embodiment, the access processing node is divided into a plurality of load levels, each load level corresponds to a set of load threshold parameters, and the load level of the access processing node can be adjusted according to the load condition of the access processing node, thereby adjusting the load capacity of the access processing node; the load score of the access processing node is calculated, and the number of logical nodes is determined according to the load score of the access processing node, so as to achieve load balancing when the Internet of Things devices are connected to the Internet of Things platform.

[0063] In order to achieve load balancing during the operation of the Internet of Things platform, the Internet of Things platform load balancing method in the embodiment of the present disclosure also includes:

[0064] S6: monitor the access processing nodes of the IoT platform in real time. When the access processing nodes are added or reduced or the load scores of the access processing nodes are changed, update the original hash ring according to the load scores of the access processing nodes, calculate the number of logical nodes of the access processing nodes according to the load scores of the access processing nodes, and update the logical nodes in the logical hash ring.

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

[0066] In some examples, multiple load levels of the access processing node are set, and load threshold parameters corresponding to each load level are set to determine the load calculation coefficient of the access processing node, specifically including:

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

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

[0069] Specifically, each of the n load levels corresponds to a 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 the i-th layer, MPth i Indicates the memory usage threshold of the i-th layer, DCth i Indicates the threshold 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 larger the corresponding load threshold parameter is. It is understandable that the parameter types included in a set of load threshold parameters can be adjusted according to actual conditions, and can include only CPU usage threshold and memory usage threshold, or can include other parameter types besides CPU usage threshold, memory usage threshold, device connection number threshold and message retention number threshold.

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

[0071] Specifically, the load calculation coefficients CPw, MPw, DCw and MCw are determined, where 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. It can be understood that the setting of 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 type and index weight contained in the load calculation coefficient can be adjusted according to actual conditions.

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

[0073] S21: Periodically collect statistics on the load and determine load indicator data, which includes: CPU usage, memory usage, number of device connections, and number of message retention;

[0074] Specifically, in order to achieve dynamic load balancing, it is necessary to periodically count the load situation and determine the load indicator data based on the load situation. The load indicator data includes: CPU usage, memory usage, number of device connections, and number of message retention. CPU usage is recorded as CP; memory usage is recorded as MP; number of device connections is recorded as DC; number of message retention is recorded as MC.

[0075] S22: Compare the load indicator data with the load threshold parameter of the i-th load level. When the load indicator data is continuously smaller than the load threshold parameter of the i-th load level, increase the load level of the access processing node to the i+1th level, where 0<i≤n.

[0076] Specifically, taking the load level of the access processing node as the i-th layer 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; where 0<i≤n. It can be understood that in the process of comparing the load indicator data with the load threshold parameters, all parameter types can be compared with the corresponding load threshold parameters, for example: only comparing the size relationship between the CPU usage and the CPU usage threshold, the memory usage and the memory usage threshold, or using some parameter types to compare with the corresponding load threshold parameters.

[0077] S23: When the load indicator data is continuously smaller 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.

[0078] Specifically, when all load indicator data are less than the load threshold parameter corresponding to the current load level, you can choose to use part of the load indicator data to compare with the corresponding load threshold parameter to determine whether the load level can be reduced; for example: when DC drops and maintains DCth i-2 ≤DC <DCth i-1 After a certain period of time, the load level is lowered to i-1, where 0<i≤n, and the value of DCth0 is set to be fixed at 0.

[0079] In some examples, determining a preset threshold value of the load score, and determining the load score of the access processing node according to the load indicator data, the load threshold parameter of the current access processing node, and the load calculation coefficient, 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, a preset threshold value of the load score is determined. When any load indicator data is greater than the corresponding load threshold parameter, no calculation is required and it is determined that the preset threshold value of the load score is reached. If the load indicator data of all parameter types are less than the load threshold parameter of the current access processing node, the preset threshold value, load indicator data, the load threshold parameter of the current access processing node and the load calculation coefficient are used to calculate the load score.

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

[0084]

[0085] Among them, 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 number of device connections is greater than or equal to the device connection number threshold of the i-th layer, and the number of message retention is greater than or equal to the message retention 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 IoT devices can continue to be allocated to access the access processing node. If all load indicator data are less than the load threshold parameter of the current access processing node, the preset threshold, load indicator data, the load threshold parameter of the current access processing node and the load calculation coefficient are used to calculate the load score according to the above formula (1). According to the calculation result of the load score of the access processing node, for access processing nodes with a load score greater than or equal to 100, new IoT devices are no longer allocated to access; and for access processing nodes with a load score less than 100, new IoT devices continue to be allocated to access. It is understandable that when the load index data of the access processing node changes, the load score may also change accordingly. Therefore, 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 statistically analyzing the load of the access processing node and determining the load index data.

[0086] In some examples, a blank hash ring is created, and access processing nodes whose load scores are 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 an access processing node whose load score is less than a preset threshold, and determine a 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 nodes whose load scores are less than a preset threshold are determined. Taking the preset threshold as 100 as an example, the access processing nodes whose load scores are less than 100 have their unique identifiers determined.

[0089] S42: Using a consistent hashing algorithm, a hash value is calculated according to a unique identifier of the access processing node, and the access processing node is added to a corresponding position of the hash value on the blank hash ring.

[0090] Specifically, 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, and the access processing node a is added to the hash ring. The hash value H a In the corresponding position; when S a If it 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 a preset threshold are added to the blank hash ring, an original hash ring is generated.

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

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

[0094] S51: Copy the original hash ring to obtain a logical hash ring, and calculate the number of logical nodes of the access processing node according to the load score of the access processing node. The specific calculation method of the number of logical nodes is:

[0095]

[0096] Among them, LN is the number of logical nodes, S is the load score, Floor function is a function that rounds down the calculation result, N is a natural number ranging from 1 to 100, which is used to reflect the dynamic changes of the access processing node load; M represents the coefficient of expanding the logical node, and M 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, and the appropriate constants M and N should be determined according to the actual situation.

[0097] Specifically, the lower the load score of an access processing node, the smaller the load of the access processing node, the fewer access devices, and therefore, more devices can be allocated. Taking the preset threshold value 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, and the more logical nodes are allocated on the hash ring, the higher the probability of being allocated to the device. In the process of copying the original hash ring, the access processing node 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, and 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, according to the calculated number of logical nodes 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. 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 node.

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

[0101] Specifically, all access processing nodes whose load scores are less than a preset threshold are calculated according to the formula, and based on the calculated number of logical nodes 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.

[0102] In some examples, the access processing nodes of the IoT platform are monitored in real time. When it is detected that an access processing node is added or reduced or the load score of the access processing node changes, the original hash ring is updated according to the load score of the access processing node, and the number of logical nodes of the access processing node is calculated according to the load score of the access processing node, and the logical nodes in the logical hash ring are updated, specifically including:

[0103] S61: When the load score of a newly added access processing node or an existing access processing node changes from greater than a preset threshold to less than a preset threshold, an access processing node is added to the original hash ring, and the number of logical nodes 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 the load score of a new access processing node or an existing access processing node changes from greater than a preset threshold to less than a preset threshold, the access processing node is added to the original hash ring; the load score of the access processing node is calculated according to formula (1), and the number of logical nodes 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 the access processing node is reduced or the load score of the existing access processing node changes from less than the preset threshold to greater than or equal to the preset threshold, the corresponding access processing node is removed from the original hash ring, and the logical node is removed from the logical hash ring.

[0106] S63: When the load score of the access processing node changes and is always less than a preset threshold, the number of logical nodes is redetermined according to the load score of the access processing node. If the number of logical nodes changes, the corresponding logical nodes are increased or decreased in the logical hash ring according to the redetermined number of logical nodes.

[0107] Specifically, the load balancing node needs to monitor the access processing node in real time. When the load score of an access processing node that is not greater than a preset threshold changes its load score, the number of logical nodes of the access processing node is re-determined according to formula (2). Based on the changed number of logical nodes, the consistent hashing algorithm is used to update the logical hash ring.

[0108] In the disclosed embodiment, when the IoT device sends a load balancing boot request to the 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 to the IoT device k access processing nodes with load scores less than a preset threshold; based on the unique identifier of the device, calculate its hash value and add it to the logical hash ring, and then use the hash value as the starting point to find the nearest k non-repeating nodes counterclockwise, and return their connection address information to the 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; for example: set k = 3, the IoT platform includes 10 access processing nodes, of which 8 access processing nodes have load scores greater than or equal to the preset threshold, then only 2 access processing nodes can be returned to the IoT device, 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 IoT device.

[0109] In the disclosed embodiment, the consistent hashing algorithm is used to add access processing nodes to the original hash ring and to add logical nodes to the logical hash ring. In the process of IoT device connection, the hash value of the IoT device is also used to select the access processing node. When the number of access processing nodes does not change, the load score of the access processing node does not change significantly, and the number of logical nodes does not change, the same IoT device is assigned to the same access processing node when accessing the load balancing node. The contingency in the IoT device connection process is eliminated as much as possible to ensure that the device can reconnect to the same access processing node when the overall load of the IoT platform is stable.

[0110] In the disclosed embodiment, multiple load levels of access processing nodes are set, and load threshold parameters corresponding to each load level are set. According to the load situation, load index data is determined, and the load index data is compared with the load threshold parameters of the current load level. 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 device access. Based on the load score of the access processing node, the original hash ring is constructed, and the number of logical nodes on the logical hash ring is dynamically adjusted by the load score of the processing node 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 situation of the access processing node, so as to more effectively balance the load situation between 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, and 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 the i-th layer, MPth i Indicates the memory usage threshold of the i-th layer, DCth i Indicates the threshold 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 larger the corresponding load threshold parameter is.

[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] The access processing node periodically counts its own load and determines the load indicator data, which includes CPU usage, memory usage, number of device connections, and number of message retention. CPU usage is recorded as CP; memory usage is recorded as MP; number of device connections is recorded as DC; number of message retention is recorded as MC.

[0115] Taking the load level of the access processing node as the i-th layer 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 lowered to i-1, where 0<i≤n, and the value of DCth0 is set to be fixed at 0.

[0117] Determine the preset threshold value of the load score of 100, calculate the load score of each access processing node based on the load index data of each access processing node, combine the load threshold parameters and load calculation coefficient of the current access processing node, and synchronize the load score to the registration center. Periodically calculate the load score of each access processing node to dynamically monitor the load of the access processing node and make timely adjustments.

[0118] When any load indicator data is greater than the corresponding load threshold parameter, no calculation is required and it is determined to have reached the preset threshold of the load score. If all load indicator data are less than the load threshold parameter of the current access processing node, the load score is calculated using the preset threshold, load indicator 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 for determining the load score is as follows:

[0119]

[0120] Among them, 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 number of device connections is greater than or equal to the device connection number threshold of the i-th layer, and the number of message retention 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 load indicator data are less than the load threshold parameter of the current access processing node, the load score is calculated using the preset threshold, load indicator 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 access processing nodes with a load score greater than or equal to 100, new IoT devices are no longer allocated for access; and for access processing nodes with a load score less than 100, new IoT devices continue to be allocated for access.

[0121] Figure 3 The original hash ring diagram provided by the embodiment of the present disclosure is as follows: Figure 3 As shown in the figure, a blank hash ring is created, and the load scores of all access processing nodes are monitored through the registration center. Access processing nodes with a load score less than 100 are counted, and the hash value of the node is calculated through the consistent hashing algorithm. Each access processing node with a load score less than 100 is added to the blank hash ring to generate an original hash ring. The original hash ring includes access processing nodes with a load score less than 100, including: node a, node b, node c, and node d.

[0122] Take 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, and the access processing node a is added to the hash ring. The hash value H a In the corresponding position; when S a If it 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 load scores less than the 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. According to the load score of each node, the number of logical nodes 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, the Floor function is to round down the calculation result, the value range of N is a natural number between 1 and 100, and the value range of M is a natural number greater than 1. The lower the load score of the access processing node, the smaller the load of the access processing node, the fewer access devices, and therefore, more devices can be allocated. It can be seen from the calculation formula 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, and the higher the probability of being allocated to a device.

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

[0127] Take 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 The unique identifiers are calculated for their hash values, and then the access processing node a is added 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 node. 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, such as Figure 4 As shown, the logical hash ring includes access processing nodes and corresponding logical nodes, and the access processing nodes include node a, node b, node c and node d, wherein the load score size 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 nodes 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 the number of logical nodes added in the logical hash ring is small. 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 the number of logical nodes added in the logical hash ring is more. 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, which 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 to the IoT device k access processing nodes whose load scores are less than the preset threshold; 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, and then the hash value is used as the starting point to find the nearest k non-repeating nodes counterclockwise and return their connection address information to the device. Figure 5 As shown, 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 a counterclockwise direction are node c, node a, and node b. During the search process, if a duplicate node c is encountered, it is directly skipped 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 levels 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 the 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.

[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 according to 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 used 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 load scores less than a preset threshold to the blank hash ring, and 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 score of the access processing node, and allocate the logical nodes of the access processing node on the logical hash ring according to the number of logical nodes; monitor the access processing nodes of the Internet of Things platform in real time, and when it is detected that the access processing nodes are added or reduced and the load scores of the access processing nodes have changed, update the original hash ring according to the load scores of the access processing nodes, and calculate the number of logical nodes of the access processing nodes according to the load scores of the access processing nodes, and update the logical nodes in the logical hash ring.

[0138] In the disclosed embodiment, the access processing node determines the load index data according to 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 calculation module also calculates the load score of the access processing node according to 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 is achieved.

[0139] On the third aspect, based on the same inventive concept, the embodiment of the present disclosure also provides a computer-readable storage medium, storing one or more programs, which, when executed, can implement the aforementioned Internet of Things platform load balancing method.

[0140] In a fourth aspect, based on the same inventive concept, an embodiment of the present disclosure further provides an electronic device, including a processor, a communication interface, the aforementioned computer-readable storage medium, and a communication bus. The processor, the communication interface, and the computer-readable storage medium communicate with each other via the communication bus. The processor is used to execute the program stored in the aforementioned 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 lines. An indirect connection method 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 aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A load balancing method for an Internet of Things platform, characterized in that: The method comprises, Setting multiple load levels of the access processing node, and setting load threshold parameters corresponding to each load level, and determining a load calculation coefficient of the access processing node; Periodically collecting statistics on the load of the access processing node, determining load index data, and adjusting the load level according to the load index data and a current load threshold parameter of the access processing node; Determine a preset threshold value of the load score, and determine the load score of the access processing node according to the load indicator data, the current load threshold parameter of the access processing node and the load calculation coefficient; Creating a blank hash ring, adding the access processing node whose load score is less than a preset threshold to the blank hash ring, and generating an original hash ring; The original hash ring is copied to obtain a logical hash ring, the number of logical nodes of the access processing node is calculated according to the load score of the access processing node, and the logical nodes of the access processing node are allocated on the logical hash ring according to the number of logical nodes.

2. The method according to claim 1, characterized in that: The step of setting multiple load levels of the access processing node and setting load threshold parameters corresponding to each load level to determine the load calculation coefficient of the access processing node includes: According to the server and hardware specifications of the access processing node, set the n-layer load level of the access processing node; wherein n is a natural number greater than 0; The load threshold parameters corresponding to the load levels of each layer are set, and the higher the load level, the larger the load threshold parameters are. The load threshold parameters include: CPU usage threshold, memory usage threshold, device connection number threshold, and message retention number threshold; Determine the load calculation coefficient of the access processing node, the load calculation coefficient including: CPU usage index weight, memory usage index weight, device connection number index weight and message retention number index weight.

3. The method according to claim 1, characterized in that The periodic statistical 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 include: Periodically collect statistics on load conditions to determine load indicator data, which includes: CPU usage, memory usage, number of device connections, and number of message retention; Comparing the load indicator data with a load threshold parameter of the i-th load level, and when the load indicator data is continuously less than the load threshold parameter of the i-th load level, raising the load level of the access processing node to the i+1-th level, where 0<i≤n; When the load indicator data is continuously smaller 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.

4. The method according to claim 1, characterized in that The method of determining a preset threshold value of the load score, determining the load score of the access processing node according to the load indicator data, the load threshold parameter of the current access processing node and the load calculation coefficient, includes: 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; 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.

5. The method according to claim 1, characterized in that The step of creating a blank hash ring, adding access processing nodes whose load scores are less than a preset threshold to the blank hash ring, and generating an original hash ring includes: Creating the blank hash ring, determining an access processing node whose load score is less than a preset threshold, and determining a unique identifier of the access processing node; Using a consistent hashing algorithm, a hash value is calculated according to a unique identifier of the access processing node, and the access processing node is added to a corresponding position of the hash value on the blank hash ring; After all access processing nodes with load scores less than a preset threshold are added to the blank hash ring, the original hash ring is generated.

6. The method according to claim 1, characterized in that The method of copying the original hash ring to obtain a logical hash ring, calculating the number of logical nodes of the access processing node according to the load score of the access processing node, and allocating the logical nodes of the access processing node on the logical hash ring according to the number of logical nodes includes: The original hash ring is copied to obtain the logical hash ring, and the number of logical nodes of the access processing node is calculated according to the load score of the access processing node. The specific calculation method of the number of logical nodes is: Wherein, LN is the number of logical nodes, S is the load fraction, Floor function is a function that rounds down the calculation result, the value range of N is a natural number between 1 and 100, and the value range of M is a natural number greater than 1; Determine LN unique identifiers, calculate corresponding hash values ​​respectively, add the access processing node to corresponding positions of all hash values ​​on the logical hash ring, and use it as a logical node of the access processing node; All access processing nodes whose load scores are less than a preset threshold calculate the number of logical nodes, and allocate logical nodes of the access processing nodes on the logical hash ring according to the number of logical nodes.

7. The method according to claim 1, characterized in that The Internet of Things platform load balancing method further includes: When the load score of a newly added access processing node or an existing access processing node changes from being greater than a preset threshold to being less than a preset threshold, an access processing node is added to the original hash ring, and the number of logical nodes is determined according to the load score of the access processing node, and the logical hash ring is updated; When the access processing node is reduced or the load score of the existing access processing node changes from less than a preset threshold to greater than or equal to the preset threshold, the corresponding access processing node is removed from the original hash ring, and the logical node is removed from the logical hash ring; When the load score of the access processing node changes and is always less than a preset threshold, the number of logical nodes is redetermined according to the load score of the access processing node. If the number of logical nodes changes, logical nodes are added or reduced in the logical hash ring according to the redetermined number of logical nodes.

8. A load balancing system for an Internet of Things platform, characterized in that: The system includes: 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 used to set the multi-layer load level of the access processing node, and set the load threshold parameters corresponding to each layer of the load level to determine the load calculation coefficient of the access processing node; The access processing node is used to periodically collect statistics on load conditions, 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; The load calculation module is used to determine a preset threshold value of the load score, determine the load score of the access processing node according to the load indicator 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 used to monitor the load scores of all the access processing nodes through the registration center; create a blank hash ring, add the access processing nodes with load scores less than a preset threshold to the blank hash ring, and 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 score of the access processing node, and allocate the logical nodes of the access processing node on the logical hash ring according to the number of logical nodes; monitor the access processing nodes of the Internet of Things platform in real time, and when it is monitored that the access processing nodes are added or reduced and the load scores of the access processing nodes change, update the original hash ring according to the load scores of the access processing nodes, and calculate the number of logical nodes of the access processing nodes according to the load scores of the access processing nodes, and update the logical nodes in the logical hash ring.

9. A computer-readable storage medium storing one or more programs, characterized in that: When the one or more programs are executed, the Internet of Things platform load balancing method described in any one of claims 1 to 7 can be implemented.

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, the communication interface, and the computer-readable storage medium communicate with each other via a communication bus; It is characterized in that The processor is configured to execute a program stored in a computer-readable storage medium.

Citation Information

Patent Citations

  • Network request resource scheduling method and device, electronic equipment and storage medium

    CN111225059A

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

    CN112492008A

  • Load balancing method and device and electronic equipment

    CN115766737A

  • Load balancing method and system of server, and gateway

    CN117880290A

  • Distributed processing system, dispatcher, and distributed processing management device

    JP2013178677A