A load balancing method and apparatus

CN113094175BActive Publication Date: 2026-08-14WEBANK (CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-15
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0005]现有的负载均衡方案中,多为简单的任务数量的均衡,并没有考虑应用实例本身的处理能力,当有计算密集型的交易请求下发到资源空闲不足的应用实例处理时,会导致出现应用实例处理交易请求的资源紧张的问题,降低了应用实例的处理效率

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113094175B_ABST
    Figure CN113094175B_ABST
Patent Text Reader

Abstract

This invention discloses a load balancing method and apparatus. The method includes acquiring transaction requests sent by a front-end transaction system. Each transaction request includes a transaction type. The method involves determining the application instances currently processing the transaction type from an application instance load-weighted score table. The load-weighted score of each application instance is determined by the resource status packet of each application instance at the current time and the weight factor of each resource. The weight factor of each resource is determined by the historical single-time resource consumption of each application instance and the total value of each resource. The method then sends the application instances currently processing the transaction type to the front-end transaction system. By selecting application instances to process transaction requests based on the weight factors of each resource determined through historical single-time resource consumption and the load-weighted score obtained from the resource status packet at the current time, application instances with idle resources and high processing efficiency can be identified, improving the accuracy of load balancing and increasing the processing efficiency of application instances.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for load balancing. Background Technology

[0002] With the continuous development of fintech, especially internet fintech, more and more technologies (such as distributed systems, blockchain, artificial intelligence, etc.) are being applied in the financial field. However, the financial industry is also placing higher demands on technology, such as on the load balancing of servers in the financial industry.

[0003] Currently, mainstream internet and financial companies deploy their systems using inexpensive hardware and software through a distributed, multi-active architecture with disaster recovery to ensure system reliability and stability. Taking banking and other financial systems as an example, application servers are typically deployed using a two-site, three-center architecture with local multi-active deployment and off-site disaster recovery to ensure the reliability of application services.

[0004] In a distributed, multi-active application architecture, the first problem to be solved is how to achieve load balancing between online transactions and batch transactions at the application layer. Existing mainstream vendors all use the following algorithms: round-robin algorithm, weighted round-robin algorithm, least connections algorithm, fixed weight algorithm, weighted least connections algorithm, source IP hash algorithm, etc.

[0005] Existing load balancing solutions mostly balance the number of tasks without considering the processing capacity of the application instances themselves. When computationally intensive transaction requests are sent to application instances with insufficient resources, it can lead to resource shortages for the application instances, reducing their processing efficiency. Summary of the Invention

[0006] This invention provides a load balancing method and apparatus to rationally arrange transaction requests of different transaction types and improve the processing efficiency of application instances.

[0007] In a first aspect, embodiments of the present invention provide a load balancing method, comprising:

[0008] Obtain transaction requests sent by the front-end transaction system, wherein the transaction requests include transaction types;

[0009] The application instance currently processing the transaction type is determined from the application instance load weighted score table; wherein, the load weighted score of each application instance in the application instance load weighted score table is determined by the resource status packet of each application instance at the current time and the weight factor of each resource; the weight factor of each resource is determined by the historical single resource consumption of each application instance and the total value of each resource.

[0010] The application instance currently processing the transaction type is sent to the front-end transaction system, so that the front-end transaction system can forward the transaction request to the application instance currently processing the transaction type for processing.

[0011] In the above technical solution, when selecting application instances to process transaction requests, the load-weighted score obtained by combining the weight factors of each resource determined through historical single-time resource consumption and the resource status packet at the current moment can identify application instances with idle resources and high processing efficiency, thereby improving the accuracy of load balancing and the processing efficiency of application instances.

[0012] Optionally, determining the weighting factor for each resource based on the historical single-time resource consumption of each application instance and the total value of each resource includes:

[0013] Periodically retrieve the historical single-time resource consumption of each application instance in processing transaction requests of each transaction type;

