A micro-service-based load balancing method with software and hardware complementation

By combining client-side software load balancing and F5 hardware load balancing, a complementary software and hardware load balancing method was implemented, which solved the system stability and cost issues in high-performance scenarios and achieved efficient load balancing results.

CN115604271BActive Publication Date: 2026-05-15SUNING CONSUMER FINANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUNING CONSUMER FINANCE CO LTD
Filing Date
2022-08-03
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

In existing technologies, independently deployed load balancing devices are costly, while client-side load balancing is not stable enough in high-performance scenarios and is difficult to respond quickly to changes in the state of the server cluster.

Method used

This approach combines a client-side software load balancing module with an F5 load balancing device, employing software load scheduling as the primary method and hardware load balancing as a fallback, to achieve a complementary software and hardware load balancing method.

Benefits of technology

While reducing costs, it improves system stability and performance, enabling rapid response to changes in server cluster status and ensuring effective load balancing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115604271B_ABST
    Figure CN115604271B_ABST
Patent Text Reader

Abstract

The application discloses a kind of load balancing methods based on microservice's software and hardware complementation, comprising: each service is integrated load balancing module and is configured the load balancing address of F5 hardware;Initialization configuration information;Initialization load balancing module;Query microservice registration center, obtain the node address information list of each associated service end, to update the cluster address in service configuration information;When service sends request to other service, load balancing module is dispatched according to the service name of request service, and sends request to the specified node address of target service, if sending fails, again using the F5 load balancing address of service end as the bottom to send request past.The application can well guarantee the stability of system load balancing under double-layer load strategy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of Internet load balancing technology, specifically relating to a load balancing method based on microservice-based hardware and software complementarity. Background Technology

[0002] In today's internet business model, enterprises conduct business by building their own business systems, and microservices architecture is now a popular approach to building these systems. A microservices architecture typically consists of many independent services. A complete business process is broken down into different parts, with each service responsible for only one part. The business is ultimately completed through collaboration between multiple services. Services collaborate by sending requests to each other. Furthermore, to ensure service stability, services are generally composed of a group of service instances. To send requests from one service (client) to another service (server), load balancing must be introduced to ensure that each service on the server can handle client requests in a relatively balanced manner.

[0003] Currently, there are various tools available for implementing load balancing in the industry, with commonly used ones including F5 load balancers, LVS, Nginx, and custom software load balancers. These load balancers can be broadly categorized into two types: one is independently deployed load balancers, including tools like F5, LVS, and Nginx; the other is load balancing algorithms integrated into the client, allowing the client to implement load balancing itself.

[0004] For independently deployed load balancing devices, F5 devices are a good choice because they are stable, but their biggest drawback is the high cost. When the performance does not meet the requirements, it is necessary to buy more demanding devices. On the other hand, if the load balancing is implemented by the client, in high-performance scenarios, changes in the status of the server cluster nodes, such as crashes or shutdowns, cannot be quickly reflected to the client, which may result in occasional failures. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to address the shortcomings of the prior art by providing a hardware and software complementary load balancing method based on microservices, which achieves the final load balancing solution by combining client software load balancing and F5 load balancing equipment.

[0006] To achieve the above-mentioned technical objectives, the technical solution adopted by the present invention is as follows:

[0007] A microservice-based hardware and software complementary load balancing method first schedules requests through a software load balancing module and sends the requests to a specified node address of the target service. If the sending fails, the server-side F5 load balancing address is used as a fallback to send the request there.

[0008] To optimize the above technical solution, the specific measures also include:

[0009] The above method includes the following steps:

[0010] Step 1: Each service in the service cluster integrates a load balancing module to enable software load balancing capabilities; at the same time, an F5 hardware load balancing address is configured for each service to enable hardware load balancing capabilities.

[0011] Step 2: After the service is integrated with the load balancing module, perform initial configuration according to the requirements of the load balancing module. The configuration information includes the registry center address and the associated F5 load balancer addresses of each server.

[0012] Step 3: When the service starts, initialize the load balancing module, including initializing server-side configuration information and initializing load balancing algorithm instances;

[0013] Step 4: After the load balancing module is initialized, query the microservice registry to obtain the list of node address information for each associated service. This is used to update the cluster address in the service configuration information, delete node addresses that exist in the cluster address in the configuration information but not in the registry, and add addresses that do not exist in the cluster address in the configuration information but exist in the registry.

