Load balancing methods, apparatus, devices, and storage media for message middleware

By reading and weighting the load status data from the load files of message middleware nodes, identifying overloaded nodes and deleting them from the message queue, the problem of unbalanced load in traditional message middleware is solved, and adaptive load balancing is achieved.

CN115604267BActive Publication Date: 2026-03-10SHENZHEN OURUIBO ELECTRONICS
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Traditional message middleware cannot achieve adaptive load balancing, which can lead to excessive load on certain nodes and cause load imbalance.

Method used

Load balancing is achieved by reading load status data from the node load file of the message middleware, performing weighted calculations, identifying overloaded nodes, and deleting target message queues.

Benefits of technology

Adaptive load balancing of message middleware nodes was achieved, improving the system's adaptability and load balancing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115604267B_ABST
    Figure CN115604267B_ABST
Patent Text Reader

Abstract

This application relates to a load balancing method, apparatus, device, and storage medium for message middleware. The method includes: reading at least two load status data for each message middleware node in the message middleware from a node load file corresponding to the message middleware; the node load file is generated by executing a script to write the load status data of each message middleware node obtained from the message middleware into a corresponding file; performing a weighted calculation on the at least two load status data according to the weight corresponding to each type of load status data to obtain a load characterization value for each message middleware node; determining target message middleware nodes that meet the overload conditions based on the load characterization values; and determining and deleting at least one target message queue from the message queues created in the target message middleware nodes. This method can improve the adaptability of message middleware.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of message transmission technology, and in particular to a load balancing method, apparatus, device, and storage medium for message middleware. Background Technology

[0002] With the development of message transmission technology, the concept of message middleware has been proposed. Message middleware can handle network communication. When the network connection is unavailable, the message is temporarily stored in the queue. When the network is available again, the message is forwarded to the corresponding application or service, which can realize asynchronous communication in distributed systems.

[0003] In traditional technologies, message middleware cannot achieve adaptive load balancing. If a large amount of business data is created on a single message middleware node in the message middleware cluster, it will result in a high load on that message middleware node, leading to an imbalance in the load of message middleware nodes. Summary of the Invention

[0004] Therefore, it is necessary to provide a load balancing method, apparatus, computer device, computer-readable storage medium, and computer program product for message middleware that can improve adaptability in response to the above-mentioned technical problems.

[0005] Firstly, this application provides a load balancing method for message middleware. The method includes:

[0006] Read at least two load status data of each message middleware node in the message middleware from the node load file corresponding to the message middleware; the node load file is generated by executing a script to write the load status data of each message middleware node obtained from the message middleware into the corresponding file;

[0007] Based on the weight corresponding to each type of load status data, a weighted calculation is performed on the at least two types of load status data to obtain the load characterization value of each message middleware node.

[0008] Based on the load characterization value, the target message middleware node that meets the overload condition is determined;

[0009] Identify at least one target message queue from the message queues created from the target message middleware node and delete it.

[0010] In one embodiment, reading at least two load status data for each message middleware node in the message middleware from the node load file corresponding to the message middleware includes:

[0011] By dynamically adjusting the service and reading data according to a preset time period, at least two load status data of each message middleware node in the message middleware are read from the node load file corresponding to the message middleware.

[0012] The dynamic adjustment service is a service application used to dynamically delete messages from the message queue.

[0013] In one embodiment, the load status data includes resource usage data of the message middleware node's processor and pending task data; the step of weighting the at least two types of load status data according to the weight corresponding to each type of load status data to obtain the load characterization value of each message middleware node includes:

[0014] Based on the task type corresponding to the message middleware node, determine the first weight corresponding to the resource consumption data and the second weight corresponding to the task data to be processed.

[0015] The resource usage data and the task data to be processed are weighted and calculated according to the first weight and the second weight to obtain the load characterization value of each message middleware node.

[0016] In one embodiment, before reading at least two load state data for each message middleware node in the message middleware from the node load file corresponding to the message middleware, the method further includes:

[0017] By executing the script and following the preset writing time period, the resource usage data and pending task data of the processor of each message middleware node are obtained from the message middleware, thus obtaining the load status data of each message middleware node.

