CN116418815A - Container cloud-based load balancing method, electronic device and readable storage medium - Google Patents

Container cloud-based load balancing method, electronic device and readable storage medium Download PDF

Info

Publication number
CN116418815A
CN116418815A CN202310284543.XA CN202310284543A CN116418815A CN 116418815 A CN116418815 A CN 116418815A CN 202310284543 A CN202310284543 A CN 202310284543A CN 116418815 A CN116418815 A CN 116418815A
Authority
CN
China
Prior art keywords
port
list
service
matched
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310284543.XA
Other languages
Chinese (zh)
Inventor
杨佳奇
刘青
马亮
周明伟
高伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202310284543.XA priority Critical patent/CN116418815A/en
Publication of CN116418815A publication Critical patent/CN116418815A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application discloses a load balancing method based on container cloud, electronic equipment and a readable storage medium, comprising the following steps: obtaining an IP list corresponding to the load equalizer, and determining a port list corresponding to each IP in the IP list; the IP list comprises the IP of at least one load balancer, the load balancer operates based on the container cloud and corresponds to a plurality of available ports, and the port list comprises occupied ports of the load balancer corresponding to the IP; obtaining a service to be matched, and obtaining a target port of the service to be matched based on the sequence of all the IPs in the IP list and a port list corresponding to the IPs; wherein the destination port is one of a plurality of available ports; setting the service IP of the service to be matched as the IP of the load balancer corresponding to the target port, and adding the target port as the occupied port into the corresponding port list. According to the scheme, the cost expenditure of load balancing can be reduced.

Description