[0014] Using transaction type as the dimension, calculate the normal distribution of historical single resource consumption for each application instance, and determine the resource consumption value with the highest probability as the estimated consumption value of each resource for each application instance at the current moment.

[0015] Based on the estimated consumption value of each resource of each application instance and the total value of each resource at the current moment, calculate the consumption ratio of each resource;

[0016] The weighting factor of each resource is calculated based on the consumption ratio of each resource.

[0017] In the above technical solution, since the historical single-time resource consumption of each application instance is fully considered when calculating the weight factor of each resource, the estimated consumption value of processing the same transaction type at the current moment is more accurate, thereby improving the processing efficiency of the application instance.

[0018] Optionally, determining the load-weighted score of each application instance based on the resource status packet of each application instance at the current moment and the weighting factor of each resource includes:

[0019] Obtain the resource status package of each application instance at the current moment and the weight factor corresponding to each resource in the resource status package;

[0020] The weighted score of the load of each application instance is obtained by weighting the values ​​of each resource in the resource status package and the corresponding weight factors.

[0021] Optionally, the resource status packet of each application instance at the current moment is reported by each application instance through a heartbeat message, or obtained by sending a heartbeat probe message to the application instance that has not received a heartbeat message when no heartbeat message is received within a preset time, or reported in real time by each application instance when processing a transaction request.

[0022] Optionally, the method further includes:

[0023] If no heartbeat detection result is received after sending a heartbeat detection message to the application instance that has not received a heartbeat message, then the application instance that has not received a heartbeat message will be removed from the list of application instances to be assigned.

[0024] Optionally, after sending the application instance that processes the transaction type at the current moment to the front-end transaction system, the method further includes:

[0025] Receive the resource status packet reported in real time by the application instance that is currently processing the transaction type when processing the transaction request;

[0026] Based on the resource status packet when processing the transaction request and the resource status packet when receiving the transaction request, calculate the single resource consumption of the application instance processing the transaction request of the transaction type at the current moment;

[0027] The resource consumption of a single transaction request for the transaction type is stored in the historical single resource consumption database of the application instance that is currently processing the transaction type.

[0028] Optionally, determining the application instance currently processing the transaction type from the application instance load-weighted score table includes:

[0029] The application instance responsible for the same transaction type in the weighted score table and having the highest load weighted score is determined as the application instance that processes the transaction type at the current moment.

[0030] Secondly, embodiments of the present invention provide a load balancing apparatus, comprising:

[0031] The transceiver unit is used to acquire transaction requests sent by the front-end transaction system, wherein the transaction request includes the transaction type;

[0032] The processing unit is configured to determine the application instance currently processing the transaction type from the application instance load weighted score table; wherein, the load weighted score of each application instance in the application instance load weighted score table is determined by the resource status packet of each application instance at the current time and the weight factor of each resource; the weight factor of each resource is determined by the historical single resource consumption of each application instance and the total value of each resource.

[0033] The transceiver unit is further configured to send the application instance currently processing the transaction type to the front-end transaction system, so that the front-end transaction system can send the transaction request to the application instance currently processing the transaction type for processing.

[0034] Optionally, the processing unit is specifically used for:

[0035] Periodically retrieve the historical single-time resource consumption of each application instance in processing transaction requests of each transaction type;

[0036] Using transaction type as the dimension, calculate the normal distribution of historical single resource consumption for each application instance, and determine the resource consumption value with the highest probability as the estimated consumption value of each resource for each application instance at the current moment.

[0037] Based on the estimated consumption value of each resource of each application instance and the total value of each resource at the current moment, calculate the consumption ratio of each resource;

[0038] The weighting factor of each resource is calculated based on the consumption ratio of each resource.

[0039] Optionally, the processing unit is specifically used for:

[0040] Obtain the resource status package of each application instance at the current moment and the weight factor corresponding to each resource in the resource status package;