[0018] By executing the script, the load status data of each message middleware node is written to the node load file.

[0019] In one embodiment, determining the target message middleware node that meets the overload condition based on the load characterization value includes:

[0020] The overload threshold is determined based on the load characterization value of each message middleware node;

[0021] Identify the target message middleware node whose load characterization value has reached the overload threshold.

[0022] In one embodiment, determining and deleting at least one target message queue from the message queues created from the target message middleware node includes:

[0023] Based on a pre-configured set of deletable queues, at least one target message queue is selected from the message queues created in the target message middleware node; the selected target message queue matches the queue element in the set of deletable queues.

[0024] Delete at least one of the target message queues.

[0025] In one embodiment, the target message queue is created by the target business service application; after determining and deleting at least one target message queue from the message queues created from the target message middleware node, the method further includes:

[0026] If the target message queue is deleted, the target message queue is randomly reconstructed to any message middleware node in the message middleware through the target business service application.

[0027] Secondly, this application also provides a load balancing device for message middleware. The device includes:

[0028] The acquisition module is used to read at least two load status data of each message middleware node in the message middleware from the node load file corresponding to the message middleware; the node load file is generated by executing a script to write the load status data of each message middleware node obtained from the message middleware into the corresponding file.

[0029] The calculation module is used to perform weighted calculation on the at least two load state data according to the weight corresponding to each type of load state data, so as to obtain the load characterization value of each message middleware node.

[0030] The determination module is used to determine the target message middleware node that meets the overload condition based on the load characterization value; and to determine and delete at least one target message queue from the message queues created by the target message middleware node.

[0031] In one embodiment, the acquisition module is used to read at least two load status data of each message middleware node in the message middleware from the node load file corresponding to the message middleware according to a preset reading time period by dynamically adjusting the service; wherein, the dynamic adjustment service is a service application used to dynamically delete message queues.

[0032] In one embodiment, the load status data includes resource usage data of the processor of the message middleware node and pending task data; the calculation module is further configured to determine a first weight corresponding to the resource usage data and a second weight corresponding to the pending task data based on the task type corresponding to the message middleware node; and to perform weighted calculation on the resource usage data and the pending task data according to the first weight and the second weight to obtain the load characterization value of each message middleware node.

[0033] In one embodiment, the acquisition module is further configured to obtain the resource usage data and pending task data of the processor of each message middleware node from the message middleware by executing a script according to a preset writing time period, thereby obtaining the load status data of each message middleware node; and to write the load status data of each message middleware node into the node load file by executing a script.

[0034] In one embodiment, the determining module is configured to determine an overload threshold based on the load characterization value of each message middleware node; and to determine the target message middleware node whose load characterization value reaches the overload threshold.

[0035] In one embodiment, the determining module is configured to select at least one target message queue from the message queues created in the target message middleware node based on a pre-configured set of deletable queues; the selected target message queue matches a queue element in the set of deletable queues; and delete the at least one target message queue.

[0036] In one embodiment, the target message queue is created by the target business service application; the determining module is used to randomly reconstruct the target message queue to any message middleware node in the message middleware by the target business service application when the target message queue is deleted.

[0037] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the various embodiments of the method described in this application.

[0038] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the methods described in the embodiments of this application.

[0039] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the methods described in the various embodiments of this application.

[0040] The aforementioned load balancing method, apparatus, computer equipment, storage medium, and computer program product for message middleware reads at least two load status data for each message middleware node from the node load file corresponding to the message middleware. The node load file is generated by executing a script to write the load status data of each message middleware node obtained from the message middleware into a corresponding file. Based on the weight corresponding to each load status data, a weighted calculation is performed on the at least two load status data to obtain a load characterization value for each message middleware node. Based on the load characterization value, a target message middleware node that meets the overload condition is determined. At least one target message queue is determined from the message queues created in the target message middleware node and deleted. By calculating the load characterization value of each middleware node using load status data and corresponding weights, and subsequently deleting the target message queue after determining the target message middleware node that meets the overload condition to reduce the load, the load of the message middleware node can be adaptively adjusted, improving adaptability. Attached Figure Description

[0041] Figure 1 This is an application environment diagram of a load balancing method for message middleware in one embodiment;