Container cloud-based load balancing method, electronic device and readable storage medium
Technical Field
The present disclosure relates to the field of cloud computing technologies, and in particular, to a load balancing method based on container cloud, an electronic device, and a readable storage medium.
Background
With the advent of the data age, the current application program needs to process a large number of requests at the same time and feed back the data corresponding to the requests in a fast and reliable manner, so that in order to process such high traffic, a load balancing policy is increasingly focused, load balancing is a method for evenly distributing network traffic in a resource pool supporting the application program, the application program usually corresponds to at least one service, a corresponding service to be matched is obtained after the application program is newly added, in the prior art, in the process of carrying out load balancing, each service to be matched is distributed with a respective IP, and cost expenditure caused by a large number of IP addresses is extremely large. In view of this, how to reduce the cost expenditure of load balancing is a problem to be solved.
Disclosure of Invention
The technical problem that this application mainly solves is to provide a load balancing method, electronic equipment and readable storage medium based on container cloud, can reduce the cost expenditure of load balancing.
To solve the above technical problem, a first aspect of the present application provides a load balancing method based on a container cloud, including: obtaining an IP list corresponding to a load equalizer, and determining a port list corresponding to each IP in the IP list; the IP list comprises at least one IP of the load balancer, the load balancer operates based on a container cloud and corresponds to a plurality of available ports, and the port list comprises occupied ports of the load balancer corresponding to the IP; obtaining a service to be matched, and obtaining a target port of the service to be matched based on the sequence of all the IPs in the IP list and a port list corresponding to the IPs; wherein the destination port is one of the plurality of available ports; setting the service IP of the service to be matched as the IP of a load balancer corresponding to the target port, and adding the target port as the occupied port into the corresponding port list.
To solve the above technical problem, a second aspect of the present application provides an electronic device, including: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor invokes the program data to perform the method of the first aspect.
To solve the above technical problem, a third aspect of the present application provides a computer-readable storage medium having stored thereon program data, which when executed by a processor, implements the method described in the first aspect.
According to the scheme, the IP list corresponding to the load balancers is obtained, the port list corresponding to each IP is determined according to the IP in the IP list, wherein the IP list comprises at least one IP of the load balancers, the load balancers operate based on container cloud, each load balancers corresponds to a plurality of available ports, the occupied available ports are arranged in the port list corresponding to the IP as occupied ports, when the service to be matched is obtained, the IP is selected according to the sequence of all the IPs in the IP list, the target port corresponding to the service to be matched is determined from the available ports outside the port list corresponding to the IP, the service IP of the service to be matched is set as the IP of the load balancers corresponding to the target port, and the target port is corrected to the occupied port so as to be added into the corresponding port list, so that all the service to be matched corresponding to all the occupied ports corresponding to the same load balancers share the same IP, the use quantity of IP addresses is greatly reduced, and the cost of the load balancers is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. Wherein:
FIG. 1 is a flow diagram of an embodiment of a container cloud-based load balancing method of the present application;
FIG. 2 is a flow diagram of another embodiment of a container cloud-based load balancing method of the present application;
fig. 3 is a schematic view of an application scenario of an embodiment corresponding to step S204 in fig. 2;
FIG. 4 is a schematic diagram of an embodiment of an electronic device of the present application;
fig. 5 is a schematic structural diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
The following description of the technical solutions in the embodiments of the present application will be made clearly and completely with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The terms "system" and "network" are often used interchangeably herein. The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship. Further, "a plurality" herein means two or more than two.
The load balancing method based on the container cloud is used for determining the target port for the service to be matched and configuring the IP so as to realize load balancing, so that when the target port is accessed, the flow of the target port is forwarded to the corresponding service, and the corresponding execution body is a processor capable of calling the load balancing.
Referring to fig. 1, fig. 1 is a flow chart illustrating an embodiment of a method for load balancing based on container cloud, where the method includes:
s101: obtaining an IP list corresponding to the load balancer, and determining a port list corresponding to each IP in the IP list, wherein the IP list comprises the IP of at least one load balancer, the load balancer operates based on the container cloud and corresponds to a plurality of available ports, and the port list comprises occupied ports of the load balancer corresponding to the IP.
Specifically, an IP list corresponding to the load balancers is obtained, a port list corresponding to each IP is determined according to the IPs in the IP list, wherein the IP list comprises at least one IP of the load balancers, the load balancers operate based on container cloud, each load balancers corresponds to a plurality of available ports, and the occupied available ports are arranged in the port list corresponding to the IPs as occupied ports.
In an application mode, a plurality of load balancers run based on container cloud, each load balancer corresponds to an IP and is added in an IP list in advance, wherein the sequence of the IP in the IP list is ordered according to the time sequence set by the load balancers, each available port corresponds to a respective port number, after the available ports of the load balancers are occupied, the port numbers of the occupied available ports are added to the IP list corresponding to the IP of the load balancers, and after the IP list corresponding to the load balancers is obtained, the port list corresponding to each IP list is determined according to the sequence of the IP in the IP list.
In another application mode, the load balancer operates based on the container cloud, and comprises a plurality of available ports, each available port corresponds to a respective port number, an IP corresponding to the load balancer is preset in an IP list, the IP corresponds to a port list, when the available ports of the load balancer are occupied, the port numbers of the occupied available ports are added into the IP list corresponding to the IP of the load balancer, after the IP in the IP list is obtained, the port codes in the port list corresponding to the IP are obtained, and therefore unoccupied available ports outside the port list are obtained.
In an application scenario, the load balancer operates based on a kubernetes container cloud, so that a load balancing strategy is deployed based on kubernetes, deployment convenience and maintainability are improved, the IP of one load balancer is prestored in an IP list until all available ports in the IP list are added to a port list corresponding to the IP, a new load balancer is obtained, and the newly added load-balanced IP is added to the IP list, so that the number of the used IPs is reduced.
S102: and obtaining a service to be matched, and obtaining a target port of the service to be matched based on the sequence of all the IPs in the IP list and a port list corresponding to the IPs, wherein the target port is one of a plurality of available ports.
Specifically, when the service to be matched is obtained, selecting the IP according to the sequence of all the IPs in the IP list, and determining a target port corresponding to the service to be matched from available ports outside the port list corresponding to the IP.
In an application mode, each available port corresponds to a respective port number, in response to obtaining a service to be matched, an IP still including the available port not set in the port list is selected according to the sequence of all IPs in the IP list, and from the available ports outside the port list corresponding to the IP, a port with the smallest port number is selected as a target port corresponding to the service to be matched according to the sequence of the port numbers of the available ports.
In another application mode, responding to the service to be matched, selecting the IP which still comprises the available ports which are not arranged in the port list according to the sequence of all the IPs in the IP list, and randomly selecting one port from the available ports which are outside the port list corresponding to the IP as a target port corresponding to the service to be matched.
S103: setting the service IP of the service to be matched as the IP of the load balancer corresponding to the target port, and adding the target port as the occupied port into the corresponding port list.
Specifically, the service IP of the service to be matched is set as the IP of the load balancer corresponding to the target port, and the target port is modified to be an occupied port so as to be added into the corresponding port list, so that all the services to be matched corresponding to all the occupied ports corresponding to the same load balancer share the same IP, thereby greatly reducing the number of used IP addresses and reducing the cost expenditure of load balancing.
In an application mode, the service IP of the service to be matched corresponds to a service IP field, the IP of the load balancer corresponding to the target port is utilized to fill the corresponding service IP field of the service to be matched, so that the service IP of the service to be matched is set as the IP of the load balancer corresponding to the target port, and the target port is added into the corresponding port list.
In another application mode, the available ports correspond to port numbers, the service IPs of the services to be matched correspond to service IP fields, the service IPs of the corresponding services to be matched are filled with the IPs of the load balancers corresponding to the target ports and the port numbers of the target ports, so that the service IPs of the services to be matched are set as the IPs of the load balancers corresponding to the target ports, and the port numbers of the target ports are added to the corresponding port lists, so that the target ports are corrected to be occupied ports.
In a specific application scenario, the load balancer operates based on a Kubernetes container cloud, where in the prior art, kubernetes provides three external access modes, nodePort, loadBalancer and Ingress. The node is the most original way of guiding external traffic to services, the Ingress is an interface object for managing external access of services in a cluster, the LoadBalancer is a standard way of exposing services to the internet, the way starts a network load balancer Network Load Balancer, each service exposed by the existing way has its own IP address, each IP needs to pay, and the cost of load balancing is greatly increased.
According to the scheme, the IP list corresponding to the load balancers is obtained, the port list corresponding to each IP is determined according to the IP in the IP list, wherein the IP list comprises at least one IP of the load balancers, the load balancers operate based on container cloud, each load balancers corresponds to a plurality of available ports, the occupied available ports are arranged in the port list corresponding to the IP as occupied ports, when the service to be matched is obtained, the IP is selected according to the sequence of all the IPs in the IP list, the target port corresponding to the service to be matched is determined from the available ports outside the port list corresponding to the IP, the service IP of the service to be matched is set as the IP of the load balancers corresponding to the target port, and the target port is corrected to the occupied port so as to be added into the corresponding port list, so that all the service to be matched corresponding to all the occupied ports corresponding to the same load balancers share the same IP, the use quantity of IP addresses is greatly reduced, and the cost of the load balancers is reduced.
Referring to fig. 2, fig. 2 is a schematic flow chart of another embodiment of a load balancing method based on container cloud, where the method includes:
s201: obtaining an IP list corresponding to the load balancer, and determining a port list corresponding to each IP in the IP list, wherein the IP list comprises the IP of at least one load balancer, the load balancer operates based on the container cloud and corresponds to a plurality of available ports, and the port list comprises occupied ports of the load balancer corresponding to the IP.
Specifically, an IP list corresponding to the load balancer is obtained, and a port list corresponding to each IP is determined according to the IPs in the IP list. The load balancer operates based on the container cloud, the load balancer corresponds to an IP and is arranged in an IP list, and the load balancer corresponds to a plurality of available ports, wherein the available ports are all arranged outside the port list in the initial stage, and when any available port is occupied, the available port is corrected to be an occupied port and added into the port list.
Further, all the IPs in the IP list have been set on the physical machine, and the order of all the IPs in the IP list is related to the timing of the addition of the corresponding load balancer. The IP of the load equalizer is arranged on the physical machine for the external equipment to access.
In an application scenario, obtaining an IP list corresponding to the load balancer, and after determining a port list corresponding to each IP in the IP list, further includes: in response to obtaining the load balancer to be set, setting the newly added IP of the load balancer to be set in sequence behind the IP in the IP list; and in response to the detection of the new IP obtained from the IP list, setting the new IP on a physical network card of the physical machine, and correcting the load equalizer to be set into the set load equalizer.
Specifically, when a newly added load balancer is obtained, the newly added load balancer is taken as a load balancer to be set, and the IP of the load balancer to be set is set after the IP in the IP list as a newly added IP, so that the newly added IP is added to the IP list at the timing of the load balancer addition.
Further, when the newly added IP is obtained from the IP list, the newly added IP is set on a physical network card of the physical machine, so that the newly added IP can be accessed by external equipment, a load balancer corresponding to the IP can be used, and the load balancer to be set is corrected to be the set load balancer.
It should be noted that, by monitoring the IP list, after obtaining the new IP in the IP list, the new IP is set on the physical network card of the physical machine in time, so as to ensure the availability of each IP in the IP list, and realize high availability of the IP.
In one embodiment, in response to detecting that a new IP is obtained from the IP list, setting the new IP to a physical network card of the physical machine, and correcting the load balancer to be set to be a set load balancer, including: monitoring the IP list by using a service daemon until a new IP is obtained from the IP list; acquiring a hash conversion value of the newly added IP, and determining a target physical machine corresponding to the newly added IP based on the ratio between the hash conversion value and the number of the physical machines; and setting the newly added IP to a physical network card of the target physical machine.
Specifically, the service daemon is used for monitoring the IP list, after the newly added IP is obtained in the IP list, the newly added IP is monitored by the service daemon, the newly added IP is determined, hash conversion is carried out on the newly added IP, a hash conversion value of the newly added IP is obtained, the ratio of the hash conversion value to the number of the physical machines is obtained, and therefore one physical machine is selected as a target physical machine for the newly added IP based on the ratio, the newly added IP is arranged on a physical network card of the target physical machine, the efficiency of arranging the newly added IP on the physical machine in the IP list is improved, and when the IP is provided with the physical machines, the balance of the number of the IPs on the physical machines is improved.
In a specific application scenario, a service daemon is utilized to deploy services, each physical machine is used as a node, an lb-pod is operated on the node, an IP list is monitored by the lb-pod, when a new IP is added in the IP list, the lb-pod acquires the new IP, jhash calculation is carried out on the IP to obtain a hash conversion value, the hash conversion value is divided by the number node of the currently available physical machines to obtain a return value, a target physical machine corresponding to the new IP is determined based on the remainder in the return value, when the remainder is 0, the current physical machine is used as the target physical machine of the new IP, when other values except the preset value are set, the corresponding numerical physical machines behind the current physical machine are used as the target physical machines of the new IP, and therefore the balance of the number of the IPs on the physical machines is improved.
Optionally, the number of the physical machines is multiple, and after setting the new IP to the physical network card of the target physical machine, the method includes: responding to the service daemon to monitor the abnormality of the physical machine corresponding to any IP in the IP list, taking all the IPs arranged on the abnormal physical machine as newly-added IPs, and updating the number of the physical machines based on the abnormal physical machine; returning to the step of obtaining the hash conversion value of the newly added IP, and determining the target physical machine corresponding to the newly added IP based on the ratio between the hash conversion value and the number of the physical machines.
Specifically, when the service daemon monitors that the physical machines corresponding to the IP exist in the IP list are abnormal, temporarily removing the physical machines with the abnormality from the total number of the physical machines to obtain the number of updated physical machines, taking all the IP which are already arranged on the physical machines with the abnormality as new IP, returning to the step of obtaining the hash conversion value of the new IP, determining the target physical machine corresponding to the new IP based on the ratio between the hash conversion value and the number of the physical machines, and resetting the IP on the physical machines with the abnormality to the normal physical machines to improve the reliability and the stability of the load equalizer.
In a specific application scenario, a service daemon is utilized to deploy services, each physical machine is used as a node, an lb-pod is operated on the node, if the physical machine with the IP in the IP list is abnormal, the lb-pod acquires a non ready event of the node, all the IPs arranged on the physical machine with the abnormality are used as newly added IPs, the total number of the physical machines is updated, and therefore the IPs on the physical machine with the abnormality are reset to the rest physical machines.
S202: and responding to the newly added service, and taking the newly added service as a service to be matched, wherein the access mode of the service to be matched is based on the access of the load balancer, and the service to be matched corresponds to a service IP field.
Specifically, when a newly added service is obtained, the newly added service is used as a service to be matched, wherein the service to be matched corresponds to an application program, the access mode of the service to be matched is set to be based on the access of a load balancer, each service to be matched corresponds to a service IP field, and the initial service IP field is empty.
S203: the IP including the available port is selected as the available IP based on the order of all the IPs in the IP list.
Specifically, when the available ports are occupied, the available ports are updated to be occupied ports and added to the port list, the first IP including the available ports is determined to be the available IP from the initial IP in the IP list according to the sequence of the IP, that is, if the initial IP in the IP list also includes the available ports which are not added to the port list, the initial IP is used as the available IP, otherwise, traversal is performed from the initial IP in sequence, and the IP including the available ports at the forefront end in the IP list is found to be the available IP, so that the occupied amount of the IP is reduced.
It will be appreciated that when only one IP is included in the IP list, the current IP is taken as the available IP as long as the available ports of the current IP are not fully occupied, and all the matched services share the same IP.
S204: and determining a target port corresponding to the service to be matched from all available ports except the port list corresponding to the available IP, so that when the target port is accessed, the traffic of the target port is forwarded to the corresponding service.
Specifically, all available ports outside a port list corresponding to the available IP are determined, one available port is selected from the available ports outside the port list to serve as a target port of the service to be matched, after the target port is matched with the service to be matched, the target port points to the service to be matched, and when the target port is accessed, the traffic of the target port is completely forwarded to the service pointed by the target port, so that the traffic forwarding process is completed on the container cloud, namely in the kernel, and a third party is not required to be passed, thereby improving the service performance.
It should be noted that, before determining the target port corresponding to the service to be matched from all available ports except the port list corresponding to the available IP, the method includes: and responding to the fact that the IP list comprises a plurality of IPs and the service to be matched corresponds to the appointed port, determining the IP without the appointed port in the port list according to the sequence of the IPs in the IP list by taking the current available IP as a starting point, and taking the IP as the appointed IP.
Specifically, when the IP list includes a plurality of IPs and the service to be matched selects the designated port, the current available IP is used as a starting point, whether the designated port is included in the port list corresponding to the current available IP is searched, if not, the current available IP is used as the designated IP, if so, the IP after the current available IP in the IP list is updated to the available IP, and whether the designated port is included in the port list corresponding to the current available IP is searched until the IP which does not include the designated port in the port list is obtained as the designated IP.
Further, determining a target port corresponding to the service to be matched from all available ports except the port list corresponding to the available IP, including: and taking the appointed port as a target port corresponding to the service to be matched from all available ports except the port list corresponding to the appointed IP.
It can be understood that the designated IP can allocate a designated port for the service to be matched, so that the designated port is used as a target port corresponding to the service to be matched, so as to meet the designated requirement of the service to be matched.
In a specific application scenario, referring to fig. 3, fig. 3 is a schematic diagram of an application scenario corresponding to step S204 in fig. 2, in which service 1 and service 2 are respectively matched with port 1 and port 2 in IP1, when the designated port of service 3 is port 1, the available IP obtained from the IP list is IP1 first, and the port list of IP1 is searched to find that port 1 exists in the port list, so that the port list corresponding to IP2 after IP1 in the IP list is searched, when the port class corresponding to IP2 does not include port 1, service 3 is matched with port 1 in IP2, and port 1 is added to the port list corresponding to IP2, so that the use of IP is reduced as much as possible, and the designated requirements of different services are met.
S205: and filling a service IP field corresponding to the service to be matched by using the IP of the load balancer corresponding to the target port.
Specifically, the IP of the load balancer corresponding to the target port is used to fill the service IP field corresponding to the service to be matched, so that the service IP of the service to be matched is set as the IP of the load balancer corresponding to the target port.
Further, referring to fig. 3 again, taking fig. 3 as an example, in order to distinguish services corresponding to the same IP, the service fields include, in addition to the IP corresponding to the destination port, a port number corresponding to the port, for example, the service IP field corresponding to the service 1 includes IP1 and port number 1, the service IP field corresponding to the service 2 includes IP1 and port number 2, and the service IP field corresponding to the service 3 includes IP2 and port number 1, so that the service IP fields corresponding to each service are distinguished from each other, so as to distinguish different services.
S206: and adding the target port as an occupied port into a corresponding port list, and correcting the service to be matched into the matched service.
Specifically, the target port is corrected to be an occupied port and added into a corresponding port list, and the service to be matched is corrected to be a matched service, so that a load balancing setting flow of the service to be matched is completed, until a new service to be matched is acquired, the process returns to the step of acquiring an IP list corresponding to the load balancer, and the port list corresponding to each IP in the IP list is determined.
In this embodiment, the service daemon monitors the IP list, and monitors the IP list to obtain a new IP in the IP list, and then sets the new IP on a physical network card of the physical machine in time, so as to ensure availability of each IP in the IP list, realize high availability of the IP, determine, from the initial IP in order of the IP in the IP list, a first IP further including an available port as an available IP, thereby reducing the occupation amount of the IP, select one available port from all available ports except the port list corresponding to the available IP as a target port of the service to be matched, and when the target port is accessed, forward the traffic of the target port to the service pointed by the target port entirely, so that the traffic forwarding process is completed on the container cloud, that is, in the kernel, without a third party, thereby improving the service performance.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an embodiment of an electronic device according to the present application, where the electronic device 40 includes a memory 401 and a processor 402 coupled to each other, where the memory 401 stores program data (not shown), and the processor 402 invokes the program data to implement a method in any of the above embodiments, and the description of the related content refers to the detailed description of the above method embodiments, which is not repeated herein.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an embodiment of a computer readable storage medium 50 of the present application, where the computer readable storage medium 50 stores program data 500, and the program data 500 when executed by a processor implements the method in any of the above embodiments, and details of the related content are described in the above embodiments, which are not repeated herein.
The units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all or part of the technical solution contributing to the prior art or in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing description is only of embodiments of the present application, and is not intended to limit the scope of the patent application, and all equivalent structures or equivalent processes using the descriptions and the contents of the present application or other related technical fields are included in the scope of the patent application.

