Server load balancing method and device, equipment and storage medium
By configuring the virtual network port and OSPF protocol on the server, monitoring and adjusting the load balancing strategy, the problem of insufficient load state perception in the existing technology is solved, efficient load balancing and accuracy are achieved, and deployment costs are reduced.
Patent Information
- Application Number
- CN202411768267.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-01-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art lacks load state awareness during server load balancing, resulting in slow request response and degraded service quality, and the introduction of additional LVS increases deployment costs and affects response speed.
By configuring multiple virtual network ports on the server and deploying a first process based on the OSPF protocol, the first process publishes the server's physical IP address and virtual IP address to generate a forwarding table, monitors processing pressure, and disables virtual when the pressure exceeds the threshold. Network port update forwarding tables to avoid using extra LVS.
The server is actively load balancing is realized, the accuracy and efficiency of load balancing is improved, the deployment cost is reduced, and additional network latency is avoided.
Smart Images

Figure CN119248517A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a server load balancing method, device, equipment and storage medium. Background Art
[0002] For client access requests for a specific virtual IP address, the switch uses a four-tuple (destination IP, destination port, source IP, and source port) hash method to forward the client's access request to the server associated with the specific virtual IP address.
[0003] Since the switch only forwards requests to the server in the form of four-tuple hashing when performing forwarding operations, it does not have the ability to perceive the current load status of the server. Therefore, if some servers have insufficient performance due to uneven load or hardware performance differences, the switch cannot adjust the forwarding strategy accordingly, resulting in slow response to client requests and reduced service quality.
[0004] Currently, there are some technologies that can be used to alleviate this situation, such as adding a layer of Linux virtual server LVS (Linux Virtual Server) between the switch and the server cluster. The switch first forwards the access request to the LVS, and then the LVS uses polling and four-tuple hashing to forward the access request to the corresponding server. However, the additional LVS increases the deployment cost. Secondly, since the request needs to be forwarded through the LVS, it will introduce additional network delays, affecting the request response speed. Summary of the invention
[0005] In view of this, the present application provides a server load balancing method, apparatus, device and storage medium to address the deficiencies in the related art.
[0006] In a first aspect of the present application, a server load balancing method is provided, wherein the server is configured with multiple virtual network ports and a first process running based on an open shortest path first (OSPF) protocol is deployed, wherein each virtual network port is configured with a virtual IP address, and the method comprises: Using the first process to publish the first IP address information of the server, so that the switch generates a forwarding table according to the received first IP address information, and forwards the access request from the client to the server according to the forwarding table, wherein the first IP address information includes the physical IP address of the server and multiple virtual IP addresses; monitoring the processing pressure of the server in processing the access request; When the processing pressure exceeds a first set threshold, one or more of the multiple virtual network ports are set to a disabled state, and the first process is used to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table, wherein the second IP address information includes the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state.
[0007] According to an embodiment of the present application, the server is any server in a server group, and the server group is used to receive an access request from a client for any virtual IP address among the multiple virtual IP addresses.
[0008] According to an embodiment of the present application, for each virtual network port among the multiple virtual network ports, at least one server in the server group is unable to set the virtual network port to a disabled state.
[0009] According to an embodiment of the present application, forwarding the access request from the client to the server according to the forwarding table includes: After receiving an access request for a target virtual IP address from a client, the switch performs a hash calculation according to the destination IP, destination port, source IP and source port of the access request to obtain a hash value, wherein the target virtual IP address is allocated to the client from the multiple virtual IP addresses by a domain name server DNS according to a pre-configured allocation rule; Determine the physical IP address of the target server from the forwarding table according to the target virtual IP address and the hash value; The access request is forwarded to the target server according to the physical IP address of the target server.
[0010] According to an embodiment of the present application, generating a forwarding table according to the received first IP address information includes: The switch uses the OSPF protocol to generate a forwarding table according to the received physical IP address of the server and the multiple virtual IP addresses, wherein each entry in the forwarding table contains a mapping relationship between a virtual IP address and the physical IP address of the server.
[0011] According to one embodiment of the present application, the method further includes: When the processing pressure is lower than a second set threshold value, and the duration for which the processing pressure is lower than the second set threshold value satisfies a preset condition, one or more virtual network ports in a disabled state are set to a non-disabled state, and the second IP address information of the server is published using the first process, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table.
[0012] In a second aspect of the present application, a server load balancing device is provided, wherein the server is configured with multiple virtual network ports and a first process running based on an open shortest path first (OSPF) protocol is deployed, wherein each virtual network port is configured with a virtual IP address, and the device comprises: a processing unit, configured to publish the first IP address information of the server by using the first process, so that the switch generates a forwarding table according to the received first IP address information, and forwards the access request from the client to the server according to the forwarding table, wherein the first IP address information includes a physical IP address of the server and a plurality of virtual IP addresses; A monitoring unit, used for monitoring the processing pressure of the server in processing the access request; A load balancing unit, configured to set one or more of the multiple virtual network ports to a disabled state when the processing pressure exceeds a first set threshold, and to use the first process to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table, wherein the second IP address information includes the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state.
[0013] According to an embodiment of the present application, the server is any server in a server group, and the server group is used to receive an access request from a client for any virtual IP address among the multiple virtual IP addresses.
[0014] According to an embodiment of the present application, for each virtual network port among the multiple virtual network ports, at least one server in the server group is unable to set the virtual network port to a disabled state.
[0015] In a third aspect of the present application, an electronic device is provided, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor is used to execute the machine executable instructions to implement the steps of the method proposed in the above embodiment.
[0016] In a fourth aspect of the present application, a machine-readable storage medium is provided, wherein the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are executed by a processor, the steps of the method proposed in the above embodiment are implemented.
[0017] In a fifth aspect of the present application, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the method proposed in the above embodiment when executed by a processor.
[0018] It can be seen from the above technical solution that the server is configured with multiple virtual network ports and a first process running based on the OSPF protocol is deployed. Each virtual network port is configured with a virtual IP address. The physical IP address of the server and multiple virtual IP addresses are published by the first process, so that the switch generates a forwarding table according to the received IP address information, and forwards the access request from the client to the server according to the forwarding table, monitors the processing pressure of the server processing the access request, and when the processing pressure exceeds the first set threshold, sets one or more virtual network ports to a disabled state, and uses the first process to publish the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state, so that the switch updates the forwarding table according to the received IP address information, and forwards the access request from the client to the server according to the updated forwarding table, thereby eliminating the need to use an additional LVS. The server itself can actively perform pressure reduction adjustment when its own performance is insufficient, which not only realizes active load balancing of servers based on OSPF, but also improves the accuracy of load balancing.
[0019] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a schematic diagram of forwarding a client access request provided in an embodiment of the present application; Figure 2 It is a flow chart of a server load balancing method provided in an embodiment of the present application; Figure 3 It is a flow chart of a server load balancing method provided in an embodiment of the present application; Figure 4 It is a structural diagram of a server load balancing device provided in an embodiment of the present application; Figure 5 It is a schematic diagram of the hardware structure of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0021] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0022] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0023] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.
[0024] For client access requests for a specific virtual IP address, the switch uses a four-tuple (destination IP, destination port, source IP, and source port) hash method to forward the client's access request to the server associated with the specific virtual IP address.
[0025] like Figure 1 As shown, Figure 1 This is a schematic diagram of forwarding a client access request provided in an embodiment of the present application.
[0026] Among them, server A is configured with a virtual IP address of 192.168.1.1, and the physical IP address of server A is 192.168.1.11; server B is configured with a virtual IP address of 192.168.1.1, and the physical IP address of server B is 192.168.1.12; server C is configured with a virtual IP address of 192.168.1.1, and the physical IP address of server C is 192.168.1.13; server D is configured with a virtual IP address of 192.168.1.1, and the physical IP address of server D is 192.168.1.14.
[0027] The switch pre-establishes a forwarding table, and the entry in the forwarding table with a destination IP of 192.168.1.1 has the next-hop addresses of server A's physical IP address of 192.168.1.11, server C's physical IP address of 192.168.1.12, server C's physical IP address of 192.168.1.13, and server D's physical IP address of 192.168.1.14. That is, the switch can forward access requests with a destination IP of 192.168.1.1 to servers with physical IP addresses of 192.168.1.11, 192.168.1.12, 192.168.1.13, or 192.168.1.14.
[0028] After the switch receives an access request from the client for the specific virtual IP address 192.168.1.1, it uses a four-tuple (destination IP, destination port, source IP, and source port) hash method to calculate, and selects a route from the four next-hop addresses in the table entry with the destination IP of 192.168.1.1 based on the calculated value.
[0029] For example, assuming that the calculated value points to the physical IP address 192.168.1.13 of server C, the switch can forward the access request from the client for the specific virtual IP address 192.168.1.1 to server C.
[0030] However, this implementation has certain limitations, that is, when the switch performs forwarding operations, it only forwards access requests to the server in the form of four-tuple hashing, and it does not have the ability to perceive the current load status of the server. Therefore, if some servers have insufficient performance due to uneven load or hardware performance differences, there is no way for the switch to perceive this and change the load balancing method, resulting in slow client request responses and reduced service quality.
[0031] Currently, there are some technologies that can be used to alleviate this situation, such as adding a layer of Linux virtual server LVS (Linux Virtual Server) between the switch and the server cluster. The switch first forwards the access request to the LVS, and then the LVS uses polling and four-tuple hashing to forward the access request to the corresponding server. However, the additional LVS increases the deployment cost. Secondly, since the request needs to be forwarded through the LVS, it will introduce additional network delays, affecting the request response speed.
[0032] In view of this, an embodiment of the present application discloses a server load balancing method to address the deficiencies in the related art.
[0033] like Figure 2 As shown, Figure 2 This is a flow chart of a server load balancing method provided by an embodiment of the present application. The embodiment of the present application does not limit the execution subject of the method process. Optionally, the execution subject can be any electronic device. For example, a server that needs to be load balanced, or a computing device used for server load balancing, etc.
[0034] The server load balancing method may include the following steps: S201: Utilize the first process to publish the first IP address information of the server, so that the switch generates a forwarding table according to the received first IP address information, and forwards the access request from the client to the server according to the forwarding table, wherein the first IP address information includes the physical IP address of the server and multiple virtual IP addresses.
[0035] In an embodiment of the present application, multiple virtual network ports may be created in advance on the server, and a VIP (virtual IP address) may be configured on each virtual network port, so that the server is configured with multiple virtual IP addresses.
[0036] In an embodiment of the present application, a server is deployed with a first process running based on the Open Shortest Path First (OSPF) protocol.
[0037] Exemplarily, the first process mentioned above can be the Open Shortest Path First Daemon (OSPFD) in Zebra or Quagga software. OSPFD is a daemon responsible for implementing the OSPF protocol. It maintains OSPF routing information, exchanges routing updates with other OSPF routers, and builds a forwarding table (routing table) to guide data packet forwarding in the network.
[0038] In some embodiments, the first process may be used to obtain and publish routing publishing rules to publish multiple virtual IP addresses of the server, wherein the multiple virtual IP addresses of the server refer to virtual IP addresses configured on the multiple virtual network ports of the server.
[0039] The user can add a route publishing rule by modifying the configuration of the first process. The route publishing rule can instruct the first process to publish a specific network segment (VIP) and area in the OSPF protocol.
[0040] For example, the route advertisement rule can be as follows: network 192.168.1.1 / 32 area 0.0.0.0 network 192.168.1.2 / 32 area 0.0.0.0 network 192.168.1.3 / 32 area 0.0.0.0 network 192.168.1.4 / 32 area 0.0.0.0 Among them, "192.168.1.1", "192.168.1.2", "192.168.1.3" and "192.168.1.4" are multiple virtual IP addresses configured for the server, and "area 0.0.0.0" is the area. "area 0.0.0.0" is usually designated as the backbone area in the OSPF network, also known as area 0. "area 0.0.0.0" means that multiple virtual IP addresses (192.168.1.1, 192.168.1.2, 192.168.1.3 and 192.168.1.4 / 32) are all configured in the backbone area, which means that these virtual IP addresses belong to the backbone part of the OSPF network and will participate in the routing calculation and information distribution of the entire OSPF domain.
[0041] In this embodiment, the first process is used to obtain and publish routing publishing rules, so that the server can notify other devices in the network (such as switches) of its configured multiple virtual IP addresses. In this way, other devices in the network (such as switches) can obtain the multiple virtual IP addresses configured for the server.
[0042] In an embodiment of the present application, after the first IP address information of the server (the physical IP address and multiple virtual IP addresses of the server) is published by the first process, the switch in the network can receive the first IP address information and generate a forwarding table according to the first IP address information.
[0043] In some embodiments, the switch uses the OSPF protocol to generate a forwarding table based on the received physical IP address of the server and the multiple virtual IP addresses, wherein each entry in the forwarding table includes a mapping relationship between a virtual IP address and the physical IP address of the server.
[0044] The server publishes the server's physical IP address and multiple virtual IP addresses through a first process running based on the OSPF protocol, and starts the OSPF protocol on the switch. After the switch receives the physical IP address and multiple virtual IP addresses published by the server, a route for each of the multiple virtual IP addresses can be formed on the switch.
[0045] For example, assuming that the multiple virtual IP addresses in the first IP address information are 192.168.1.1, 192.168.1.2, 192.168.1.3 and 192.168.1.4, and the physical IP address of the server in the first IP address information is 192.168.1.11. The switch will generate forwarding entries for the virtual IP addresses 192.168.1.1, 192.168.1.2, 192.168.1.3 and 192.168.1.4 in the forwarding table, wherein the forwarding entry for the virtual IP address 192.168.1.1 may be as follows: 192.168.1.1 192.168.1.11 This means that the access request from the client with the destination IP of 192.168.1.1 can be forwarded to the server with the physical IP address of 192.168.1.11.
[0046] Similarly, the forwarding table entries for virtual IP addresses 192.168.1.2, 192.168.1.3, and 192.168.1.4 are also the same, and are not described again here.
[0047] In some embodiments, the server is any server in a server group, and the server group is used to receive an access request from a client for any virtual IP address among the multiple virtual IP addresses.
[0048] The server group includes multiple servers, each server is configured with the same number of virtual network ports, each virtual network port is configured with a virtual IP address, and each server is configured with the same multiple virtual IP addresses.
[0049] For example, the server group includes server A, server B, server C and server D. Each server is configured with virtual network ports lo1, lo2, lo3 and lo4. The virtual network port lo1 on each server is configured with a virtual IP address 192.168.1.1, the virtual network port lo2 on each server is configured with a virtual IP address 192.168.1.2, the virtual network port lo3 on each server is configured with a virtual IP address 192.168.1.3, and the virtual network port lo4 on each server is configured with a virtual IP address 192.168.1.4.
[0050] An access request from a client to any of the multiple virtual IP addresses will be forwarded to a server in the server group.
[0051] In some embodiments, each server in the server group will publish multiple virtual IP addresses and physical IP addresses of the server through a first process running based on the OSPF protocol. The OSPF protocol is started on the switch. After the switch receives the multiple virtual IP addresses and physical IP addresses published by each server in the server group, multiple routes for each of the above multiple virtual IP addresses can be formed on the switch.
[0052] For example, suppose the virtual network ports are lo1, lo2, lo3, and lo4, and the virtual IP addresses configured on the four virtual network ports are 192.168.1.1, 192.168.1.2, 192.168.1.3, and 192.168.1.4, respectively. The server group contains four servers, and the physical IP addresses of the four servers are 192.168.1.11, 192.168.1.12, 192.168.1.13, and 192.168.1.14, respectively. The switch will generate forwarding entries for the virtual IP addresses 192.168.1.1, 192.168.1.2, 192.168.1.3, and 192.168.1.4, respectively, in the forwarding table, where the forwarding entry for the virtual IP address 192.168.1.1 can be as follows: 192.168.1.1 192.168.1.11 192.168.1.12 192.168.1.13 192.168.1.14 This means that the access request from the client with the destination IP of 192.168.1.1 can be forwarded to the server with the physical IP address of 192.168.1.11, 192.168.1.12, 192.168.1.13 or 192.168.1.14.
[0053] Similarly, the forwarding table entries for virtual IP addresses 192.168.1.2, 192.168.1.3, and 192.168.1.4 are also the same, and are not described again here.
[0054] In some embodiments, the server group includes multiple servers, and each server is configured with the same multiple virtual IP addresses.
[0055] After receiving an access request for the target virtual IP address from the client, the switch can perform a hash calculation based on the four-tuple information of the access request to obtain a hash value. The four-tuple information of the access request includes the destination IP (that is, the target virtual IP address), the destination port, the source IP, and the source port.
[0056] It should be noted that the target virtual IP address may be allocated to the client by a domain name server (DNS) from the above multiple virtual IP addresses according to a pre-configured allocation rule. Exemplarily, the above pre-configured allocation rule may be polling, random or other custom allocation rules.
[0057] The switch can determine the physical IP address of the target server from the forwarding table according to the target virtual IP address and the hash value. In some embodiments, the switch can perform a modulus operation on the obtained hash value to obtain a modulus value, and then determine the physical IP address of the target server from multiple routes in the forwarding table for the target virtual IP address according to the modulus value.
[0058] For example, assuming the target virtual IP address is "192.168.1.1", the multiple routes for the target virtual IP address "192.168.1.1" in the forwarding table can be as follows: 192.168.1.1 192.168.1.11 192.168.1.12 192.168.1.13 192.168.1.14 ... Each server's physical IP address is pre-associated with a specific modulo value. For example, server A's physical IP address "192.168.1.11" is associated with modulo value 0, server B's physical IP address "192.168.1.12" is associated with modulo value 1, server C's physical IP address "192.168.1.13" is associated with modulo value 2, server D's physical IP address "192.168.1.14" is associated with modulo value 3, and so on.
[0059] Assume that the calculated hash value is 55, and the hash value is modulo calculated using the formula "55%5", and the modulo value obtained is 0.
[0060] Since the obtained modulo value matches the modulo value associated with the physical IP address "192.168.1.11" of server A, it can be determined that the physical IP address of the target server is the physical IP address "192.168.1.11" of server A.
[0061] Finally, the access request of the client is forwarded to the target server according to the physical IP address of the target server.
[0062] In this embodiment, each server is configured with multiple virtual IP addresses, so when a client initiates an access request, the destination IP of the access request can have multiple choices according to the pre-set allocation rules. In this way, when the switch performs hash calculation based on the four-tuple information of the access request, it can obtain different hash values, thereby improving the load balancing effect and avoiding the hash value skew problem that may occur when each server is configured with only one virtual IP address.
[0063] S202: Monitor the processing pressure of the server in processing the access request.
[0064] In some embodiments, a second process for monitoring the processing pressure of the server may be pre-deployed in the server, and the server itself may use the second process to monitor the processing pressure of the server in processing access requests.
[0065] It should be noted that the embodiments of the present application do not specifically limit the method of "monitoring the processing pressure of the server in processing access requests". For example, the processing pressure of the server in processing access requests can also be monitored through log analysis, operating system commands, and other methods.
[0066] Exemplarily, the processing pressure may include CPU usage, memory usage, and / or I / O usage, etc.
[0067] S203: When the processing pressure exceeds a first set threshold, one or more virtual network ports among the multiple virtual network ports are set to a disabled state, and the first process is used to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table, wherein the second IP address information includes the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state.
[0068] When the processing pressure of the server in processing access requests exceeds a first set threshold, one or more virtual network ports among the multiple virtual network ports are set to a disabled state.
[0069] The server can use the first process to publish the IP address information of the server in real time or periodically. Since one or more of the multiple virtual network ports in the server are set to a disabled state, the IP address information of the server is changed to the second IP address information, and the second IP address information includes the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state.
[0070] After the switch receives the second IP address information published by the server, it updates the forwarding table in the switch according to the second IP address information. That is, the forwarding table entry corresponding to the virtual IP address configured on the virtual network port in the disabled state in the forwarding table is deleted. After that, the switch will forward the access request for each virtual IP address from the client to the server according to the updated forwarding table.
[0071] In some embodiments, when the processing pressure of the server for processing access requests is lower than a second set threshold, and the duration of the processing pressure being lower than the second set threshold meets a preset condition, one or more virtual network ports in a disabled state are set to a non-disabled state, and the second IP address information of the server is published using the first process, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table.
[0072] In this embodiment, when the processing pressure of the server in processing access requests drops to a certain threshold and lasts for a period of time, for example, the CPU utilization rate of the server drops to 60% and the time exceeds 30 seconds, the virtual network port that was previously set to a disabled state can be reset to a non-disabled state, thereby restoring the processing capacity of the server in processing access requests.
[0073] In some embodiments, the server is any server in a server group. For each virtual network port in the plurality of virtual network ports, at least one server in the server group cannot set the virtual network port to a disabled state.
[0074] In this embodiment, for each virtual network port among the multiple virtual network ports, at least one server in the server group cannot set the virtual network port to a disabled state. That is, for each virtual network port, at least one server processes the client's access request for the virtual IP address configured on the virtual network port, thereby preventing all servers in the server group from setting a certain virtual network port to a disabled state in an extreme case, causing the switch to be unable to forward the client's access request for the virtual IP address configured on the virtual network port, thereby causing the client request to fail.
[0075] In an embodiment of the present application, a server is configured with multiple virtual network ports and a first process running based on the OSPF protocol is deployed. Each virtual network port is configured with a virtual IP address. The physical IP address of the server and multiple virtual IP addresses are published by the first process so that the switch generates a forwarding table according to the received IP address information, and forwards the access request from the client to the server according to the forwarding table, monitors the processing pressure of the server in processing the access request, and sets one or more virtual network ports to a disabled state when the processing pressure exceeds a first set threshold. The physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state are published by the first process so that the switch updates the forwarding table according to the received IP address information, and forwards the access request from the client to the server according to the updated forwarding table, thereby eliminating the need to use an additional LVS. The server itself can actively perform pressure reduction adjustment when its own performance is insufficient, which not only realizes active load balancing of the server based on OSPF, but also improves the accuracy of load balancing and reduces deployment costs.
[0076] like Figure 3 As shown, Figure 3 It is a flow chart of a server load balancing method provided in an embodiment of the present application.
[0077] The server group includes multiple servers, and the server group is used to receive an access request from a client for any virtual IP address among multiple virtual IP addresses.
[0078] Each server is configured with the same number of virtual network ports, and each virtual network port is configured with a virtual IP address. Each server is configured with the same multiple virtual IP addresses, and a first process running based on the OSPF protocol is deployed. For each server in the server group, the server uses the first process to publish the first IP address information of the server, so that the switch generates a forwarding table according to the received first IP address information, and forwards the access request from the client to the server according to the forwarding table. The first IP address information includes multiple virtual IP addresses configured on the server and the physical IP address of the server. The forwarding table in the switch contains multiple routes for each of the multiple virtual IP addresses.
[0079] The server monitors the processing pressure of the server in processing access requests.
[0080] When the processing pressure of the server in processing access requests exceeds a first set threshold, the server sets one or more virtual network ports among the multiple virtual network ports to a disabled state, and uses the first process to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table.
[0081] For each virtual network port among the multiple virtual network ports, at least one server in the server group cannot set the virtual network port to a disabled state.
[0082] When the processing pressure of the access request processed by the server is lower than the second set threshold, and the duration of the processing pressure being lower than the second set threshold satisfies the preset conditions, the server sets one or more virtual network ports in the disabled state to the non-disabled state (i.e., the enabled state), and uses the first process to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table.
[0083] In an embodiment of the present application, a first process based on the OSPF protocol deployed in the server is used to negotiate with the switch to establish load balancing, and the server can autonomously disable and enable the virtual IP address according to its own pressure, thereby reducing and restoring its own request volume. This can not only achieve active load balancing of the server based on OSPF, but also improve the accuracy of load balancing.
[0084] The above content describes the method provided by the present application. The following describes the device provided by the present application: See also Figure 4 , which is a structural diagram of a server load balancing device provided in an embodiment of the present application, wherein the server is configured with multiple virtual network ports and a first process running based on the Open Shortest Path First (OSPF) protocol is deployed, wherein each virtual network port is configured with a virtual IP address.
[0085] like Figure 4 As shown, the device may include: The processing unit 410 is configured to publish the first IP address information of the server by using the first process, so that the switch generates a forwarding table according to the received first IP address information, and forwards the access request from the client to the server according to the forwarding table, wherein the first IP address information includes the physical IP address of the server and multiple virtual IP addresses; A monitoring unit 420, configured to monitor a processing pressure of the server in processing the access request; The load balancing unit 430 is used to set one or more virtual network ports among the multiple virtual network ports to a disabled state when the processing pressure exceeds a first set threshold, and use the first process to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table, wherein the second IP address information includes the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state.
[0086] In some embodiments, the server is any server in a server group, and the server group is used to receive an access request from a client for any virtual IP address among the multiple virtual IP addresses.
[0087] In some embodiments, for each virtual network port in the plurality of virtual network ports, at least one server in the server group is unable to set the virtual network port to a disabled state.
[0088] In some embodiments, the switch is specifically used to: After receiving an access request for a target virtual IP address from a client, the switch performs a hash calculation according to the destination IP, destination port, source IP and source port of the access request to obtain a hash value, wherein the target virtual IP address is allocated to the client from the multiple virtual IP addresses by a domain name server DNS according to a pre-configured allocation rule; Determine the physical IP address of the target server from the forwarding table according to the target virtual IP address and the hash value; The access request is forwarded to the target server according to the physical IP address of the target server.
[0089] In some embodiments, the switch is specifically used to: The switch uses the OSPF protocol to generate a forwarding table according to the received physical IP address of the server and the multiple virtual IP addresses, wherein each entry in the forwarding table contains a mapping relationship between a virtual IP address and the physical IP address of the server.
[0090] In some embodiments, the load balancing unit 430 is further configured to: When the processing pressure is lower than a second set threshold value, and the duration for which the processing pressure is lower than the second set threshold value satisfies a preset condition, one or more virtual network ports in a disabled state are set to a non-disabled state, and the second IP address information of the server is published using the first process, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table.
[0091] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0092] The present application embodiment also provides a hardware structure. Figure 5 , Figure 5 This is a structural diagram of an electronic device provided in an embodiment of the present application. Figure 5 As shown, the hardware structure may include: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application.
[0093] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.
[0094] Exemplarily, the above-mentioned machine-readable storage medium may be any electronic, magnetic, optical or other physical storage device, which may contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium may be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.
[0095] It should be noted that, in this article, relational terms such as target and target are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0096] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A server load balancing method, characterized in that: The server is configured with multiple virtual network ports and a first process running based on the Open Shortest Path First (OSPF) protocol is deployed, wherein each virtual network port is configured with a virtual IP address. The method includes: Using the first process to publish the first IP address information of the server, so that the switch generates a forwarding table according to the received first IP address information, and forwards the access request from the client to the server according to the forwarding table, wherein the first IP address information includes the physical IP address of the server and multiple virtual IP addresses; monitoring the processing pressure of the server in processing the access request; When the processing pressure exceeds a first set threshold, one or more of the multiple virtual network ports are set to a disabled state, and the first process is used to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table, wherein the second IP address information includes the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state.
2. The method according to claim 1, characterized in that The server is any server in a server group, and the server group is used to receive an access request from a client for any virtual IP address among the multiple virtual IP addresses.
3. The method according to claim 2, characterized in that For each virtual network port among the multiple virtual network ports, at least one server in the server group cannot set the virtual network port to a disabled state.
4. The method according to claim 2, characterized in that: The forwarding the access request from the client to the server according to the forwarding table includes: After receiving an access request for a target virtual IP address from a client, the switch performs a hash calculation according to the destination IP, destination port, source IP and source port of the access request to obtain a hash value, wherein the target virtual IP address is allocated to the client from the multiple virtual IP addresses by a domain name server DNS according to a pre-configured allocation rule; Determine the physical IP address of the target server from the forwarding table according to the target virtual IP address and the hash value; The access request is forwarded to the target server according to the physical IP address of the target server.
5. The method according to claim 1, characterized in that Generating a forwarding table according to the received first IP address information includes: The switch uses the OSPF protocol to generate a forwarding table according to the received physical IP address of the server and the multiple virtual IP addresses, wherein each entry in the forwarding table contains a mapping relationship between a virtual IP address and the physical IP address of the server.
6. The method according to claim 1, characterized in that The method further comprises: When the processing pressure is lower than a second set threshold value, and the duration for which the processing pressure is lower than the second set threshold value satisfies a preset condition, one or more virtual network ports in a disabled state are set to a non-disabled state, and the second IP address information of the server is published using the first process, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table.
7. A server load balancing device, characterized in that: The server is configured with multiple virtual network ports and a first process running based on the Open Shortest Path First (OSPF) protocol is deployed, wherein each virtual network port is configured with a virtual IP address. The device includes: a processing unit, configured to publish the first IP address information of the server by using the first process, so that the switch generates a forwarding table according to the received first IP address information, and forwards the access request from the client to the server according to the forwarding table, wherein the first IP address information includes a physical IP address of the server and a plurality of virtual IP addresses; A monitoring unit, used for monitoring the processing pressure of the server in processing the access request; A load balancing unit, configured to set one or more of the multiple virtual network ports to a disabled state when the processing pressure exceeds a first set threshold, and to use the first process to publish the second IP address information of the server, so that the switch updates the forwarding table according to the received second IP address information, and forwards the access request from the client to the server according to the updated forwarding table, wherein the second IP address information includes the physical IP address of the server and the virtual IP address configured on the virtual network port in a non-disabled state.
8. The device according to claim 7, characterized in that The server is any server in a server group, and the server group is used to receive an access request from a client for any virtual IP address among the multiple virtual IP addresses.
9. The device according to claim 8, characterized in that For each virtual network port among the multiple virtual network ports, at least one server in the server group cannot set the virtual network port to a disabled state.
10. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor is used to execute the machine executable instructions to implement the method according to any one of claims 1 to 6.
11. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Open shortest path first (OSPF) over-network balanced forwarding method and OSPF over-network balanced forwarding system
CN105515979A
Network access method and device, computer readable medium and electronic equipment
CN113489691A
Load balancing method and platform, electronic equipment and computer readable storage medium
CN116155903A
Load balancing method, apparatus and system, system creation method, and device and medium
WO2024113895A1