[0041] The weighted score of the load of each application instance is obtained by weighting the values ​​of each resource in the resource status package and the corresponding weight factors.

[0042] Optionally, the resource status packet of each application instance at the current moment is reported by each application instance through a heartbeat message, or obtained by sending a heartbeat probe message to the application instance that has not received a heartbeat message when no heartbeat message is received within a preset time, or reported in real time by each application instance when processing a transaction request.

[0043] Optionally, the processing unit is further configured to:

[0044] If no heartbeat detection result is received after sending a heartbeat detection message to the application instance that has not received a heartbeat message, then the application instance that has not received a heartbeat message will be removed from the list of application instances to be assigned.

[0045] Optionally, the processing unit is further configured to:

[0046] After sending the application instance that is currently processing the transaction type to the front-end transaction system, the system receives the resource status packet reported in real time by the application instance that is currently processing the transaction type when processing the transaction request.

[0047] Based on the resource status packet when processing the transaction request and the resource status packet when receiving the transaction request, calculate the single resource consumption of the application instance processing the transaction request of the transaction type at the current moment;

[0048] The resource consumption of a single transaction request for the transaction type is stored in the historical single resource consumption database of the application instance that is currently processing the transaction type.

[0049] Optionally, the processing unit is specifically used for:

[0050] The application instance responsible for the same transaction type in the weighted score table and having the highest load weighted score is determined as the application instance that processes the transaction type at the current moment.

[0051] Thirdly, embodiments of the present invention also provide a computing device, comprising:

[0052] Memory, used to store program instructions;

[0053] The processor is used to call the program instructions stored in the memory and execute the above-mentioned load balancing method according to the obtained program.

[0054] Fourthly, embodiments of the present invention also provide a computer-readable non-volatile storage medium, including computer-readable instructions, which, when read and executed by a computer, cause the computer to perform the above-described load balancing method. Attached Figure Description

[0055] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0056] Figure 1 A schematic diagram of a system architecture provided for an embodiment of the present invention;

[0057] Figure 2 A flowchart illustrating a load balancing method provided in an embodiment of the present invention;

[0058] Figure 3 This is a schematic diagram of a resource status packet message provided in an embodiment of the present invention;

[0059] Figure 4 A schematic diagram illustrating an active heartbeat detection method provided in an embodiment of the present invention;

[0060] Figure 5 A schematic diagram of a load balancing method provided in an embodiment of the present invention;

[0061] Figure 6 This is a schematic diagram of a load balancing device provided in an embodiment of the present invention. Detailed Implementation

[0062] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0063] Figure 1 This is a system architecture provided as an embodiment of the present invention. For example... Figure 1 As shown, the system architecture may include a front-end transaction system 100, a load balancing configuration center 200, and a business processing system 300.

[0064] The front-end transaction system 100 is a system for sending transaction requests or tasks. Before sending a transaction request or task to the business processing system 300, it needs to send a transaction request to the load balancing configuration center 200 to obtain an application instance that processes the same type of transaction as the transaction request.

[0065] The load balancing configuration center 200 is used to obtain the resource status packets reported by each application instance, run the load balancing algorithm, and determine the application instances with high processing efficiency based on the requests from the front-end transaction system 100.

[0066] The business processing system 300 is deployed with multiple application instances, each of which is equivalent to a server, used to process transaction requests or tasks issued by the front-end transaction system 100.

[0067] It should be noted that the above Figure 1 The structure shown is merely an example, and the embodiments of the present invention are not limited thereto.

[0068] Based on the above description Figure 2 The present invention provides a detailed flowchart of a load balancing method according to an embodiment of the present invention, which can be executed by a load balancing device.

[0069] like Figure 2 As shown, the process specifically includes:

[0070] Step 201: Obtain the transaction request sent by the front-end transaction system.

[0071] In this embodiment of the invention, the transaction request includes a transaction type, so as to select an application instance that can handle the transaction request of that transaction type.