Claims (10)

1. A method of load balancing based on a container cloud, the method comprising:
obtaining an IP list corresponding to a load equalizer, and determining a port list corresponding to each IP in the IP list; the IP list comprises at least one IP of the load balancer, the load balancer operates based on a container cloud and corresponds to a plurality of available ports, and the port list comprises occupied ports of the load balancer corresponding to the IP;
obtaining a service to be matched, and obtaining a target port of the service to be matched based on the sequence of all the IPs in the IP list and a port list corresponding to the IPs; wherein the destination port is one of the plurality of available ports;
setting the service IP of the service to be matched as the IP of a load balancer corresponding to the target port, and adding the target port as the occupied port into the corresponding port list.
2. The method for balancing load based on container cloud according to claim 1, wherein the obtaining the service to be matched, based on the order of all the IPs in the IP list and the port list corresponding to the IPs, obtains the target port of the service to be matched, includes:
responding to obtaining a newly added service, and taking the newly added service as the service to be matched; the access mode of the service to be matched is based on load balancer access, and the service to be matched corresponds to a service IP field;
selecting an IP including the available port as an available IP based on the order of all the IPs in the IP list;
and determining the target port corresponding to the service to be matched from all available ports except the port list corresponding to the available IP, so that when the target port is accessed, the traffic of the target port is forwarded to the corresponding service.
3. The container cloud-based load balancing method according to claim 2, wherein the determining the target port corresponding to the service to be matched from all the available ports except the port list corresponding to the available IP includes:
responding to the IP list comprising a plurality of IPs, wherein the service to be matched corresponds to a designated port, and determining the IP which does not comprise the designated port in the port list as the designated IP according to the sequence of the IPs in the IP list by taking the current available IP as a starting point;
the determining the target port corresponding to the service to be matched from all the available ports except the port list corresponding to the available IP includes:
and taking the appointed port as the target port corresponding to the service to be matched from all available ports except the port list corresponding to the appointed IP.
4. The method for container cloud-based load balancing according to claim 2, wherein the setting the service IP of the service to be matched as the IP of the load balancer corresponding to the target port, and adding the target port as the occupied port to the corresponding port list includes:
filling the service IP field corresponding to the service to be matched by utilizing the IP of the load balancer corresponding to the target port;
and adding the target port as the occupied port into the corresponding port list, and correcting the service to be matched into the matched service.
5. The container cloud-based load balancing method of claim 1, wherein all of the IPs in the IP list have been set on a physical machine, and wherein the order of all of the IPs in the IP list is related to the timing of the corresponding load balancer addition.
6. The method for container cloud-based load balancing according to claim 5, wherein the obtaining the IP list corresponding to the load balancer, after determining the port list corresponding to each IP in the IP list, further comprises:
responding to the acquisition of a load balancer to be set, and setting the newly added IP of the load balancer to be set behind the IP in the IP list according to the sequence;
and responding to the detection that the new IP is obtained from the IP list, setting the new IP on a physical network card of the physical machine, and correcting the load equalizer to be set into a set load equalizer.
7. The container cloud-based load balancing method according to claim 6, wherein the setting the new IP on a physical network card of the physical machine and correcting the load balancer to be set to a set load balancer in response to monitoring that the new IP is obtained from the IP list comprises:
monitoring the IP list by using a service daemon until the newly added IP is obtained from the IP list;
acquiring a hash conversion value of the newly added IP, and determining a target physical machine corresponding to the newly added IP based on a ratio between the hash conversion value and the number of the physical machines;
and setting the newly added IP to a physical network card of the target physical machine.
8. The method for container cloud-based load balancing according to claim 7, wherein the number of physical machines is plural, and after the setting the new IP on the physical network card of the target physical machine, the method comprises:
responding to the service daemon to monitor that the physical machine corresponding to any IP in the IP list is abnormal, taking all the IPs arranged on the physical machine with the abnormality as newly-added IPs, and updating the quantity of the physical machines based on the physical machine with the abnormality;
returning to the step of obtaining the hash conversion value of the new IP, and determining the target physical machine corresponding to the new IP based on the ratio between the hash conversion value and the number of the physical machines.
9. An electronic device, comprising: a memory and a processor coupled to each other, wherein the memory stores program data that the processor invokes to perform the method of any of claims 1-8.
10. A computer readable storage medium having stored thereon program data, which when executed by a processor, implements the method of any of claims 1-8.
CN202310284543.XA 2023-03-21 2023-03-21 Container cloud-based load balancing method, electronic device and readable storage medium Pending CN116418815A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310284543.XA CN116418815A (en) 2023-03-21 2023-03-21 Container cloud-based load balancing method, electronic device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310284543.XA CN116418815A (en) 2023-03-21 2023-03-21 Container cloud-based load balancing method, electronic device and readable storage medium