[0042] Figure 2 This is a flowchart illustrating a load balancing method for a message middleware in one embodiment.

[0043] Figure 3 This is an architecture diagram of a load balancing method for a message middleware in one embodiment;

[0044] Figure 4 This is a structural block diagram of a load balancing device for a message middleware in one embodiment;

[0045] Figure 5 This is an internal structural diagram of a computer device in one embodiment;

[0046] Figure 6 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0048] The load balancing method for message middleware provided in this application can be applied to, for example... Figure 1In the application environment shown, message middleware 102 communicates with load balancing server 104 via a network. Load balancing server 104 can execute scripts to obtain load status data of each message middleware node from the message middleware and write this data to corresponding files to generate a node load file for message middleware 102. Load balancing server 104 can read at least two types of load status data for each message middleware node in message middleware 102 from the node load file. Load balancing server 104 can perform weighted calculations on the at least two types of load status data according to the weights corresponding to each type of load status data to obtain a load characterization value for each message middleware node. Based on the load characterization value, load balancing server 104 can determine target message middleware nodes that meet the overload conditions. Load balancing server 104 can determine at least one target message queue from the message queues created in the target message middleware node and delete it. Both message middleware 102 and load balancing server 104 can be implemented using independent servers or a server cluster consisting of multiple servers.

[0049] In one embodiment, message middleware 102 can be implemented by a server cluster consisting of multiple servers. Each message middleware node can involve one or more servers. The message middleware is based on queue and message passing technology to support synchronous or asynchronous, reliable message transmission. After establishing a connection with a business service application, each message middleware node can support message transmission by the business service application; that is, the message middleware node is used to establish a connection with the business service application so that the business service application can create a message queue within the message middleware node. The business service application is a service program used to support business applications deployed on the terminal. It can be understood that the business application on the terminal responds to user operations, generates corresponding messages, and sends these messages to the connected message middleware nodes through the business service application deployed on the application server.

[0050] In one embodiment, within a smart home scenario, a business application is deployed in the smart central control device. This device can respond to control operations on home devices and create control commands through the business application. The smart central control device can communicate with the application server via a network, sending the control commands to the application server. The application server can then use the business service application to create the control commands and store them in the message queue of the connected target middleware node.

[0051] In one embodiment, the business service application can be deployed on a terminal, which can communicate with the message middleware via a network. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc.

[0052] In one embodiment, such as Figure 2 As shown, a load balancing method for message middleware is provided, which can be applied to... Figure 1 Taking the load balancing server in the example, the following steps are included:

[0053] S202, Read at least two load status data for each message middleware node in the message middleware from the node load file corresponding to the message middleware.

[0054] The node load file is generated by executing a script to write the load status data of each message middleware node obtained from the message middleware into the corresponding file. The load status data indicates the load status of the message middleware nodes. It can be understood that multiple load status data can reflect the load status of message middleware nodes from multiple dimensions. For example, one load status data reflects the busy level of the message middleware node, while another reflects the load amount of the message middleware node.

[0055] Specifically, the load balancing server can obtain the load status data of each message middleware node from the message middleware by executing a script, and write the obtained load status data to a file to obtain the node load file corresponding to the message middleware. The load balancing server can then read various load status data of each message middleware node from the node load file corresponding to the message middleware.

[0056] In one embodiment, each message middleware node can run independently in a container of a running application, or independently on a terminal or server, or independently on a virtual host of a cloud service.

[0057] S204. Based on the weight corresponding to each type of load status data, perform weighted calculation on at least two types of load status data to obtain the load representation value of each message middleware node.

[0058] The load characterization value is used to represent the overall load status of the message middleware node. It can be understood that each load status data can only represent the load status in a single dimension; the load characterization value obtained by combining at least two load status data can comprehensively reflect the load status of the message middleware node.

[0059] Specifically, the load balancing server has pre-defined weights for each type of load status data. The load balancing server can use these weights to perform a weighted summation to obtain the load representation value for each message middleware node. In other words, the load balancing server can use the weights corresponding to each type of load status data to perform weighted summation, obtaining weighted load status data for each type. The load balancing server can then calculate the summation of these weighted load status data to obtain the load representation value for each middleware node.