[0072] Step 202: Determine the application instance currently processing the transaction type from the application instance load-weighted score table.

[0073] The main purpose is to identify the application instance with the same transaction type and the highest load weighting score in the application instance weighted score table as the application instance that is currently processing the transaction type.

[0074] In this application instance load weighting score table, the load weighting score of each application instance is determined by the resource status packet of each application instance at the current time and the weight factor of each resource. Specifically, it is necessary to first obtain the resource status packet of each application instance at the current time and the weight factor corresponding to each resource in the resource status packet, and then perform weighted calculation on the value of each resource in the resource status packet and the weight factor corresponding to each resource to obtain the load weighting score of each application instance.

[0075] In this embodiment of the invention, the resources in the resource status package may include, but are not limited to, CPU (Central Processing Unit) resource utilization, IO (Input / Output) utilization, remaining memory space, whether the application instance and the database are in the same IDC (Internet Data Center), the number of concurrent threads of the process, and the network bandwidth latency between the application instance and the database across IDCs, etc.

[0076] CPU utilization can be obtained using the `top` command in Linux, which displays the current CPU utilization and idle rate of the application instance. I / O utilization can be obtained using the `iostat` command in Linux, which displays the disk I / O utilization and idle rate of the application instance. Remaining memory space can be obtained using the `free` command in Linux, which displays the current remaining memory of the application instance, and the `top` command can be used to display the process memory usage of the business processing system. Whether the application and the database reside in the same data center can be determined through environment variable parameters when deploying application instances of the transaction system B in different data centers. The number of concurrent threads can be obtained using the `ps` command in Linux, which displays the current number of running threads in the business processing system.

[0077] Resource status packets can use the JSON protocol, and the format of their content can be as follows: Figure 3 As shown.

[0078] The weight factors corresponding to each resource in the above resource status package can be read from the weight factor library. After receiving a resource status package reported by an application instance, the system's resource weighted load balancing calculation logic can be triggered, thereby reading the weight factors corresponding to each resource in the resource status package reported by the application instance from the weight factor library.

[0079] The weighting factors can be stored using a relational database, and the table structure can be as shown in Table 1.

[0080] Table 1

[0081]

[0082] Once the weighting factors are read, they can be weighted together with the current resource status packet to obtain the load-weighted score. The calculation formula is as follows:

[0083] score = W1*P1 + W2*P2 + ... + W n *P n ;

[0084] Wherein, score is the load-weighted score. W n This represents the weighting factor for each resource in the application instance, and its value can be [-100, 100], such as CPU utilization weight being -30, memory availability weight being 20, etc. n The application instance reports the status values ​​of each resource in the resource status packet, such as CPU utilization of 80% and memory availability of 40%, where n is the number of resources.

[0085] The above load-weighted scores can be stored in the application instance load-weighted score table in the database. The table structure can be as shown in Table 2. The primary keys of this table are the application instance ID and the business processing system identifier ID. The application instance ID is usually the IP address assigned to the instance, and the business processing system identifier ID is usually a uniformly assigned system identifier ID or name.

[0086] Table 2

[0087]

[0088] In addition, the application instance load weighted score table and the resource status packets reported by the application instances can be stored in the application instance resource reporting record table, and its table structure can be as shown in Table 3.

[0089] Table 3

[0090]

[0091] The weighting factors for each resource are determined by the historical single-transaction resource consumption of each application instance and the total value of each resource. Specifically, the historical single-transaction resource consumption of each application instance for processing transaction requests of each transaction type can be periodically obtained. Then, using transaction type as the dimension, a normal distribution of the historical single-transaction resource consumption of each application instance is calculated, and the resource consumption value with the highest probability is determined as the estimated consumption value of each resource for each application instance at the current moment. Next, based on the estimated consumption value of each resource for each application instance at the current moment and the total value of each resource, the consumption ratio of each resource is calculated. Finally, the weighting factor of each resource is calculated based on the consumption ratio of each resource.

[0092] This requires first estimating the estimated resource consumption of each application instance. This can be done by reading historical single-transaction resource consumption data from a database and using a resource consumption calculation model to estimate the resource consumption for each transaction type. For example, when estimating the resource consumption for transaction type A, the historical single-transaction resource consumption data of application instance n when processing transaction type A is arranged according to a normal distribution curve. The mean m and standard deviation n of this normal distribution are calculated, and the resource consumption value with the highest probability under this normal distribution is taken as the estimated consumption value X for each resource.

[0093] Then, by combining all the values ​​Y of each resource in the application instance (such as 1024MB of memory), the resource consumption ratio is calculated, such as Z = X / Y.

[0094] For example, the percentage of CPU resources consumed: Z cpu =X cpu / Y cpu ;

[0095] Memory resource consumption percentage: Z vm =X vm / Y vm ;

[0096] Percentage of IO resource consumption: Z io =X io / Y io ;

[0097] This allows us to obtain the weighting factor W for CPU resources. cpu =Z cpu / (Z cpu +Z vm +Z io );

[0098] The weighting factor for memory resources is Wvm = Z. vm / (Z cpu +Z vm +Z io ).

[0099] Similarly, the weight factors of other resources in this application instance can be obtained.

[0100] The weighting factors for each of the above resources need to be updated periodically to obtain the optimal and most accurate load-weighted score for each application instance. This allows the front-end transaction system to determine the optimal application instance based on the maximum load-weighted score when requesting to process the transaction request.

[0101] The aforementioned resource status packets can be reported by each application instance via heartbeat messages, obtained after sending heartbeat probe messages to application instances that have not received heartbeat messages within a preset time, or reported in real time by each application instance when processing transaction requests. The preset time can be set based on experience.

[0102] In addition, if no heartbeat result is received after sending a heartbeat probe message to an application instance that has not received a heartbeat message, the application instance that has not received a heartbeat message will be removed from the list of application instances to be assigned.

[0103] In other words, resource status packets can be divided into scheduled reporting and real-time reporting.

[0104] During scheduled reporting, each application instance of the business processing system reports its resource status to the load balancing configuration center at specified intervals (t1) using a predetermined message protocol. This includes, but is not limited to, CPU resource utilization, IO utilization, remaining memory space, and whether the application instance and the database are located in different data centers. Upon receiving the resource status packets reported via heartbeat, the load balancing configuration center updates the resource status records of the application instances and executes the load balancing algorithm to calculate the load-weighted score.

[0105] If the load balancing configuration center does not receive a resource status packet from an application instance P1 of the business processing system within a specified time period t2 (preset time), the load balancing configuration center will proactively initiate a heartbeat probe message to that application instance P1. The processing flow can be as follows: Figure 4 As shown. If a heartbeat response message is received, proving that the application instance is still alive, the heartbeat response message is parsed, the load weighting score of business instance P1 is calculated using weighted methods, and the load weighting score is updated in the application instance load weighting score table. If no heartbeat response message is received, it indicates that application instance P1 may be down, and it is considered that the current service of application instance P1 is unavailable. In this case, application instance P1 is removed from the list of pending application instances in the business processing system of the load balancing configuration center, and subsequent request tasks from the front-end transaction system will no longer be distributed to application instance P1.

[0106] Real-time reporting refers to the situation where, during the processing of transaction requests, application instances proactively report their resource set information in real time, so that the load balancing configuration center can autonomously optimize the weight factors of each resource.

[0107] For example, after the front-end transaction system requests the load balancing configuration center and obtains the most efficient application instance for processing according to the load balancing algorithm, it records the resource status information setA of the application instance that is currently processing the transaction request with transaction type typeA and request sequence number serialnoA, as the initial resource status information of the application instance at time t1.