[0014] Step 5: When a service sends a request to another service, the load balancing module schedules the request based on the service name of the requesting service and sends the request to the specified node address of the target service. If the sending fails, the server's F5 load balancing address is used as a fallback to send the request.

[0015] The configuration information for step 2 above is as follows:

[0016] Registration center address: Used when the service acts as a client to obtain the address information of each node on the server side; when the service acts as a server, it sends the address information of its own node when it starts up.

[0017] The associated F5 load balancer addresses of each server are used as backup addresses for retrying when a request fails to pass through the software load balancer, thus providing dual protection.

[0018] Step 3 above includes:

[0019] Step 3.1, Initialize server configuration information: Create a configuration object for each server, which includes the service name, a list of service cluster addresses, and the F5 load balancer address of the service;

[0020] Step 3.2, Initialize the load balancing algorithm instance: Create a load balancing algorithm instance object for each server. This object is responsible for calculating the target node for requests going to its corresponding service; and store this object in a global Hash storage structure with the service name as the key.

[0021] In the above step 3.1, the service name is used as the unique identifier of the server, serving as the credential for obtaining the address information of each node of the service from the configuration center and the target service to which the request goes;

[0022] The service cluster address list is used for the load balancing algorithm instance to calculate load scheduling and obtain the address information of a certain node;

[0023] The F5 load balancing address of the service is used as a fallback load scheduling scheme in case of software load failure.

[0024] The above step 4 process is periodically scheduled by a dedicated thread until the end of the service life cycle.

[0025] The specific process of the above step 5 is as follows:

[0026] Step 5.1, According to the service name of the request target service, obtain the load balancing algorithm instance and configuration information of the service;

[0027] Step 5.2, Initialize the index pointer in the load balancing algorithm instance;

[0028] Step 5.3, When a request comes and is load-scheduled, the load balancing algorithm instance compares the value of the index pointer with the length length of the service cluster address list in the configuration information:

[0029] 1) If index < length, return the address with the sequence number index in the service cluster address list;

[0030] 2) If index ≥ length, set index to 0 and return the first address in the service cluster address list;

[0031] Step 5.4, Increment index by 1 to prepare for the next load scheduling;

[0032] Step 5.5, When the request fails to be sent successfully due to an exception, retry. The load balancing module directly uses the F5 address in the configuration information as a fallback, thus implementing a software and hardware complementary load balancing method that prioritizes software load scheduling and then supplements with hardware load.

[0033] The present invention has the following beneficial effects:

[0034] This invention firstly involves embedding a load balancing module within a microservice architecture. This module enables load balancing when the service acts as a client. Before a service starts, the F5 load balancing addresses of its associated services are configured into the service, serving as a fallback for load balancing. Upon service startup, the load balancing module initializes to handle load scheduling when the service sends requests. After startup, the load balancing module immediately queries the microservice registry to obtain the address information of each node in the cluster of other services associated with the service when acting as a client, and updates the address configuration information by service. This process is executed periodically throughout the program's lifecycle to ensure the validity of the address configuration information for each service. When a service sends a request to another service, the load balancing module uses a round-robin strategy for load scheduling, directly sending the request to a specified remote service node. If the request fails, it retryes the request using the F5 load balancing address of that service as a fallback.

[0035] 1. Integrating a load balancing module through client services can meet high-performance requirements and handle the vast majority of load balancing needs;

[0036] 2. By using existing F5 devices that no longer meet performance requirements as a supplement, load balancing can still be completed even if client software load balancing fails, saving costs and improving the overall stability of the service.

[0037] This invention, by prioritizing client-side load balancing and using F5 devices as an auxiliary load balancing method, effectively reduces reliance on F5 devices, achieving cost savings while also minimizing network interactions and improving system performance. Under this two-layer load balancing strategy, the stability of system load balancing is well guaranteed. Attached Figure Description

[0038] Figure 1 This is a flowchart illustrating the workflow of a microservice-based hardware and software complementary load balancing method according to the present invention.

[0039] Figure 2 This is a system architecture diagram of a hardware and software complementary load balancing method based on microservices according to the present invention.

[0040] Figure 3 This is a schematic diagram of the load balancing module structure of a microservice-based hardware and software complementary load balancing method according to the present invention.

[0041] Figure 4 This is a configuration file example diagram of a microservice-based hardware and software complementary load balancing method according to the present invention.

[0042] Figure 5 This is a screenshot of the load balancing algorithm example code for a microservice-based hardware and software complementary load balancing method according to the present invention. Detailed implementation manners

[0043] The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

[0044] As Figure 1-2 shown, in a system with a microservices architecture, there are multiple services, and each service consists of multiple nodes. A business often requires multiple services to cooperate with each other by sending requests. The request sender is the client, and the request receiver is the server. The request must be sent to a specific node on the server for processing. In order to balance the processing capabilities of each node, load balancing is required. The load balancing method based on the software and hardware complementarity of microservices in the present invention first schedules requests through a software load balancing module and sends the requests to the specified node address of the target service. If the sending fails, the F5 load balancing address of the server is used as a backup to send the request. The specific steps are as follows:

[0045] Step 1: Each service in the service cluster integrates a load balancing module, so the service has the software load balancing ability; at the same time, the F5 hardware load balancing address is configured for each service, so the service cluster has the hardware load balancing ability.

[0046] Through Step 1, each service in the microservices architecture system has both software load balancing ability and hardware load balancing ability.

[0047] Step 2: After the service integrates the load balancing module, it performs initialization configuration according to the requirements of the load balancing module.

[0048] When the program uses the load balancing module, the configuration information needs to include the registration center address and the F5 load balancing addresses of the associated server ends;

[0049] The registration center address (configuration item: rpc.registry.addrs) is used as follows: when the service is a client, it obtains the address information of each node of the server it needs; when the service is a server, it reports the address information of its own node at startup;

[0050] The F5 load balancing addresses of the associated server ends, with the configuration format rpc.client.serverAddresses.<service name> = <F5 load balancing address>, serve as the backup address for retrying to send requests in case of emergencies such as software load balancing failure of the request, playing a dual guarantee role;

[0051] Step 3: When the service starts, it initializes the load balancing module. As Figure 3 shown, it specifically includes: server configuration information, load balancing algorithm instance;

[0052] Step 3.1, Initialize server configuration information: Create a configuration object for each server. This configuration object consists of three parts: service name, service cluster address list, and service F5 load balancer address.

[0053] The service name serves as a unique identifier for the server and is used as a credential to obtain the address information of each node of the service from the configuration center and to request the target service.

[0054] The service cluster address list serves to calculate load scheduling for load balancing algorithm instances and to obtain the address information of a specific node.

[0055] The F5 load balancing address of the service is a fallback load balancing solution in case of software load failure.

[0056] Step 3.2, Initialize the load balancing algorithm instance: Create a separate load balancing algorithm instance object for each server. This object is responsible for calculating the target node for requests to its corresponding service; and store this object in a global hash storage structure with the service name as the key.

[0057] Step 4: After the load balancing module is initialized, it will immediately query the registry center to obtain the list of node address information of each server required by it. This information is used to update the cluster address in the service configuration information, delete node addresses that exist in the cluster address in the configuration information but not in the registry center, and add addresses that do not exist in the cluster address in the configuration information but exist in the registry center. This process is periodically scheduled by a dedicated thread until the service's lifecycle ends.

[0058] Step 5: When a service sends a request to another service, the load balancing module schedules the request based on the service name of the requesting service and sends the request to the specified node address of the target service. If the sending fails, the server's F5 load balancing address is used as a fallback to send the request.

[0059] In step 5, when a service sends a request to another service, the load balancing module schedules the request based on the service name of the requesting service and obtains the address of the specific node on the server side. The process is as follows:

[0060] Step 5.1: Based on the service name of the target service, obtain the load balancing algorithm instance and configuration information for that service;

[0061] Step 5.2: The load balancing algorithm instance stores a pointer index, which points to a certain position in the service cluster address list in the configuration information. The pointer is initially set to 0.

[0062] Step 5.3, when a request comes and is load-scheduled, the load balancing algorithm instance compares the value of the index pointer with the length (length) of the service cluster address list in the configuration information:

[0063] 1) If index < length, return the address with the sequence number index in the service cluster address list;

[0064] 2) If index ≥ length, set index to 0 and return the first address in the service cluster address list;

[0065] Step 5.4, increment index by 1 to prepare for the next load scheduling;

