Server traffic regulation method and device, computer equipment and storage medium
By detecting the server status and adjusting traffic through load balancing equipment, the service interruption problem caused by server traffic regulation in traditional technology is solved, smooth traffic switching is achieved, service reliability and availability are improved, and it is suitable for scenarios with high reliability requirements.
Patent Information
- Application Number
- CN202411168858.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-01-03
AI Technical Summary
During the server traffic regulation process, traditional technology needs to interrupt services, resulting in short-term or long-term unavailability of services, affecting user experience and business operations, especially in scenarios such as e-commerce platforms and financial services. .
The load balancing device detects the server status, determines the target downtime server and the running server, and adjusts the traffic parameters of the target downtime server according to the preset rules, reduces its traffic to the preset level, and allocates the reduced traffic to the running server to achieve traffic smooth switching to avoid service interruption.
Improve service reliability and availability during server traffic regulation, ensure that application services do not affect normal operation when traffic fluctuates or downtime, avoid service interruptions, and improve user experience and business continuity.
Smart Images

Figure CN119254778A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of server technology, and in particular to a server traffic regulation method, device, computer equipment and storage medium. Background Art
[0002] In modern distributed systems, the release and restart of applications deployed on servers and other server traffic regulation processes are common operations. However, in these processes, how to ensure that HTTP requests are not interrupted is a key issue. For example, online services such as e-commerce platforms, social media, and online games need to run uninterruptedly, and any short service interruption will affect user experience and business revenue; the normal operation of enterprise-level applications such as ERP (Enterprise Resource Planning) and CRM (Customer Relationship Management) is crucial to the daily operations of the company, and any interruption may affect business processes and efficiency; financial services such as online banking and payment gateways require high reliability and high availability, and any interruption may lead to transaction failures and a decrease in user trust.
[0003] However, in traditional technologies, server traffic regulation usually requires service interruption, resulting in long-term or short-term service unavailability, affecting user experience and even causing business interruption. Therefore, there is an urgent need in traditional technologies for a method that can improve service reliability and availability during server traffic regulation. Summary of the invention
[0004] Based on this, it is necessary to provide a server traffic regulation method, device, computer equipment and storage medium that can improve service reliability and availability in response to the above technical problems.
[0005] In a first aspect, the present application provides a server traffic regulation method, which is applied to a load balancing device. The method comprises:
[0006] Detecting the status of each server in a server group, wherein the server group includes a plurality of servers, and the plurality of servers are respectively connected to the load balancing device;
[0007] Determine, according to the status of the server, a target downtime server and a running server in the server group, wherein the server group includes at least one running server;
[0008] The traffic parameters of the target shutdown server are adjusted according to a first preset rule until the traffic of the target shutdown server is reduced to a first preset traffic, and the reduced traffic of the target shutdown server is distributed to the at least one running server.
[0009] In one embodiment, each server is configured with a status detection interface, and detecting the status of each server in the server group includes:
[0010] According to the interface address information, the status return information of each status detection interface is read accordingly;
[0011] If the status return information is health information, determining that the status of the server is a running status;
[0012] If the status return information is unhealthy information, it is determined that the status of the server is a waiting shutdown status.
[0013] In one embodiment, determining the target shutdown server and the running server in the server group according to the status of the server includes:
[0014] If the state of the server is a running state, determining that the server is a running server;
[0015] If the state of the server is a waiting-to-shutdown state, the server is determined to be a target shutdown server.
[0016] In one embodiment, the reading of the status return information of each status detection interface includes:
[0017] Send request information to each status detection interface according to a preset interval;
[0018] The status return information is read, where the status return information is generated by each server according to the request information.
[0019] In one embodiment, adjusting the traffic parameter of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic includes:
[0020] Adjusting the flow parameter of the target downtime server to a first flow ratio;
[0021] Detecting the state of the target shutdown server, if the state of the target shutdown server includes a waiting shutdown state, adjusting the flow parameter of the target shutdown server to a second flow ratio, wherein the second flow ratio is smaller than the first flow ratio;
[0022] Detect the state of the target shutdown server. If the state of the target shutdown server includes a waiting shutdown state, adjust the flow parameter of the target shutdown server to a third flow ratio so that the flow of the target shutdown server is reduced to the first preset flow, and the third flow ratio is less than the second flow ratio.
[0023] In one of the embodiments, after adjusting the traffic parameter of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, the method further includes:
[0024] Detecting the status of the target downtime server;
[0025] If the state of the target shutdown server includes a running state, the flow parameter of the target shutdown server is adjusted according to a second preset rule until the flow of the target shutdown server increases to a second preset flow.
[0026] In one embodiment, adjusting the traffic parameter of the target shutdown server according to the second preset rule until the traffic of the target shutdown server increases to the second preset traffic includes:
[0027] Adjusting the flow parameter of the target downtime server to a fourth flow ratio;
[0028] Detecting the state of the target shutdown server, and if the state of the target shutdown server includes a running state, adjusting the flow parameter of the target shutdown server to a fifth flow ratio, wherein the fifth flow ratio is greater than the fourth flow ratio;
[0029] Detect the status of the target shutdown server. If the status of the target shutdown server includes an operating status, adjust the flow parameters of the target shutdown server to a sixth flow ratio so that the flow of the target shutdown server increases to the second preset flow, and the sixth flow ratio is greater than the fifth flow ratio.
[0030] In a second aspect, the present application also provides a server traffic regulation device. The device comprises:
[0031] A status detection module, used to detect the status of each server in a server group, wherein the server group includes a plurality of servers, and the plurality of servers are respectively connected to a load balancing device;
[0032] A server determination module, configured to determine a target downtime server and a running server in the server group according to the status of the server, wherein the server group includes at least one running server;
[0033] The traffic regulating module is used to adjust the traffic parameters of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, and distribute the reduced traffic of the target shutdown server to the at least one running server.
[0034] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of any of the server traffic regulation methods in the first aspect are implemented.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the server traffic regulation methods described in the first aspect are implemented.
[0036] The above-mentioned server traffic adjustment method, device, computer equipment and storage medium detect the status of each server in the server group, the server group includes multiple servers, and the multiple servers are respectively connected to the load balancing device; according to the status of the server, determine the target shutdown server and the running server in the server group, the server group includes at least one running server; adjust the traffic parameters of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, and distribute the reduced traffic of the target shutdown server to the at least one running server. The present application determines the status of multiple servers through a load balancing device. If there is a target shutdown server in the server, the traffic of the target shutdown server is adjusted according to the first preset rule, so that the traffic of the target shutdown server is reduced to the first preset traffic. Since the server group includes at least one running server, the reduced traffic is automatically distributed to at least one running server. Therefore, the present application can realize the smooth switching of the traffic on the target shutdown server, so that the target shutdown server does not affect the normal operation of the application service when the traffic fluctuates or shuts down, avoids the interruption of the service, and effectively improves the service reliability and availability.
[0037] The details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0039] Figure 1 A diagram of an application environment of a server traffic regulation method in an embodiment;
[0040] Figure 2 A schematic diagram of a flow chart of a method for adjusting server traffic in one embodiment;
[0041] Figure 3 A schematic diagram of a flow chart of adjusting flow parameters of a target downtime server in a specific embodiment;
[0042] Figure 4 is a structural block diagram of a server traffic regulating device in an embodiment;
[0043] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0045] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0046] The terms "module", "unit", etc. used below are a combination of software and / or hardware that can implement a predetermined function. Although the devices described in the following embodiments are preferably implemented in hardware, the implementation of software, or a combination of software and hardware is also possible and conceivable.
[0047] The server traffic regulation method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. The server group 102 includes a plurality of servers, and the plurality of servers are respectively connected to the load balancing device 108. The load balancing device 108 detects the status of each server in the server group 102, and determines the target shutdown server 104 and the running server 106 in the server group 102 according to the status of the server, and the server group includes at least one running server 106. The load balancing device 108 adjusts the traffic parameters of the target shutdown server 104 according to the first preset rule until the traffic of the target shutdown server 104 is reduced to the first preset traffic, and the first preset traffic is distributed to the at least one running server 106. The server group 102 is connected to the terminal 110 through a network to provide application services to the terminal 110.
[0048] In one embodiment, Figure 2 As shown, a server traffic regulation method is provided, the method is applied to a load balancing device, and the method is applied to Figure 1 The application scenario in is taken as an example to illustrate, including the following steps:
[0049] S201: Detecting the status of each server in a server group, where the server group includes a plurality of servers, and the plurality of servers are respectively connected to the load balancing device.
[0050] In the embodiment of the present application, the load balancing device is used to adjust the traffic between multiple servers in the server group, and to detect the status of each server in the server group. The load balancing device may include a device composed of a load balancer and a server detection module, and may also include a load balancer with a server status detection function. In some specific embodiments, the load balancer may include F5 BIG-IP, A10Networks, etc.
[0051] In the embodiment of the present application, the server group may include a server cluster composed of multiple servers. The multiple servers in the server group can interact with other systems or terminals as a whole, and the multiple servers are respectively connected to the load balancer.
[0052] In some embodiments, each server is configured with a status detection interface, and detecting the status of each server in the server group includes:
[0053] S301: Read the status return information of each status detection interface accordingly according to the interface address information.
[0054] S303: If the status return information is health information, determine that the status of the server is a running status.
[0055] S305: If the status return information is unhealthy information, determine that the status of the server is a waiting shutdown status.
[0056] In an embodiment of the present application, a status detection interface is configured on each server, and the status detection interface may include a health check interface. The status detection interface can be used to monitor the running status of the server. According to the interface address information of the status detection interface, the status return information of each status detection interface is read accordingly. The status return information may include health information or unhealthy information. If the status return information is health information, it is determined that the status of the server is a running status. If the status return information is unhealthy information, it is determined that the status of the server is a waiting shutdown status.
[0057] In some specific embodiments, the interface address information may be ` / healthcheck`, and the status return information may include health information "OK" indicating that the server is running normally, or unhealthy information "FAIL" indicating that the server is in an abnormal state. For example, the logic that the status detection interface may implement is that, when the server is running by default, the status return information of the status detection interface may be "OK", and when a server receives a shutdown instruction, the status return information of the status detection interface may be "FAIL".
[0058] In some specific embodiments, the Python pseudo code for implementing server status detection may include:
[0059]
[0060] In some embodiments, the status return information of each status detection interface can be read regularly by setting a preset interval time. The reading of the status return information of each status detection interface includes:
[0061] S401: Sending request information to each status detection interface according to a preset interval time.
[0062] S403: Read status return information, where the status return information is generated by each server according to the request information.
[0063] In an embodiment of the present application, a request message may be sent to each status detection interface at a preset interval, and status return information may be read, and the status return information may be generated by each server according to the request message. The request message may include status detection information sent by the load balancer to each server. Specifically, the preset interval may include 10 seconds. Based on the status return information, the load balancing device may dynamically adjust the traffic distribution of the server group.
[0064] In some specific embodiments, the YAML pseudo code for periodically reading the status return information of each status detection interface may include:
[0065] health_check:
[0066] interval: 10s
[0067] path: / healthcheck
[0068] timeout: 2s.
[0069] By setting a preset interval time, the server operation status can be detected in time, so that the server traffic can be adjusted in time when the server status is abnormal or about to be shut down, which can effectively improve the reliability and availability of application services.
[0070] S203: Determine a target shutdown server and a running server in the server group according to the state of the server, wherein the server group includes at least one running server.
[0071] In the embodiment of the present application, according to the status of the server, multiple servers in the server group can be divided into target shutdown servers and running servers, so as to facilitate the subsequent adjustment of the traffic between the servers. It can be understood that in order to ensure the reliability and availability of the application server during the traffic adjustment process, at least one running server should be ensured in the server group.
[0072] In some embodiments, determining the target shutdown server and the running server in the server group according to the status of the server includes:
[0073] S501: If the state of the server is a running state, determine that the server is a running server.
[0074] S503: If the state of the server is a waiting-to-shutdown state, determine that the server is a target shutdown server.
[0075] In the embodiment of the present application, if the state of the server is the running state, it means that the server is running normally without any abnormality or is not ready to shut down, and the server is determined to be a running server. If the state of the server is the waiting to shut down state, it means that the server may have an abnormal operation, traffic fluctuations, or is ready to shut down, and the server is determined to be a target shutdown server.
[0076] S205: Adjust the traffic parameters of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, and distribute the reduced traffic of the target shutdown server to the at least one running server.
[0077] In an embodiment of the present application, the first preset rule may include a preset rule for adjusting the server traffic in the server group. The traffic parameter of the target shutdown server can be adjusted according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic. In some specific embodiments, the traffic parameter may include at least one of the number of requests, bandwidth usage, number of connections, and load weight. Among them, the number of requests includes the number of HTTP requests or TCP connections delivered to the server per second, the bandwidth usage includes the amount of data processed by the server per second (e.g., Mbps), the number of connections includes the number of connections or sessions currently processed by the server, and the load weight includes the relative weight of the server, which is used to determine the distribution ratio in the load balancing of the server group.
[0078] Adjusting the traffic parameters of the target shutdown server according to the first preset rule may include gradually adjusting the traffic parameters of the target shutdown server so that the traffic of the target shutdown server is reduced to the first preset traffic. In some specific embodiments, the gradual adjustment may include adjusting the maximum operating traffic ratio of the target shutdown server multiple times, for example, it may be adjusted twice, each time the maximum operating traffic ratio of the target shutdown server is adjusted to 50%, 0%; it may also be adjusted four times, each time the maximum operating traffic ratio of the target shutdown server is adjusted to 80%, 50%, 30%, 10%, etc. The first preset traffic may be a preset value, for example, it may be set to 0 to make the target shutdown server exit operation.
[0079] In an embodiment of the present application, the traffic reduced by the target downtime server is distributed to at least one running server in the server group. Specifically, a running server that is not fully loaded in at least one running server can be determined, and the traffic can be evenly distributed to the running servers that are not fully loaded, or it can be preferentially distributed to the running servers with less current traffic, or it can be distributed according to the weights of different running servers. The present application does not specifically limit the specific way of distributing traffic to the running servers.
[0080] In some embodiments, Figure 3 As shown, adjusting the flow parameter of the target shutdown server according to the first preset rule until the flow of the target shutdown server is reduced to the first preset flow includes:
[0081] S601: Adjust the flow parameter of the target downtime server to a first flow ratio.
[0082] S603: Detect the state of the target shutdown server. If the state of the target shutdown server includes a waiting shutdown state, adjust the flow parameter of the target shutdown server to a second flow ratio, where the second flow ratio is smaller than the first flow ratio.
[0083] S605: Detect the state of the target shutdown server. If the state of the target shutdown server includes a waiting shutdown state, adjust the flow parameter of the target shutdown server to a third flow ratio so that the flow of the target shutdown server is reduced to the first preset flow, and the third flow ratio is smaller than the second flow ratio.
[0084] In an embodiment of the present application, the flow parameters of the target shutdown server are adjusted according to the first preset rule. The flow parameters of the target shutdown server can be adjusted to the first flow ratio first. The first flow ratio can be understood as the maximum flow allowed to pass through the target shutdown server is the product of the first flow ratio and the full load flow. In other embodiments, the first flow ratio can also be understood as the maximum flow allowed to pass through the target shutdown server is the product of the current flow of a certain running server and the first flow ratio. Specifically, the first flow ratio can include a ratio value, such as 80%; it can also include a ratio range, such as 75%-85%. The second flow ratio to the sixth flow ratio in the subsequent embodiments can all refer to the description of the first flow ratio and will not be repeated.
[0085] After adjusting the traffic parameters of the target shutdown server to the first traffic ratio, the state of the target shutdown server is detected again. If the state of the target shutdown server includes a waiting state, it means that the target shutdown server still needs to continue to adjust the traffic, and the traffic parameters of the target shutdown server are adjusted to the second traffic ratio; if the state of the target shutdown server includes a waiting state, it means that the target shutdown server may have traffic fluctuations, a short-term abnormality in the state detection port, or the server shutdown plan has been revoked during the previous state detection, and the traffic parameters of the target shutdown server can be adjusted to the default state. The second traffic ratio is smaller than the first traffic ratio. Specifically, the second traffic ratio can include a ratio value, such as 50%; it can also include a ratio range, such as 45%-55%.
[0086] After adjusting the flow parameters of the target shutdown server to the second flow ratio, the state of the target shutdown server is detected. If the state of the target shutdown server includes a waiting state, it means that the target shutdown server still needs to continue to adjust the flow, and the flow parameters of the target shutdown server are adjusted to a third flow ratio to reduce the flow of the target shutdown server to the first preset flow; if the state of the target shutdown server includes a waiting state, it means that the target shutdown server may have flow fluctuations, a short-term abnormality in the state detection port, or the server shutdown plan has been revoked during the previous state detection, and the flow parameters of the target shutdown server can be adjusted to the first flow ratio or the default state. The third flow ratio is less than the second flow ratio. Specifically, the third flow ratio can include a ratio value, such as 0; it can also include a ratio range, such as 0%-5%.
[0087] In some specific embodiments, before the server deployed by the application service needs to be shut down, the status return information of the status detection interface of the target shut down server can be adjusted to "FAIL" through instructions. The load balancing device or API gateway gradually reduces the traffic of the target shut down server according to the status return information until the traffic is 0. After the application service is distributed and the server is restarted successfully, the status return information is adjusted to "OK", and the load balancing device or API gateway gradually restores the traffic of the target shut down server. In the process of smooth traffic switching: if the first health check fails, the traffic ratio of the target shut down server will be reduced to 80% of a running server; if the second health check fails, the traffic ratio of the target shut down server will be reduced to 50%; if the third health check fails: the traffic ratio of the target shut down server will be reduced to 0%.
[0088] In some specific embodiments, the operation and maintenance script can be used to realize the automatic management of the server status return information during the application release or restart process. The operation and maintenance script is responsible for sending the shutdown command, executing the application release and restart operations, and restoring the status return information of the status detection interface. Specifically, the operation and maintenance script may include the following functions: sending a shutdown command, adjusting the status return information of the target shutdown server to "FAIL"; executing the application release and restart operations; restoring the status return information to "OK". The pseudo code of the operation and maintenance script may include:
[0089] #! / bin / bash
[0090] #Send shutdown command
[0091] curl-X POST http: / / server / healthcheck / fail
[0092] #Execute application release and restart operations
[0093] deploy_application
[0094] restart_application
[0095] #Restore the status of the status detection interface
[0096] curl -X POST http: / / server / healthcheck / ok.
[0097] In the embodiment of the present application, the above-mentioned server traffic adjustment method detects the state of each server in the server group, the server group includes multiple servers, and the multiple servers are respectively connected to the load balancing device; according to the state of the server, the target shutdown server and the running server in the server group are determined, and the server group includes at least one running server; the traffic parameters of the target shutdown server are adjusted according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, and the reduced traffic of the target shutdown server is distributed to the at least one running server. The present application determines the state of multiple servers through the load balancing device. If there is a target shutdown server in the server, the traffic of the target shutdown server is adjusted according to the first preset rule, so that the traffic of the target shutdown server is reduced to the first preset traffic, and since the server group includes at least one running server, the reduced traffic is automatically distributed to at least one running server. Therefore, the present application can realize the smooth switching of the traffic on the target shutdown server, so that the target shutdown server does not affect the normal operation of the application service when the traffic fluctuates or shuts down, avoids the interruption of the service, and effectively improves the service reliability and availability.
[0098] In an embodiment of the present application, an implementation method of restoring the traffic of a target downtime server is also provided. In some embodiments, after the traffic parameter of the target downtime server is adjusted according to the first preset rule until the traffic of the target downtime server is reduced to the first preset traffic, it also includes:
[0099] S701: Detect the status of the target downtime server.
[0100] S703: If the state of the target shutdown server includes a running state, adjusting the flow parameter of the target shutdown server according to a second preset rule until the flow of the target shutdown server increases to a second preset flow.
[0101] In the embodiment of the present application, after the traffic of the target shutdown server is reduced to the first preset traffic, the state of the target shutdown server is detected. If the state of the target shutdown server includes the running state, it means that the application service deployed on the target shutdown server has been released for restart, and the traffic parameters of the target shutdown server are adjusted according to the second preset rule until the traffic of the target shutdown server increases to the second preset traffic.
[0102] In the embodiment of the present application, adjusting the flow parameters of the target shutdown server according to the second preset rule may include gradually adjusting the flow parameters of the target shutdown server so that the flow of the target shutdown server increases to the second preset flow. In some specific embodiments, the gradual adjustment may include adjusting the maximum operating flow ratio of the target shutdown server multiple times, for example, it may be adjusted twice, each time the maximum operating flow ratio of the target shutdown server is adjusted to 50%, 100%; it may also be adjusted four times, each time the maximum operating flow ratio of the target shutdown server is adjusted to 10%, 30%, 50%, 80%, etc. The second preset flow may be a preset value, for example, it may be set to the allowed flow under the default operating state of the target shutdown server.
[0103] In an embodiment of the present application, the increased traffic of the target downtime server is migrated from at least one running server in the server group to the target downtime server. Specifically, the traffic on at least one running server can be evenly migrated to the target downtime server until the traffic of the target downtime server increases to a second preset traffic; the traffic on the fully loaded server in at least one running server can also be preferentially migrated, and the traffic can also be migrated according to the weights of different running servers. The present application does not specifically limit the specific method of migrating the traffic to the target downtime server.
[0104] In some embodiments, adjusting the traffic parameter of the target shutdown server according to the second preset rule until the traffic of the target shutdown server increases to the second preset traffic includes:
[0105] S801: Adjust the flow parameter of the target downtime server to a fourth flow ratio.
[0106] S803: Detect the state of the target shutdown server. If the state of the target shutdown server includes a running state, adjust the flow parameter of the target shutdown server to a fifth flow ratio, where the fifth flow ratio is greater than the fourth flow ratio.
[0107] S805: Detect the status of the target shutdown server. If the status of the target shutdown server includes an operating status, adjust the flow parameters of the target shutdown server to a sixth flow ratio so that the flow of the target shutdown server increases to the second preset flow, and the sixth flow ratio is greater than the fifth flow ratio.
[0108] In the embodiment of the present application, the flow parameter of the target downtime server is adjusted according to the second preset rule, and the flow parameter of the target downtime server can be adjusted to the fourth flow ratio. Specifically, the fourth flow ratio can include a ratio value, such as 10%; or a ratio range, such as 5%-15%.
[0109] After adjusting the traffic parameters of the target downtime server to the fourth traffic ratio, the state of the target downtime server is detected again. If the state of the target downtime server includes the running state, it means that the traffic of the target downtime server needs to be restored, and the traffic parameters of the target downtime server are adjusted to the fifth traffic ratio; if the state of the target downtime server includes the waiting downtime state, it means that the application service may need to be restarted again, and the traffic of the target downtime server can be adjusted to the first preset traffic again. The fifth traffic ratio is greater than the fourth traffic ratio. Specifically, the fifth traffic ratio can include a ratio value, such as 50%; it can also include a ratio range, such as 45%-55%.
[0110] After adjusting the traffic parameter of the target downtime server to the fifth traffic ratio, the state of the target downtime server is detected. If the state of the target downtime server includes the running state, it means that the traffic of the target downtime server needs to be restored, and the traffic parameter of the target downtime server is adjusted to the sixth traffic ratio to increase the traffic of the target downtime server to the second preset traffic. If the state of the target downtime server includes the waiting downtime state, it means that the application service may need to be restarted again, and the traffic parameter of the target downtime server can be adjusted to the fourth traffic ratio. The sixth traffic ratio is greater than the fifth traffic ratio. Specifically, the sixth traffic ratio can include a ratio value, such as 100%; it can also include a ratio range, such as 90%-100%.
[0111] In some specific embodiments, if the application publishing and restart operations are completed on the target downtime server, the traffic of the target downtime server can be restored. The process of restoring the traffic may include: if the first health check is successful, the traffic ratio of the target downtime server is restored to 10%; if the second health check is successful, the traffic ratio of the target downtime server is restored to 50%; if the third health check is successful, the traffic ratio of the target downtime server is restored to 100%.
[0112] In some specific embodiments, the Python pseudo code of the target downtime server traffic reduction and recovery process may include:
[0113]
[0114]
[0115] The following takes the server traffic adjustment in an e-commerce website as an example to illustrate the server traffic adjustment method provided by this application. The backend service of the e-commerce website is deployed on a server group consisting of multiple servers, and HTTP requests are distributed to these servers through a load balancer. Now it is necessary to update and restart the application on one of the servers, but do not want to affect the user's access experience:
[0116] 1. Configure the health check interface: Configure a health check interface on each server. The interface address is / healthcheck. The default status return information of the health check interface is "OK". The Python pseudo code is:
[0117]
[0118]
[0119] 2. Configure the load balancer: Configure the scheduled request health check interface in the load balancer, requesting once every 10 seconds. The YAML pseudo code is:
[0120]
[0121]
[0122] 3. Server traffic regulation: Before updating and restarting the service application, modify the status information returned by the health check interface of the target downtime server to "FAIL" through the operation and maintenance script. The pseudo code is:
[0123]
[0124] 4. Traffic adjustment method of load balancer: The load balancer periodically requests the health check interface and gradually adjusts the traffic according to the health check results. The Python pseudo code is:
[0125]
[0126]
[0127] In the embodiment of the present application, the server traffic regulation is used to achieve smooth switching of HTTP traffic during application update and restart, ensuring uninterrupted user access. On the one hand, the present application achieves smooth traffic switching, and the load balancer gradually reduces and restores traffic through multiple health check results, avoiding service interruptions caused by instantaneous traffic switching; secondly, the present application achieves automated operation and maintenance, and realizes automated management of application update and restart processes through operation and maintenance scripts, reducing the complexity and error risks of manual operations, making the application release and restart process smoother and more controllable; furthermore, HTTP requests are continuously processed, the availability of application services is improved, and the reliability of the system is significantly improved.
[0128] In some specific embodiments, a system for implementing the above-mentioned server traffic regulation method is provided, the system comprising a server group, a load balancer or API gateway, a control module, and an operation and maintenance script module, wherein the server group comprises multiple servers, each server having an application and a status detection interface deployed thereon; the control module is used to send shutdown instructions and monitor the server status; the operation and maintenance script module is used to automatically control the release and restart process of the application; the load balancer or API gateway is used to implement the steps of the server traffic regulation method described in any of the above-mentioned embodiments.
[0129] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0130] Based on the same inventive concept, the embodiment of the present application also provides a server traffic regulating device 900 for implementing the server traffic regulating method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more server traffic regulating device 900 embodiments provided below can refer to the limitations of the server traffic regulating method above, and will not be repeated here.
[0131] In one embodiment, Figure 4 As shown, a server traffic regulating device 900 is provided, comprising:
[0132] A status detection module 901 is used to detect the status of each server in a server group, wherein the server group includes a plurality of servers, and the plurality of servers are respectively connected to a load balancing device;
[0133] A server determination module 902, configured to determine a target downtime server and a running server in the server group according to the status of the server, wherein the server group includes at least one running server;
[0134] The traffic regulating module 903 is used to adjust the traffic parameters of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, and distribute the reduced traffic of the target shutdown server to the at least one running server.
[0135] In one of the embodiments, a status detection interface is configured on each server, and the status detection module 901 is also used to read the status return information of each status detection interface accordingly according to the interface address information; if the status return information is healthy information, the status of the server is determined to be a running status; if the status return information is unhealthy information, the status of the server is determined to be a waiting shutdown status.
[0136] In one embodiment, the status detection module 901 is further used to determine that the server is a running server if the status of the server is a running status; and to determine that the server is a target shutdown server if the status of the server is a waiting shutdown status.
[0137] In one embodiment, the status detection module 901 is further used to send request information to each status detection interface according to a preset interval time; read status return information, and the status return information is generated by each server according to the request information.
[0138] In one embodiment, the traffic regulation module 903 is also used to adjust the traffic parameters of the target shutdown server to a first traffic ratio; detect the state of the target shutdown server, if the state of the target shutdown server includes a waiting shutdown state, adjust the traffic parameters of the target shutdown server to a second traffic ratio, the second traffic ratio is smaller than the first traffic ratio; detect the state of the target shutdown server, if the state of the target shutdown server includes a waiting shutdown state, adjust the traffic parameters of the target shutdown server to a third traffic ratio, so that the traffic of the target shutdown server is reduced to the first preset traffic, the third traffic ratio is smaller than the second traffic ratio.
[0139] In one embodiment, the traffic regulation module 903 is also used to detect the status of the target shutdown server; if the status of the target shutdown server includes an operating status, the traffic parameters of the target shutdown server are adjusted according to a second preset rule until the traffic of the target shutdown server increases to a second preset traffic.
[0140] In one embodiment, the traffic regulation module 903 is also used to adjust the traffic parameters of the target shutdown server to a fourth traffic ratio; detect the state of the target shutdown server, if the state of the target shutdown server includes an operating state, adjust the traffic parameters of the target shutdown server to a fifth traffic ratio, and the fifth traffic ratio is greater than the fourth traffic ratio; detect the state of the target shutdown server, if the state of the target shutdown server includes an operating state, adjust the traffic parameters of the target shutdown server to a sixth traffic ratio, so that the traffic of the target shutdown server is increased to the second preset traffic, and the sixth traffic ratio is greater than the fifth traffic ratio.
[0141] Each module in the server traffic regulation device 900 can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0142] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a server traffic regulation method is implemented.
[0143] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0144] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the server traffic regulation method described in any of the above embodiments are implemented.
[0145] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the server traffic regulation method described in any of the above embodiments are implemented.
[0146] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the steps of the server traffic regulation method described in any of the above embodiments.
[0147] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0148] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0149] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0150] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A server traffic regulation method, characterized in that: The method is applied to a load balancing device, and the method comprises: Detecting the status of each server in a server group, wherein the server group includes a plurality of servers, and the plurality of servers are respectively connected to the load balancing device; Determine, according to the status of the server, a target downtime server and a running server in the server group, wherein the server group includes at least one running server; The traffic parameters of the target shutdown server are adjusted according to a first preset rule until the traffic of the target shutdown server is reduced to a first preset traffic, and the reduced traffic of the target shutdown server is distributed to the at least one running server.
2. The method according to claim 1, characterized in that Each server is configured with a status detection interface, and the status of each server in the server group is detected including: According to the interface address information, the status return information of each status detection interface is read accordingly; If the status return information is health information, determining that the status of the server is a running status; If the status return information is unhealthy information, it is determined that the status of the server is a waiting shutdown status.
3. The method according to claim 2, characterized in that Determining the target shutdown server and the running server in the server group according to the status of the server includes: If the state of the server is a running state, determining that the server is a running server; If the state of the server is a waiting-to-shutdown state, the server is determined to be a target shutdown server.
4. The method according to claim 2, characterized in that: The reading of the status return information of each status detection interface includes: Send request information to each status detection interface according to a preset interval; The status return information is read, where the status return information is generated by each server according to the request information.
5. The method according to claim 2, characterized in that: The step of adjusting the flow parameter of the target shutdown server according to the first preset rule until the flow of the target shutdown server is reduced to the first preset flow includes: Adjusting the flow parameter of the target downtime server to a first flow ratio; Detecting the state of the target shutdown server, if the state of the target shutdown server includes a waiting shutdown state, adjusting the flow parameter of the target shutdown server to a second flow ratio, wherein the second flow ratio is smaller than the first flow ratio; Detect the state of the target shutdown server. If the state of the target shutdown server includes a waiting shutdown state, adjust the flow parameter of the target shutdown server to a third flow ratio so that the flow of the target shutdown server is reduced to the first preset flow, and the third flow ratio is less than the second flow ratio.
6. The method according to claim 1, characterized in that After adjusting the traffic parameter of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, the method further includes: Detecting the status of the target downtime server; If the state of the target shutdown server includes a running state, the flow parameter of the target shutdown server is adjusted according to a second preset rule until the flow of the target shutdown server increases to a second preset flow.
7. The method according to claim 6, characterized in that The step of adjusting the flow parameter of the target shutdown server according to the second preset rule until the flow of the target shutdown server increases to the second preset flow includes: Adjusting the flow parameter of the target downtime server to a fourth flow ratio; Detecting the state of the target shutdown server, and if the state of the target shutdown server includes a running state, adjusting the flow parameter of the target shutdown server to a fifth flow ratio, wherein the fifth flow ratio is greater than the fourth flow ratio; Detect the status of the target shutdown server. If the status of the target shutdown server includes an operating status, adjust the flow parameters of the target shutdown server to a sixth flow ratio so that the flow of the target shutdown server increases to the second preset flow, and the sixth flow ratio is greater than the fifth flow ratio.
8. A server traffic regulation device, characterized in that: The device comprises: A status detection module, used to detect the status of each server in a server group, wherein the server group includes a plurality of servers, and the plurality of servers are respectively connected to a load balancing device; A server determination module, configured to determine a target downtime server and a running server in the server group according to the status of the server, wherein the server group includes at least one running server; The traffic regulating module is used to adjust the traffic parameters of the target shutdown server according to the first preset rule until the traffic of the target shutdown server is reduced to the first preset traffic, and distribute the reduced traffic of the target shutdown server to the at least one running server.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