[0060] S206, Based on the load characterization value, determine the target message middleware node that meets the overload condition; from the message queues created from the target message middleware node, determine at least one target message queue and delete it.

[0061] Specifically, a message middleware consists of multiple message middleware nodes. A load balancing server can determine the average load characteristics of these multiple message middleware nodes to obtain the average load for the corresponding message middleware. Based on this average load, the load balancing server can determine which nodes meet the overload criteria. The load balancing server can then identify target message middleware nodes that meet the overload criteria from among the multiple message middleware nodes, and then identify and delete at least one target message queue from the message queues created by the target message middleware node.

[0062] In one embodiment, the overload condition can be a fixed percentage by which the load characteristic value exceeds the average load. It can be understood that when the load characteristic value exceeds the average load by a fixed percentage, the corresponding message middleware node can be designated as the target middleware node. For example, the fixed percentage could be 30%, meaning the load characteristic value exceeds the average load by 30%, or more than 1.3 times the average load, in which case the corresponding message middleware node can be designated as the target middleware node.

[0063] In the aforementioned load balancing method for message middleware, at least two load status data points for each message middleware node are read from the node load file corresponding to the message middleware. The node load file is generated by executing a script to write the load status data of each message middleware node obtained from the message middleware into the corresponding file. Based on the weight corresponding to each load status data point, a weighted calculation is performed on the at least two load status data points to obtain the load characterization value for each message middleware node. Based on the load characterization value, target message middleware nodes that meet the overload conditions are determined. At least one target message queue is determined and deleted from the message queues created in the target message middleware nodes. By calculating the load characterization value for each middleware node using load status data and corresponding weights, and subsequently deleting the target message queue after determining the target message middleware node that meets the overload conditions to reduce the load, the load of the message middleware nodes can be adaptively adjusted, improving adaptability.

[0064] In one embodiment, the step of reading at least two load status data of each message middleware node in the message middleware from the node load file corresponding to the message middleware includes: reading at least two load status data of each message middleware node in the message middleware from the node load file corresponding to the message middleware through a dynamic adjustment service, according to a preset reading time period; wherein, the dynamic adjustment service is a service application used to dynamically delete message queues.

[0065] The preset reading time period is a fixed time interval for reading load status data, such as 2 seconds.

[0066] Specifically, the load balancing server deploys a dynamic balancing service. This service reads various load status data for each message middleware node from the node load file corresponding to the message middleware at preset time intervals. The load balancing server then writes the read load status data back to the node load file.

[0067] In one embodiment, the load balancing server can write the read load status data to the node load file according to a preset write time period. The preset write time period is a fixed time interval for writing load status data to the file. The preset write time period and the preset read time period can be the same.

[0068] In one embodiment, the preset write time period can be less than or equal to the preset read time period to ensure that the load adjustment server can read new load status data.

[0069] In this embodiment, by dynamically adjusting the service and reading at least two load status data of each message middleware node from the node load file corresponding to the message middleware according to a preset reading time period, load balancing of the message middleware can be performed based on the read load status data, thereby improving adaptability.

[0070] In one embodiment, the load status data includes the resource usage data of the processor of the message middleware node and the data of tasks to be processed; according to the weight corresponding to each type of load status data, a weighted calculation is performed on at least two types of load status data to obtain the load characterization value of each message middleware node, including: determining a first weight corresponding to the resource usage data and a second weight corresponding to the data of tasks to be processed based on the task type corresponding to the message middleware node; and performing a weighted calculation on the resource usage data and the data of tasks to be processed according to the first weight and the second weight to obtain the load characterization value of each message middleware node.

[0071] The resource usage data indicates the busy level of the message middleware node. The pending task data indicates the load on the message middleware node. It's understandable that if a message middleware node is too busy or has too high a load, it will crash and be unable to continue supporting message transmission.

[0072] The task type refers to the type of task processed by the message middleware node processor. For example, task types can include compute-intensive (CPU-bound) and access-intensive (IO-bound). Compute-intensive tasks involve a large amount of computation, consuming significant processor resources. Therefore, processing compute-intensive tasks has a greater impact on resource consumption than processing unprocessed tasks. Access-intensive tasks, on the other hand, consume very few computational resources, spending most of their time waiting for I / O operations to complete. Therefore, processing access-intensive tasks has a smaller impact on task resource consumption than processing unprocessed tasks.

[0073] Specifically, the load balancing server pre-sets different weights for different task types and different load status data. It can be understood that the second weight corresponding to computationally intensive task data is set higher than that for access-intensive data, and the first weight corresponding to access-intensive resource consumption data is set higher than that for computationally intensive data. The load balancing server can determine the first weight corresponding to the resource consumption data and the second weight corresponding to the task data to be processed, matching the task type of the message middleware node. The load balancing server can use the first and second weights to perform a weighted summation of the resource consumption data and the task data to be processed, obtaining the load characterization value for each message middleware node. It can be understood that the load balancing server can use the first weight to weight the resource consumption data, and use the second weight to weight the task data to be processed, obtaining the weighted task data to be processed. The load balancing server can sum the weighted resource consumption data and the weighted task data to obtain the load characterization value for the message middleware node.

[0074] In this embodiment, based on the task type corresponding to the message middleware node, a first weight corresponding to the resource occupancy data and a second weight corresponding to the pending task data are determined. The resource occupancy data and pending task data are weighted according to the first weight and the second weight to obtain the load characterization value of each message middleware node. Subsequently, the target message middleware node can be determined based on the load characterization value. By deleting the target message queue of the target message middleware node, load balancing of the message middleware is achieved.

[0075] In one embodiment, before reading at least two load status data of each message middleware node from the node load file corresponding to the message middleware, the method further includes: obtaining the processor resource usage data and pending task data of each message middleware node from the message middleware by executing a script according to a preset writing time period, thereby obtaining the load status data of each message middleware node; and writing the load status data of each message middleware node into the node load file by executing a script.

[0076] Specifically, resource usage data can include the processor utilization rate (CPUrate) of message middleware nodes. Task pending data can include the processor load (CPUload) of the message middleware. The load balancing server can execute scripts to retrieve the processor utilization rate and processor load of each message middleware node from the message middleware at preset writing time intervals, thus obtaining the load status data of each message middleware node. The load balancing server can then execute scripts to write the load status data of each message middleware node to a node load file. In essence, the load balancing server can read two types of load status data from each message middleware node: processor utilization and processor load.

[0077] Processor utilization represents the actual workload of the processor. Processor utilization can indicate the busy status of message middleware nodes. Processor load represents the number of tasks waiting to use the processor. Processor load can indicate the load on message middleware nodes.

[0078] In one embodiment, the load characterization value = processor utilization * first weight + processor load * second weight.

[0079] In this embodiment, by executing a script, the resource usage data of the processor and the data of tasks to be processed of each message middleware node are obtained from the message middleware according to a preset writing time period, so as to obtain the load status data of each message middleware node; by executing a script, the load status data of each message middleware node is written into the node load file, and load balancing of the message middleware can be performed based on the load status data in the node load file in the future.

[0080] In one embodiment, the step of determining the target message middleware node that meets the overload condition based on the load characterization value includes: determining the overload threshold based on the load characterization value of each message middleware node; and determining the target message middleware node whose load characterization value reaches the overload threshold.

[0081] The overload threshold is a threshold used to determine whether an item is overloaded.

[0082] Specifically, the overload threshold can be equal to a fixed multiple of the average load. The load adjustment server can determine the message middleware node with the highest load characteristic value from multiple message middleware nodes. The load adjustment server can calculate the difference between the highest load characteristic value and the average load value to obtain the load difference. If the ratio of the load difference to the average load value is greater than a fixed percentage, the highest load characteristic value is determined to have reached the overload threshold, and the corresponding message middleware node is designated as the target message middleware node. The fixed percentage matches a fixed multiple; the fixed percentage is equal to the fixed multiple minus 1. For example, if the fixed percentage is 30%, the overload condition could be (highest load characteristic value – average load value) / average load value > 30%.

[0083] In one embodiment, when the load representation values ​​of multiple message middleware nodes reach the overload threshold, the message middleware node with the largest load representation value is adjusted each time until the load representation value of that message middleware node is no longer the largest. The next adjustment will select another message middleware node (the message middleware node corresponding to the largest load representation value) for adjustment, so that the load of message middleware nodes whose load representation value exceeds the average load by 30% will be adjusted down.