Publications (1)

Publication Number Publication Date
CN116418815A true CN116418815A (en) 2023-07-11

Family

ID=87050795

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310284543.XA Pending CN116418815A (en) 2023-03-21 2023-03-21 Container cloud-based load balancing method, electronic device and readable storage medium

Country Status (1)

Country Link
CN (1) CN116418815A (en)

Similar Documents

Publication Publication Date Title
CN108881448B (en) API request processing method and device
US11044150B2 (en) Consistent hashing for network traffic dispatching
CN108881512B (en) CTDB virtual IP balance distribution method, device, equipment and medium
CN103744719B (en) Lock management method and system, the collocation method and device of lock administration system
CN110601922B (en) Method and device for realizing comparison experiment, electronic equipment and storage medium
CN108933829A (en) A kind of load-balancing method and device
CN109995842B (en) Grouping method and device for distributed server cluster
US11403009B2 (en) Storage system, and method and apparatus for allocating storage resources
CN103607424B (en) Server connection method and server system
CN112948120A (en) Load balancing method, system, device and storage medium
US20240095082A1 (en) Method and system for multiple services to share same gpu, and device and medium
CN107105013B (en) File processing method, server, terminal and system
CN112015544A (en) Load balancing method, device and equipment of k8s cluster and storage medium
EP3958122A1 (en) Memory management method, apparatus, and system
CN110442610A (en) The method, apparatus of load balancing calculates equipment and medium
US20170142203A1 (en) Method for host scheduling for container deployment, electronic device and non-transitory computer-readable storage medium
CN109491788A (en) A kind of virtual platform implementation of load balancing and device
EP4369181A1 (en) Node for running container group, and management system and method of container group
CN107172214A (en) A kind of service node with load balancing finds method and device
US8458509B1 (en) Multipath failover
CN111352726A (en) Streaming data processing method and device based on containerized micro-service
CN111371911A (en) Domain name resolution system and method
CN113536168A (en) Component processing method and device
CN108366102A (en) A kind of service discovery method, device and electronic equipment based on Consul
CN111198756A (en) Application scheduling method and device of kubernets cluster

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination