CN-114816727-B - Load balancing method, system, device, equipment and readable storage medium
Abstract
The invention discloses a load balancing method, a system, a device, equipment and a readable storage medium. The load balancing method comprises the steps of creating a resource object associated with service, obtaining configuration information of the service through the resource object when a creation request of the service is received, obtaining instance information corresponding to the service based on the configuration information, and determining a target instance for processing a request message of the service in an instance corresponding to the instance information according to the instance information and the configuration information to finish load balancing. The complexity of the load balancing system for realizing load balancing is reduced.
Inventors
- ZHANG QING
- ZHENG YUXUAN
- GU MING
- WANG YAN
- DONG WEN
Assignees
- 咪咕文化科技有限公司
- 中国移动通信集团有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20220224
Claims (8)
- 1. A load balancing method, the load balancing method comprising: Creating a resource object associated with the business service; When receiving the creation request of the business service, acquiring configuration information of the business service through the resource object, wherein the configuration information comprises host information, network port information, instance selector information and load balancing strategy; Obtaining instance information corresponding to the business service based on the configuration information, and determining a target instance for processing a request message of the business service in an instance corresponding to the instance information according to the instance information and the configuration information to finish load balancing; The step of obtaining the instance information corresponding to the business service based on the configuration information, determining a target instance for processing the request message of the business service in the instance corresponding to the instance information according to the instance information and the configuration information, and completing load balancing comprises the following steps: controlling a service monitor to determine whether a current host meets the host requirements of the service according to the host information; When the host meets the host requirement, determining the use state of the network port corresponding to the network port information; When the using state of the network port is an unoccupied state, acquiring the instance information of the instance selector corresponding to the instance selector information; the control load balancer analyzes the request message and determines whether the request message has an associated message or not; and when the associated message does not exist in the request message, determining an instance which meets the load balancing policy in the instance information as a target instance for processing the request message.
- 2. The load balancing method of claim 1, wherein after the step of determining the usage status of the network port, further comprising: And when the use state of the network port is an occupied state, outputting error information to change the network port.
- 3. The load balancing method according to claim 1, wherein after the step of determining whether the request packet has an associated packet, further comprising: when the request message has an associated message, acquiring an instance for processing the associated message; Determining the instance for processing the association message as the target instance, and forwarding the request message to the target instance.
- 4. A load balancing system, the load balancing system comprising: a resource object for storing configuration information of a business service when a creation request of the business service is received, wherein the configuration information comprises host information, network port information, instance selector information and a load balancing policy; The service monitor is used for receiving configuration information of the resource object and determining instance information of the service according to the configuration information; the service monitor is also used for determining whether the current host meets the host requirement of the service according to the host information, determining the use state of a network port corresponding to the network port information when the host meets the host requirement, and acquiring the instance information of an instance selector corresponding to the instance selector information when the use state of the network port is in an unoccupied state; The load balancer is used for determining and processing a target instance of a request message when the request message is received and forwarding the request message to the target instance, and the steps of determining and processing the target instance of the request message and forwarding the request message to the target instance comprise analyzing the request message and determining whether the request message has an associated message or not, and determining that an instance meeting the load balancing policy corresponds to the target instance for processing the request message in the instance information when the request message does not have the associated message.
- 5. The load balancing system of claim 4, wherein the load balancer obtains the request message according to network port information in the configuration information.
- 6. A load balancing apparatus, the load balancing apparatus comprising: The creation module is used for creating a resource object associated with business service; The acquisition module is used for acquiring configuration information of the business service through the resource object when receiving the creation request of the business service, wherein the configuration information comprises host information, network port information, instance selector information and load balancing strategy; the load balancing module is used for obtaining instance information corresponding to the business service based on the configuration information, determining a target instance of a request message for processing the business service in an instance corresponding to the instance information according to the instance information and the configuration information, completing load balancing, obtaining instance information corresponding to the business service based on the configuration information, determining a target instance of a request message for processing the business service in the instance corresponding to the instance information according to the instance information and the configuration information, completing load balancing, and comprises the steps of controlling a business service monitor to determine whether a current host meets host requirements of the business service according to the host information, determining a use state of a network port corresponding to the network port information when the host meets the host requirements, obtaining instance information of an instance selector corresponding to the instance selector information when the use state of the network port is in an unoccupied state, controlling a load balancer to analyze the request message to determine whether the request message exists in an associated message, determining whether the request message exists in the instance corresponding to the instance information, and determining that the instance information does not exist in the associated instance meets the request message.
- 7. A load balancing device comprising a memory, a processor and a load balancing program stored in the memory and executable on the processor, the load balancing program when executed by the processor implementing the steps of the load balancing method according to any of claims 1-3.
- 8. A computer readable storage medium storing a load balancing program which when executed by a processor performs the steps of the load balancing method according to any one of claims 1-3.
Description
Load balancing method, system, device, equipment and readable storage medium Technical Field The present invention relates to the field of information technologies, and in particular, to a load balancing method, system, device, equipment, and readable storage medium. Background With the development of microservices and containerization, many container orchestration engines have emerged for managing containers. For example Kubernetes. Kubernetes is an open-source container arrangement and scheduling system, in which multiple containers can be created, an application instance runs in each container, and then management, discovery and access to the group of application instances are realized through a built-in load balancing strategy. Seven layers of load balancing capability are provided in Kubernetes through the Ingress and back-end components (Nginx, traefik, etc.) for access by clients outside the cluster. Using this approach requires the introduction of additional components and access map routing. That is, the complexity of current container orchestration engines to implement load balancing is high. Disclosure of Invention The invention mainly aims to provide a load balancing method, a system, a device, equipment and a readable storage medium, aiming at reducing the complexity of realizing load balancing of a load balancing system. In order to achieve the above object, the present invention provides a load balancing method, which includes the following steps: Creating a resource object associated with the business service; acquiring configuration information of the business service through the resource object when receiving the creation request of the business service; and obtaining instance information corresponding to the business service based on the configuration information, and determining a target instance for processing the request message of the business service in the instance corresponding to the instance information according to the instance information and the configuration information to finish load balancing. In an embodiment, the configuration information includes host information, network port information, and instance selector information, and the step of obtaining the instance information corresponding to the business service based on the configuration information includes: controlling a service monitor to determine whether a current host meets the host requirements of the service according to the host information; When the host meets the host requirement, determining the use state of the network port corresponding to the network port information; And when the using state of the network port is the unoccupied state, acquiring the instance information of the instance selector corresponding to the instance selector information. In an embodiment, after the step of determining the usage status of the network port, the method further includes: And when the use state of the network port is an occupied state, outputting error information to change the network port. In an embodiment, the configuration information includes a load balancing policy, and the determining, according to the instance information and the configuration information, a target instance for processing the request packet of the service in the instance corresponding to the instance information, completes a load balancing step, including: the control load balancer analyzes the request message and determines whether the request message has an associated message or not; and when the associated message does not exist in the request message, determining an instance which meets the load balancing policy in the instance information as a target instance for processing the request message. In an embodiment, after the step of determining whether the request packet has an association packet, the method further includes: when the request message has an associated message, acquiring an instance for processing the associated message; Determining the instance for processing the association message as the target instance, and forwarding the request message to the target instance. In order to achieve the above object, the present invention further provides a load balancing system, including: the resource object is used for storing configuration information of the business service when receiving a creation request of the business service; The service monitor is used for receiving configuration information of the resource object and determining instance information of the service according to the configuration information; and the load balancer is used for determining a target instance for processing the request message when receiving the request message and forwarding the request message to the target instance. In an embodiment, the load balancer obtains the request message according to network port information in the configuration information. In order to achieve the above object, the present invention further provides a load balancing appara