[0084] In this embodiment, an overload threshold is determined based on the load characterization value of each message middleware node; the target message middleware node whose load characterization value reaches the overload threshold is identified, and the overloaded target message middleware node can be continuously adjusted to achieve load balancing of the message middleware and improve adaptability.

[0085] In one embodiment, the step of determining and deleting at least one target message queue from the message queues created in the target message middleware node includes: selecting at least one target message queue from the message queues created in the target message middleware node based on a pre-configured set of deletable queues; matching the selected target message queue with a queue element in the set of deletable queues; and deleting at least one target message queue.

[0086] The deletable queue set includes information about message queues that significantly impact message middleware nodes. It can be understood that queue elements in the deletable queue set correspond to message queue attributes. For example, a queue element might indicate a message queue with an inbound / outbound rate exceeding a preset maximum rate. It's understood that an inbound / outbound rate exceeding 1000 times per second will significantly impact the message middleware's load.

[0087] Specifically, the load balancing server can determine a pre-configured set of deletable queues, select a target message queue from the message queues created in the target message middleware node that matches the queue element in the set of deletable queues, and delete the target message queue.

[0088] In one embodiment, when multiple message queues match multiple queue elements, the load balancing server can arbitrarily select one of these message queues as the target message queue. It is understood that the message queues indicated in the deletable queue set are those that have a significant impact on the load; randomly selecting one is preferable to selecting the message queue with the largest message volume. Directly selecting the queue with the largest deleted message volume might cause the load on that message middleware node to decrease too quickly, leading to an imbalance.

[0089] In one embodiment, deleting a message queue may result in message loss. Therefore, message queues that may lose messages should not be recorded in the deletable queue set. The deletable queue set can be modified manually according to the specific circumstances.

[0090] In one embodiment, the load balancing server can communicate with the application server to determine the original message queue created by the target business service application. If the target message queue matches the original message queue, the target message queue is deleted. It can be understood that the match between the target message queue and the original message queue indicates that there are no lost messages in the target message queue.

[0091] In one embodiment, if the target message queue does not match the original message queue, the load balancing server can redetermine the target message queue.

[0092] In this embodiment, based on a pre-configured set of deletable queues, at least one target message queue is selected from the message queues created in the target message middleware node; the selected target message queue matches the queue element in the set of deletable queues; at least one target message queue is deleted, thereby achieving load balancing of the message middleware and improving its adaptability.

[0093] In one embodiment, the target message queue is created by the target business service application; after identifying and deleting at least one target message queue from the message queues created from the target message middleware node, the method further includes: if the target message queue is deleted, randomly reconstructing the target message queue to any message middleware node in the message middleware by the target business service application.

[0094] Specifically, if the target message queue is deleted, the application server where the target business service application resides can learn about the deletion event by listening to the message middleware. The application server can then randomly reconstruct the target message queue to any message middleware node in the message middleware through the target business service application.

[0095] In one embodiment, multiple business service applications exist, deployed across a cluster of application servers. When a business application service starts, the application server establishes a connection with the message middleware using a round-robin method; therefore, the message middleware node connected to the business service application is not fixed. After detecting when the target message queue has been deleted, the application server hosting the target business service application recreates the target message queue on any message middleware node through the connection with the message middleware.

[0096] In one embodiment, the target message queue is rebuilt to any message middleware node by an application server that is first connected to the message middleware. It is understood that a cluster of multiple application servers can detect when the target message queue is deleted, and all application servers can rebuild the target message queue; therefore, reconstruction is performed by an application server that is first connected to the message middleware.

[0097] In this embodiment, when the target message queue is deleted, the target message queue is randomly rebuilt to any message middleware node in the message middleware by the target business service application. This achieves load balancing while supporting message transmission as much as possible, thus improving adaptability.