[0066] Step 5.5, when the request fails to be sent successfully due to an exception, it will be retried. At this time, the load balancing module directly uses the F5 address in the configuration information as a fallback, so as to implement the load balancing method that gives priority to software load scheduling and then supplements with hardware load, that is, a load balancing method that combines software and hardware.

[0067] The configuration file instance and the load balancing algorithm instance code of the present invention are as Figure 4 and 5 shown. The present invention realizes the load balancing method by preferentially using client load balancing and using the F5 device as an auxiliary. It effectively reduces the dependence on the F5 device, achieves the purpose of cost savings, and can also reduce network interaction and improve system performance. Under the double-layer load strategy, it can well ensure the stability of system load balancing.

[0068] The above is only the preferred implementation manner of the present invention. The protection scope of the present invention is not limited to the above embodiments. All technical solutions falling within the idea of the present invention belong to the protection scope of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements should be regarded as the protection scope of the present invention.

Claims

1. A load balancing method based on microservices and complementary hardware and software, characterized in that, First, the request is scheduled through a software load balancing module and sent to the specified node address of the target service. If sending fails, the request is then sent to the server's F5 load balancing address as a fallback. The method includes the following steps: Step 1: Each service in the service cluster integrates a load balancing module to enable software load balancing capabilities; at the same time, an F5 hardware load balancing address is configured for each service to enable hardware load balancing capabilities. Step 2: After the service is integrated with the load balancing module, perform initial configuration according to the requirements of the load balancing module. The configuration information includes the registry center address and the associated F5 load balancer addresses of each server. Step 3: When the service starts, initialize the load balancing module, including initializing server-side configuration information and initializing load balancing algorithm instances; Step 4: After the load balancing module is initialized, query the microservice registry to obtain the list of node address information for each associated service. This is used to update the cluster address in the service configuration information, delete node addresses that exist in the cluster address in the configuration information but not in the registry, and add addresses that do not exist in the cluster address in the configuration information but exist in the registry. The process in step 4 is periodically scheduled by a dedicated thread until the service's lifecycle ends; Step 5: When a service sends a request to another service, the load balancing module schedules the request based on the service name of the requesting service and sends the request to the specified node address of the target service. If the sending fails, the server's F5 load balancing address is used as a fallback to send the request.

2. The load balancing method based on microservices and hardware / software complementarity according to claim 1, characterized in that, Step 2 configures the following information: Registration center address: Used when the service acts as a client to obtain the address information of each node on the server side; when the service acts as a server, it sends the address information of its own node when it starts up. The associated F5 load balancer addresses of each server are used as backup addresses for retrying when a request fails to pass through the software load balancer, thus providing dual protection.

3. The load balancing method based on microservices and hardware / software complementarity according to claim 1, characterized in that, Step 3 includes: Step 3.1, Initialize server configuration information: Create a configuration object for each server, which includes the service name, a list of service cluster addresses, and the F5 load balancer address of the service; Step 3.2, Initialize the load balancing algorithm instance: Create a separate load balancing algorithm instance object for each server. This object is responsible for calculating the target node for requests going to its corresponding service; and store the object in a global hash storage structure with the service name as the key.

4. The load balancing method based on microservices and hardware / software complementarity according to claim 3, characterized in that, In step 3.1, the service name serves as a unique identifier for the server and is used as a credential to obtain the address information of each node of the service from the configuration center and to request the target service. The service cluster address list is used to calculate load scheduling for load balancing algorithm instances and obtain the address information of a specific node. The service's F5 load balancing address is used as a fallback load balancing solution in the event of software load failure.

5. The load balancing method based on microservices and hardware / software complementarity according to claim 1, characterized in that, The specific process of step 5 is as follows: Step 5.1: Based on the service name of the target service, obtain the load balancing algorithm instance and configuration information for that service; Step 5.2, initialize the index pointer in the load balancing algorithm instance; Step 5.3, when a request comes and is load-scheduled, the load balancing algorithm instance compares the value of the index pointer with the length length of the service cluster address list in the configuration information: 1) If index < length, return the address with the sequence number index in the service cluster address list; 2) If index ≥ length, set index to 0 and return the first address in the service cluster address list; Step 5.4, increment index by 1 to prepare for the next load scheduling; Step 5.5, when the request fails to be sent successfully due to an exception, retry again. The load balancing module directly uses the F5 address in the configuration information as a fallback, so as to implement a software-first load scheduling method, and then supplement it with hardware load, thus achieving a software-hardware complementary load balancing method.