[0108] Upon receiving a transaction request of type A from the front-end transaction system, this application instance, while processing the request, simultaneously initiates an asynchronous thread to continuously report the resource status packets of the current application instance for transaction type A, ceasing reporting only upon receiving a signal indicating that the transaction request processing is complete. This process helps the load balancing configuration center calculate the resource consumption of transaction type A in real time, update weighting factors, and continuously optimize the estimated consumption values ​​of each resource for transaction type A.

[0109] Step 203: Send the application instance that processes the transaction type at the current moment to the front-end transaction system.

[0110] Sending the application instance currently processing the transaction type to the front-end transaction system allows the front-end transaction system to forward the transaction request to that application instance for processing. It can also receive real-time resource status packets reported by the application instance processing the transaction request, and then calculate the single-transaction resource consumption of the application instance processing the transaction type based on these resource status packets. This single-transaction resource consumption information is stored in the historical single-transaction resource consumption database of the application instance processing the transaction type.

[0111] Among them, the resource status packets when processing transaction requests are in the same request sequence.

[0112] Specifically, the application instance sends a real-time heartbeat report of its resource status to the load balancer configuration center. Based on the changes in the resource status of the application instance, the load balancer configuration center can analyze the resource consumption of the application instance in processing transaction requests with request sequence serialnoA and request type typeA, and record it in the database.

[0113] For example, the resource status packet information shown in Table 4 can be used to calculate the consumption of a single resource. The CPU resource consumption value of the transaction request with request sequence serialnoA and request type typeA is (C1-C2+C1-C3) / 2. The calculation method for other resources is the same.

[0114] Table 4

[0115] serialnoA t1 C1 I1 M1 serialnoA t2 C2 I2 M2 serialnoA t3 C3 I3 M3

[0116] After calculating the resource consumption in this instance using the above method, it can be stored in the historical single-time resource consumption database of the application instance for updating the estimated consumption values ​​of each resource of the application instance.

[0117] To better explain the embodiments of the present invention, the above-described load balancing process will be described below in a specific implementation scenario.

[0118] like Figure 5 As shown, it specifically includes:

[0119] Step 501: Receive the resource status packet of the application instance.

[0120] After receiving a resource status packet periodically reported by an application instance, the load balancing configuration center triggers a load balancing calculation task.

[0121] Step 502: Obtain the weight factor information of the resources.

[0122] The weight factors of each resource of the application instance are read into memory from the resource weight factor library.

[0123] Step 503: Calculate the application instance load-weighted score.

[0124] Based on the weight factors of each resource of the application instance and the status values ​​of each resource in the resource status packet reported by the application instance, the weighted score of the application instance load is calculated. The specific calculation method has been described in the above embodiments and will not be repeated here.

[0125] Step 504: Update the application instance load weighted score.

[0126] Update the calculated load-weighted score to the application instance load-weighted score table.

[0127] Step 505: Save the resource status package of the application instance.

[0128] Save the resource status packets reported by the application instance to the reporting record table.

[0129] In this embodiment of the invention, by acquiring transaction requests sent by the front-end transaction system, including transaction types, the application instances currently processing the transaction type are determined from the application instance load-weighted score table. The load-weighted score of each application instance is determined by the resource status packet of each application instance at the current time and the weight factor of each resource. The weight factor of each resource is determined by the historical single-time resource consumption of each application instance and the total value of each resource. The application instances currently processing the aforementioned transaction type are then sent to the front-end transaction system. When selecting application instances to process transaction requests, based on the weight factors of each resource determined through historical single-time resource consumption and the load-weighted score obtained from the resource status packet at the current time, application instances with idle resources and high processing efficiency can be identified, improving the accuracy of load balancing and the processing efficiency of application instances.

[0130] Based on the same technological concept Figure 6 An exemplary embodiment of the present invention illustrates the structure of a load balancing device that can perform a load balancing process.

[0131] like Figure 6 As shown, the device specifically includes:

[0132] The transceiver unit 601 is used to acquire transaction requests sent by the front-end transaction system, wherein the transaction request includes a transaction type;