[0098] In one embodiment, such as Figure 3 The diagram illustrates the architecture of a load balancing method for message middleware. The load balancing server can execute a script to retrieve the processor utilization and processor load of each message middleware node at preset write intervals. The preset write interval can be 2 seconds, and the script can be a shell script. The load balancing server can then write the retrieved processor utilization and processor load to a node load file. The node load file contains the processor utilization and processor load of each message middleware node in the message middleware.

[0099] The load balancing server can dynamically adjust the data by reading the processor utilization and processor load of each message middleware node from the node load file at preset time intervals. It then performs a weighted summation of the processor utilization and processor load to obtain the load characterization value for each message middleware node. The load balancing server can then dynamically determine the maximum load characterization value and the average load value. If the load difference between the maximum load characterization value and the average load value exceeds a fixed percentage of the average load value, the message middleware node corresponding to the maximum load characterization value is designated as the target middleware node.

[0100] The load balancing server can dynamically adjust the service to determine any message queue that matches an element in the deletable queue set, obtain the target message queue, and then delete it. The application server can then recreate the target message queue through the target business service application after detecting its deletion.

[0101] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0102] Based on the same inventive concept, this application also provides a load balancing device for message middleware for implementing the load balancing method for message middleware described above. The solution provided by this device is similar to the implementation described in the above method. Therefore, the specific limitations of one or more embodiments of the load balancing device for message middleware provided below can be found in the limitations of the load balancing method for message middleware described above, and will not be repeated here.

[0103] In one embodiment, such as Figure 4 As shown, a load balancing device 400 for message middleware is provided, including: an acquisition module 402, a calculation module 404, and a determination module 406, wherein:

[0104] The acquisition module 402 is used to read at least two load status data of each message middleware node in the message middleware from the node load file corresponding to the message middleware; the node load file is generated by executing a script to write the load status data of each message middleware node obtained from the message middleware into the corresponding file.

[0105] The calculation module 404 is used to perform weighted calculation on the at least two load state data according to the weight corresponding to each type of load state data, so as to obtain the load characterization value of each message middleware node.

[0106] The determination module 406 is used to determine the target message middleware node that meets the overload condition based on the load characterization value; and to determine and delete at least one target message queue from the message queues created by the target message middleware node.

[0107] In one embodiment, the acquisition module 402 is used to read at least two load status data of each message middleware node in the message middleware from the node load file corresponding to the message middleware according to a preset reading time period by dynamically adjusting the service; wherein, the dynamic adjustment service is a service application used to dynamically delete message queues.

[0108] In one embodiment, the load status data includes the resource usage data of the processor of the message middleware node and the data of tasks to be processed; the calculation module 404 is further configured to determine the first weight corresponding to the resource usage data and the second weight corresponding to the data of tasks to be processed based on the task type corresponding to the message middleware node; and to perform weighted calculation on the resource usage data and the data of tasks to be processed according to the first weight and the second weight to obtain the load characterization value of each message middleware node.

[0109] In one embodiment, the acquisition module 402 is further configured to obtain the resource usage data and pending task data of the processor of each message middleware node from the message middleware by executing a script according to a preset writing time period, thereby obtaining the load status data of each message middleware node; and to write the load status data of each message middleware node into the node load file by executing a script.

[0110] In one embodiment, the determining module 406 is used to determine an overload threshold based on the load characterization value of each message middleware node; and to determine the target message middleware node whose load characterization value reaches the overload threshold.

[0111] In one embodiment, the determining module 406 is configured to select at least one target message queue from message queues created in the target message middleware node based on a pre-configured set of deletable queues; the selected target message queue matches a queue element in the set of deletable queues; and delete at least one target message queue.

[0112] In one embodiment, the target message queue is created by the target business service application; the determining module 406 is used to randomly reconstruct the target message queue to any message middleware node in the message middleware by the target business service application when the target message queue is deleted.

[0113] The modules in the aforementioned load balancing device for message middleware can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can invoke and execute the corresponding operations of each module.

[0114] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores node load files. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a load balancing method for message middleware.

[0115] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a load balancing method for message middleware. The display unit of the computer device is used to form a visually visible image. It can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0116] Those skilled in the art will understand that Figure 5 and Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0117] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0118] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.