[0133] Processing unit 602 is configured to determine the application instance currently processing the transaction type from the application instance load weighted score table; wherein, the load weighted score of each application instance in the application instance load weighted score table is determined by the resource status packet of each application instance at the current time and the weight factor of each resource; the weight factor of each resource is determined by the historical single resource consumption of each application instance and the total value of each resource.

[0134] The transceiver unit 601 is further configured to send the application instance currently processing the transaction type to the front-end transaction system, so that the front-end transaction system can send the transaction request to the application instance currently processing the transaction type for processing.

[0135] Optionally, the processing unit 602 is specifically used for:

[0136] Periodically retrieve the historical single-time resource consumption of each application instance in processing transaction requests of each transaction type;

[0137] Using transaction type as the dimension, calculate the normal distribution of historical single resource consumption for each application instance, and determine the resource consumption value with the highest probability as the estimated consumption value of each resource for each application instance at the current moment.

[0138] Based on the estimated consumption value of each resource of each application instance and the total value of each resource at the current moment, calculate the consumption ratio of each resource;

[0139] The weighting factor of each resource is calculated based on the consumption ratio of each resource.

[0140] Optionally, the processing unit 602 is specifically used for:

[0141] Obtain the resource status package of each application instance at the current moment and the weight factor corresponding to each resource in the resource status package;

[0142] The weighted score of the load of each application instance is obtained by weighting the values ​​of each resource in the resource status package and the corresponding weight factors.

[0143] Optionally, the resource status packet of each application instance at the current moment is reported by each application instance through a heartbeat message, or obtained by sending a heartbeat probe message to the application instance that has not received a heartbeat message when no heartbeat message is received within a preset time, or reported in real time by each application instance when processing a transaction request.

[0144] Optionally, the processing unit 602 is further configured to:

[0145] If no heartbeat detection result is received after sending a heartbeat detection message to the application instance that has not received a heartbeat message, then the application instance that has not received a heartbeat message will be removed from the list of application instances to be assigned.

[0146] Optionally, the processing unit 602 is further configured to:

[0147] After sending the application instance that is currently processing the transaction type to the front-end transaction system, the system receives the resource status packet reported in real time by the application instance that is currently processing the transaction type when processing the transaction request.

[0148] Based on the resource status packet when processing the transaction request and the resource status packet when receiving the transaction request, calculate the single resource consumption of the application instance processing the transaction request of the transaction type at the current moment;

[0149] The resource consumption of a single transaction request for the transaction type is stored in the historical single resource consumption database of the application instance that is currently processing the transaction type.

[0150] Optionally, the processing unit 602 is specifically used for:

[0151] The application instance responsible for the same transaction type in the weighted score table and having the highest load weighted score is determined as the application instance that processes the transaction type at the current moment.

[0152] Based on the same technical concept, embodiments of the present invention also provide a computing device, including:

[0153] Memory, used to store program instructions;

[0154] The processor is used to call program instructions stored in memory and execute the load balancing method described above according to the obtained program.

[0155] Based on the same technical concept, embodiments of the present invention also provide a computer-readable non-volatile storage medium, including computer-readable instructions, which, when read and executed by a computer, cause the computer to perform the above-described load balancing method.

[0156] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0157] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0158] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0159] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0160] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A load balancing method, characterized in that, include: Obtain transaction requests sent by the front-end transaction system, wherein the transaction requests include transaction types; The application instance currently processing the transaction type is determined from the application instance load weighted score table; wherein, the load weighted score of each application instance in the application instance load weighted score table is determined by the resource status packet of each application instance at the current time and the weight factor of each resource; the weight factor of each resource is determined by the historical single resource consumption of each application instance and the total value of each resource. The application instance currently processing the transaction type is sent to the front-end transaction system, so that the front-end transaction system can forward the transaction request to the application instance currently processing the transaction type for processing. The determination of the weighting factor for each resource based on the historical single-time resource consumption of each application instance and the total value of each resource includes: Periodically retrieve the historical single-time resource consumption of each application instance in processing transaction requests of each transaction type; Using transaction type as the dimension, calculate the normal distribution of historical single resource consumption for each application instance, and determine the resource consumption value with the highest probability as the estimated consumption value of each resource for each application instance at the current moment. Based on the estimated consumption value of each resource of each application instance and the total value of each resource at the current moment, calculate the consumption ratio of each resource; The weighting factor of each resource is calculated based on the consumption ratio of each resource.

2. The method as described in claim 1, characterized in that, The determination of the load-weighted score for each application instance, based on the resource status packets of each application instance at the current moment and the weighting factors of each resource, includes: Obtain the resource status package of each application instance at the current moment and the weight factor corresponding to each resource in the resource status package; The weighted score of the load of each application instance is obtained by weighting the values ​​of each resource in the resource status package and the corresponding weight factors.

3. The method as described in claim 2, characterized in that, The resource status packets of each application instance at the current moment are reported by each application instance through heartbeat messages, or obtained by sending heartbeat probe messages to application instances that have not received heartbeat messages when no heartbeat messages are received within a preset time, or reported in real time by each application instance when processing transaction requests.

4. The method as described in claim 3, characterized in that, The method further includes: If no heartbeat detection result is received after sending a heartbeat detection message to the application instance that has not received a heartbeat message, then the application instance that has not received a heartbeat message will be removed from the list of application instances to be assigned.

5. The method as described in claim 1, characterized in that, After sending the application instance that processes the transaction type at the current moment to the front-end transaction system, the method further includes: Receive the resource status packet reported in real time by the application instance that is currently processing the transaction type when processing the transaction request; Based on the resource status packet when processing the transaction request and the resource status packet when receiving the transaction request, calculate the single resource consumption of the application instance processing the transaction request of the transaction type at the current moment; The resource consumption of a single transaction request for the transaction type is stored in the historical single resource consumption database of the application instance that is currently processing the transaction type.

6. The method according to any one of claims 1 to 5, characterized in that, The step of determining the application instance currently processing the transaction type from the application instance load-weighted score table includes: The application instance responsible for the same transaction type in the weighted score table and having the highest load weighted score is determined as the application instance that processes the transaction type at the current moment.

7. A load balancing device, characterized in that, include: The transceiver unit is used to acquire transaction requests sent by the front-end transaction system, wherein the transaction request includes the transaction type; The processing unit is configured to determine the application instance currently processing the transaction type from the application instance load weighted score table; wherein, the load weighted score of each application instance in the application instance load weighted score table is determined by the resource status packet of each application instance at the current time and the weight factor of each resource; the weight factor of each resource is determined by the historical single resource consumption of each application instance and the total value of each resource. The transceiver unit is further configured to send the application instance currently processing the transaction type to the front-end transaction system, so that the front-end transaction system can send the transaction request to the application instance currently processing the transaction type for processing. The processing unit is specifically used to periodically acquire the historical single-time resource consumption of each application instance for processing transaction requests of each transaction type; calculate the normal distribution of the historical single-time resource consumption of each application instance by transaction type, and determine the resource consumption value with the highest probability as the estimated consumption value of each resource of each application instance at the current moment; calculate the consumption ratio of each resource based on the estimated consumption value of each resource of each application instance at the current moment and the total value of each resource; and calculate the weight factor of each resource based on the consumption ratio of each resource.

8. A computing device, characterized in that, include: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the method according to any one of claims 1 to 6.

9. A computer-readable non-volatile storage medium, characterized in that, Includes computer-readable instructions that, when read and executed by a computer, cause the computer to perform the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Load balancing method and device, computer equipment and storage medium

    CN110134513A

  • Virtual machine resource utilization rate analysis method based on dynamic analysis model

    CN111488200A