[0119] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0120] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0121] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0122] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0123] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A load balancing method for a message-oriented middleware, characterized in that, The method comprises: reading at least two load state data of each message middleware node in the message middleware from a node load file corresponding to the message middleware at every preset reading time period; the node load file is generated by executing a script to write load state data of each message middleware node obtained from the message middleware into a corresponding file; the load state data comprises resource occupation data of a processor of the message middleware node and to-be-processed task data; determining a first weight corresponding to the resource occupation data and a second weight corresponding to the to-be-processed task data based on a task type corresponding to the message middleware node; wherein the second weight corresponding to to-be-processed task data of a computation-intensive type is set to be higher than that of an access-intensive type; the first weight corresponding to resource occupation data of an access-intensive type is set to be higher than that of a computation-intensive type; performing weighted calculation on the resource occupation data and the to-be-processed task data according to the first weight and the second weight to obtain a load representation value of each message middleware node; determining an overload threshold based on the load representation value of each message middleware node; when the load representation values of a plurality of message middleware nodes reach the overload threshold, determining a target message middleware node with the largest load representation value; determining at least one target message queue from a message queue created in the target message middleware node and deleting the at least one target message queue.

2. The method of claim 1, wherein, The reading at least two load state data of each message middleware node in the message middleware from a node load file corresponding to the message middleware at every preset reading time period comprises: reading at least two load state data of each message middleware node in the message middleware from a node load file corresponding to the message middleware at every preset reading time period by dynamically adjusting a service; wherein the dynamic adjustment service is a service application for dynamically deleting a message queue.

3. The method of claim 1, wherein, The load state data is used to indicate the load state of the message middleware node.

4. The method of claim 1, wherein, Before the reading at least two load state data of each message middleware node in the message middleware from a node load file corresponding to the message middleware, the method further comprises: obtaining resource occupation data of a processor of each message middleware node and to-be-processed task data from the message middleware according to a preset writing time period by executing a script to obtain load state data of each message middleware node; writing the load state data of each message middleware node into a node load file by executing a script.

5. The method of claim 1, wherein, The load representation value is used to represent the overall load condition of the message middleware node.

6. The method of claim 1, wherein, The determining at least one target message queue from a message queue created in the target message middleware node and deleting the at least one target message queue comprises: selecting at least one target message queue from the message queue created in the target message middleware node based on a preconfigured deletable queue set; the selected target message queue matches a queue element in the deletable queue set; deleting the at least one target message queue.

7. The method according to any one of claims 1 to 6, characterized in that, The target message queue is created by a target business service application; and after determining at least one target message queue from the message queues created in the target message middleware node and deleting the at least one target message queue, the method further includes: In the case that the target message queue is deleted, the target message queue is randomly rebuilt by the target business service application to any message middleware node in the message middleware.

8. A load balancing apparatus for a message-oriented middleware, characterized by, The apparatus includes: The acquisition module is configured to read at least two load state data of each message middleware node in the message middleware from a node load file corresponding to the message middleware every preset reading time period; the node load file is generated by executing a script to write the load state data of each message middleware node in the message middleware into a corresponding file; the load state data includes resource occupation data of a processor of the message middleware node and to-be-processed task data; The calculation module is configured to determine a first weight corresponding to the resource occupation data and a second weight corresponding to the to-be-processed task data based on a task type corresponding to the message middleware node; the second weight corresponding to the to-be-processed task data of a calculation-intensive type is set to be higher than that of an access-intensive type; the first weight corresponding to the resource occupation data of an access-intensive type is set to be higher than that of a calculation-intensive type; and the resource occupation data and the to-be-processed task data are weighted and calculated according to the first weight and the second weight to obtain a load representation value of each message middleware node. The determination module is configured to determine an overload threshold value based on the load representation value of each message middleware node; determine a target message middleware node with a maximum load representation value when the load representation values of a plurality of message middleware nodes reach the overload threshold value; and determine at least one target message queue from the message queues created in the target message middleware node and delete the at least one target message queue. 9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-8 when the computer program is executed by the processor. The processor executes the computer program to implement the steps of the method of any one of claims 1 to 7.

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

Citation Information

Patent Citations

  • Load balancing method and system for cloud computing operating system

    CN108270857A

  • Load balancing method and apparatus, and computer readable storage medium

    CN108762924A