Methods, devices, storage media, and electronic equipment for distributing traffic.
By associating proxy containers with the server and monitoring failure and health rates in real time, and adjusting the traffic distribution method, the problem of insufficient traffic pressure perception of the service cluster was solved, and load balancing and efficient resource utilization were achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2023-04-10
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies cannot detect the traffic pressure of each service cluster, which leads to anomalies in the service cluster when processing business traffic, resulting in load imbalance and resource waste.
By associating a proxy container with each server, the failure rate and health rate of the server are monitored in real time. The controller adjusts the traffic distribution method based on the failure rate and health rate detected by the proxy container, thereby realizing real-time perception and dynamic adjustment of traffic pressure on each service cluster.
It enables real-time perception and dynamic adjustment of traffic pressure on the service cluster, avoiding anomalies when the service cluster processes business traffic and improving resource utilization efficiency.
Smart Images

Figure CN116489156B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing technology, and more specifically, to a method, apparatus, storage medium, and electronic device for traffic allocation. Background Technology
[0002] With the continuous development of distributed microservices and the increasing scale of microservice clusters, multiple provider microservice clusters are often deployed to jointly provide services to the outside world in order to ensure high availability of service calls. In order to ensure stable business operation and maximize the utilization of service cluster resources, it is necessary to adopt a traffic load balancing method among multiple clusters to utilize service cluster resources.
[0003] Current mainstream multi-cluster load balancing solutions are based on intelligent domain name traffic sharding. Multiple business zones correspond to multiple service clusters, and multiple service clusters are jointly mounted to the same intelligent domain name. When the intelligent domain name DNS device receives a business traffic, it forwards it to the corresponding service cluster according to the zone attribute of the calling end. If there is no provider in the corresponding service cluster, it will randomly load the traffic to other service clusters.
[0004] However, intelligent domain name DNS is just a simple traffic load balancing device. It cannot sense the traffic pressure of each service cluster. When the traffic is uneven across different business areas, it can cause some clusters to be overloaded, resulting in a large number of business calls timeouts and failures. However, the service resources of other clusters are largely idle, causing a waste of computing power and making it impossible to reasonably schedule and run multiple service clusters.
[0005] There is currently no effective solution to the problem that the relevant technologies cannot detect the traffic pressure of each service cluster, which causes anomalies when the service clusters process business traffic. Summary of the Invention
[0006] This application provides a traffic allocation method, apparatus, storage medium, and electronic device to solve the problem in related technologies where the traffic pressure of each service cluster cannot be perceived, leading to abnormalities in the service cluster when processing business traffic.
[0007] According to one aspect of this application, a traffic allocation method is provided. The method includes: identifying target traffic flowing through a target gateway and determining a cluster for processing the target traffic to obtain a target cluster, wherein the target cluster includes multiple servers and a proxy container for each server; selecting any proxy container in the target cluster to obtain a target proxy container; determining the failure rate associated with the target proxy container and determining the health rate of the target cluster, wherein the failure rate is the failure rate of the server processing traffic services monitored by the target proxy container, and the health rate is determined by the operating status of multiple servers in the target cluster; determining whether the failure rate is an outlier and whether the health rate is an outlier; if the failure rate or health rate is an outlier, controlling the target gateway to send the target traffic to the server corresponding to a candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters.
[0008] Optionally, in the event of an anomaly in the failure rate or health rate, controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container includes: in the event of an anomaly in the failure rate, selecting any proxy container other than the target proxy container from the target cluster to obtain a candidate proxy container, and controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container; in the event of an anomaly in the health rate, determining the total traffic received by the target cluster at the current moment, and determining the ratio between the total traffic and the maximum processing traffic of the target cluster to obtain a target ratio; determining whether the target ratio is greater than the health rate, and if the target ratio is greater than the health rate, sending the target traffic to any proxy container in the remaining clusters, wherein the remaining clusters are any clusters other than the target cluster.
[0009] Optionally, determining the cluster used to process the target traffic, and obtaining the target cluster includes: identifying the user terminal sending the target traffic to obtain the target user terminal; and determining the cluster associated with the target user terminal through a preset configuration table to obtain the target cluster, wherein the preset configuration table includes multiple user terminals and the cluster associated with each user terminal.
[0010] Optionally, determining the health rate of the target cluster includes: obtaining the current status of each server in the target cluster to obtain multiple current statuses; determining the number of servers with a current status of normal to obtain a first number; obtaining the total number of servers in the target cluster and calculating the ratio of the first number to the total number to obtain the health rate.
[0011] Optionally, determining whether the failure rate and the health rate are outliers includes: determining whether the failure rate is greater than a failure rate threshold; if the failure rate is greater than the failure rate threshold, determining that the failure rate is an outlier; determining whether the health rate is greater than a health rate threshold; if the health rate is less than the health rate threshold, determining that the health rate is an outlier.
[0012] Optionally, after determining whether the failure rate is an outlier, the method further includes: if the failure rate is an outlier, obtaining the maximum traffic processing value of the target proxy container, wherein the maximum traffic processing value represents the maximum traffic value that the target proxy container can process in parallel; determining whether the maximum traffic processing value is less than a preset traffic processing value; if the maximum traffic processing value is less than or equal to the preset traffic processing value, changing the current state of the target proxy container to outlier and initializing the failure rate of the target proxy container; if the maximum traffic processing value is greater than the preset traffic processing value, reducing the maximum traffic processing value of the target proxy container.
[0013] Optionally, determining the failure rate associated with the target proxy container includes: obtaining the historical traffic processing logs of the target proxy container and obtaining the historical processing results from the historical traffic processing logs, wherein the maximum traffic processing value of the target proxy container in the historical traffic processing logs is the same as the maximum traffic processing value of the target proxy container at the current moment; obtaining the total number of processing and the number of failed processing in the historical processing results, and calculating the proportion of the number of failed processing in the total number of processing to obtain the failure rate.
[0014] According to another aspect of this application, a traffic allocation apparatus is provided. The apparatus includes: an identification unit, configured to identify target traffic flowing through a target gateway and determine a cluster for processing the target traffic, thereby obtaining a target cluster, wherein the target cluster includes multiple servers and a proxy container for each server; a determination unit, configured to select any proxy container in the target cluster, thereby obtaining a target proxy container, determine the failure rate associated with the target proxy container, and determine the health rate of the target cluster, wherein the failure rate is the failure rate of the server processing traffic services monitored by the target proxy container, and the health rate is determined by the operating status of multiple servers in the target cluster; and a control unit, configured to determine whether the failure rate is an abnormal value and whether the health rate is an abnormal value, and, in the case of an abnormal failure rate or health rate, control the target gateway to send the target traffic to the server corresponding to the candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters.
[0015] According to another aspect of the present invention, a computer storage medium is also provided for storing a program, wherein the program, when running, controls the device where the computer storage medium is located to perform a traffic allocation method.
[0016] According to another aspect of the present invention, an electronic device is also provided, comprising one or more processors and a memory; the memory stores computer-readable instructions, and the processor is configured to execute the computer-readable instructions, wherein the computer-readable instructions, when executed, perform a traffic allocation method.
[0017] This application employs the following steps: identifying target traffic flowing through a target gateway and determining the cluster used to process the target traffic, thus obtaining a target cluster, wherein the target cluster includes multiple servers and a proxy container for each server; selecting any proxy container in the target cluster, thus obtaining a target proxy container; determining the failure rate associated with the target proxy container and the health rate of the target cluster, wherein the failure rate is the failure rate of the server monitoring the traffic processing services, and the health rate is determined by the running status of multiple servers in the target cluster; determining whether the failure rate and the health rate are outliers; if either the failure rate or the health rate is an outlier, controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters. This solves the problem in related technologies where the traffic pressure of each service cluster cannot be perceived, leading to anomalies in the service cluster when processing business traffic. By associating a proxy container with each server, the failure rate and health rate of the server are monitored in real time through the proxy container. The controller then adjusts the traffic distribution method of the target cluster and the servers in the target cluster based on the failure rate and health rate detected by multiple proxy containers. This achieves the effect of real-time perception of the traffic pressure of each service cluster and adjustment of the traffic distribution method according to the traffic pressure. Attached Figure Description
[0018] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0019] Figure 1 This is a schematic diagram of a traffic allocation system provided according to an embodiment of this application;
[0020] Figure 2 This is a flowchart of a traffic allocation method provided according to an embodiment of this application;
[0021] Figure 3 This is a schematic diagram of a traffic distribution device provided according to an embodiment of this application;
[0022] Figure 4 This is a schematic diagram of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0023] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] It should be noted that all information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information after receiving consent from the aforementioned user or organization.
[0027] It should be noted that the traffic allocation method, apparatus, storage medium and electronic device defined in this disclosure can be used in the field of cloud computing technology, or in any field other than cloud computing technology. The application fields of the traffic allocation method, apparatus, storage medium and electronic device defined in this disclosure are not limited.
[0028] Figure 1 This is a schematic diagram of a traffic allocation system provided according to an embodiment of this application. In this embodiment, as shown... Figure 1 As shown, the aforementioned traffic allocation method is executed using an optional traffic allocation system as the execution entity. This traffic allocation system includes at least:
[0029] The server, or service provider, is located in the node and connected to the container. It is the smallest unit for processing business traffic and is used to process the business content transmitted by the traffic sent by the user.
[0030] The proxy container is connected to the server in a one-to-one manner and is used to monitor the server's operation and traffic processing.
[0031] Nodes: Each node consists of a server and a proxy container, which facilitates server management within the cluster.
[0032] The user end, or service consumer, connects to the gateway, and users can send business traffic to the server through the server.
[0033] The controller connects to the proxy containers and the gateway. It is used to obtain the monitoring data collected by each proxy container from the corresponding server and control the gateway based on the monitoring data, so that the gateway can adjust the traffic allocation according to the monitoring results.
[0034] The gateway connects to the controller, containers, and client. Clients make server calls through the cross-cluster gateway and allocate traffic appropriately according to instructions issued by the controller.
[0035] Specifically, the gateway receives service traffic sent by user terminal 1 and user terminal 2. At this time, the service traffic needs to be allocated. If the cluster corresponding to user terminal 1 is cluster A and the cluster corresponding to user terminal 2 is cluster B, service traffic 1 can be sent to node 1 or node 2, and service traffic 2 can be sent to any node in cluster B, such as node n. At this time, it is necessary to determine whether the node can process the service traffic by using the server failure rate returned by the container. If the failure rate of node n is high, it indicates that service traffic 2 cannot be processed by server n in node n and needs to be sent to other containers, thereby ensuring that the server of each cluster can successfully complete the processing of each service traffic in the current state.
[0036] According to an embodiment of this application, a method for allocating traffic is provided. Figure 2 This is a flowchart of a traffic allocation method provided according to an embodiment of this application. For example... Figure 2 As shown, the method includes the following steps:
[0037] Step S201: Identify the target traffic flowing through the target gateway and determine the cluster used to process the target traffic to obtain the target cluster, wherein the target cluster includes multiple servers and a proxy container for each server.
[0038] Specifically, the target gateway can connect to the controller, containers, and client. The client makes server calls through the cross-cluster gateway and allocates traffic appropriately according to the instructions issued by the controller. The target traffic can be the business traffic generated by the client when handling a certain business. After the target gateway receives the target traffic, it needs to identify the cluster that processes the target traffic to determine the target cluster.
[0039] It should be noted that, as Figure 1 As shown, there are multiple nodes in the target cluster. Each node consists of a server and a proxy container. The proxy container corresponds one-to-one with the server and is used to monitor the server to determine the processing result of the server when processing each traffic.
[0040] Step S202: Select any proxy container in the target cluster to obtain the target proxy container, determine the failure rate associated with the target proxy container, and determine the health rate of the target cluster. The failure rate is the failure rate of the server-side traffic processing business monitored by the target proxy container, and the health rate is determined by the running status of multiple servers in the target cluster.
[0041] Specifically, after determining the target cluster, any proxy container can be selected from the target cluster to obtain the target proxy container, and the failure rate associated with the target proxy container can be determined. That is, the failure rate is the failure rate of the server's processing traffic calculated based on the processing results of the server's business traffic after the target container monitors the corresponding server.
[0042] It should be noted that the failure rate can be the failure rate of the business corresponding to the traffic processed by the server associated with the target container. For example, if server A receives 3 business traffic, completes the business successfully 2 times and fails to complete the business once, then the failure rate is 33%.
[0043] Furthermore, the health rate characterizes the cluster's traffic processing capacity. After determining the failure rate of the target proxy container, it is also necessary to determine the health rate of the target cluster to determine whether the target cluster can receive and process the target traffic. When determining the health rate of the target cluster, not only the monitoring information of the target proxy container, but also the monitoring information of the other proxy containers in the target cluster are needed. Thus, the health rate of the target cluster can be calculated based on the monitoring information of each proxy container in the target cluster, thereby determining the traffic processing capacity of the target cluster.
[0044] Step S203: Determine whether the failure rate is an outlier and whether the health rate is an outlier. If the failure rate or health rate is an outlier, control the target gateway to send the target traffic to the server corresponding to the candidate proxy container. The candidate proxy container is located in the target cluster or in other clusters.
[0045] Specifically, if either the failure rate or the health rate is abnormal, with a health rate that is too low or a failure rate that is too high being considered abnormal, then the target traffic cannot be sent to the target proxy container. In this case, the target gateway cannot send the target traffic to the target proxy container according to the preset traffic allocation rules. Instead, it needs to be controlled to send the target traffic to other proxy containers. The selection of other proxy containers needs to be determined based on the failure rate and health rate. That is, the selection of candidate proxy containers in the target cluster or in other clusters is determined based on the abnormality of the failure rate and health rate.
[0046] The traffic allocation method provided in this application identifies target traffic flowing through a target gateway and determines the cluster used to process the target traffic, thus obtaining a target cluster. The target cluster includes multiple servers and a proxy container for each server. An arbitrary proxy container is selected from the target cluster to obtain a target proxy container. The failure rate associated with the target proxy container and the health rate of the target cluster are determined. The failure rate is the failure rate of the server monitoring the traffic processing services, and the health rate is determined by the operating status of multiple servers in the target cluster. It is determined whether the failure rate and health rate are outliers. If either the failure rate or health rate is outlier, the target gateway is controlled to send the target traffic to the server corresponding to the candidate proxy container. The candidate proxy container is located in the target cluster or in other clusters. This solves the problem in related technologies where the traffic pressure of each service cluster cannot be perceived, leading to anomalies in the service clusters when processing business traffic. By associating a proxy container with each server, the failure rate and health rate of the server are monitored in real time through the proxy container. The controller then adjusts the traffic distribution method of the target cluster and the servers in the target cluster based on the failure rate and health rate detected by multiple proxy containers. This achieves the effect of real-time perception of the traffic pressure of each service cluster and adjustment of the traffic distribution method according to the traffic pressure.
[0047] In the event of an anomaly in the target container or target cluster, in order to reasonably allocate the target traffic, optionally, in the traffic allocation method provided in this application embodiment, when the failure rate or health rate is an anomaly, controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container includes: when the failure rate is an anomaly, selecting any proxy container other than the target proxy container from the target cluster to obtain a candidate proxy container, and controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container; when the health rate is an anomaly, determining the total traffic received by the target cluster at the current moment, and determining the ratio between the total traffic and the maximum processing traffic of the target cluster to obtain a target ratio; determining whether the target ratio is greater than the health rate, and if the target ratio is greater than the health rate, sending the target traffic to any proxy container in the remaining clusters, wherein the remaining clusters are any clusters other than the target cluster.
[0048] Specifically, if the failure rate is an outlier but the health rate is normal, it indicates that the target proxy container has an excessively high failure rate in processing business traffic. In this case, the target container cannot process the business traffic normally. Therefore, the target traffic can be sent to other proxy containers in the target cluster for re-evaluation until a proxy container can process the target traffic.
[0049] Furthermore, if the health rate of the target cluster is an outlier, it indicates that some proxy containers within the target cluster are not functioning properly. In this case, it is necessary to determine the total traffic sent to the target cluster simultaneously with the target traffic, and divide this total traffic by the target cluster's maximum processing capacity. This yields the ratio of the current total traffic requiring processing to the target cluster's maximum processing capacity. This ratio is then compared to the target cluster's health rate to determine whether the target cluster can process all of this traffic. If the target ratio is greater than the health rate, it indicates that the target cluster cannot process all of this traffic. In this case, this traffic needs to be distributed, meaning the target traffic can be sent to other clusters for processing. This ensures that the target cluster receives a reasonable amount of traffic and can therefore process the received business traffic normally.
[0050] For example, if cluster A has a total traffic processing capacity of 500, and a certain batch of traffic is 100, then the proportion is 20%. When the health value is 60%, cluster A can complete the processing of this batch of traffic, so there is no need for traffic splitting. If a certain batch of traffic is 450, then the proportion is 90%, and cluster A cannot process all of this batch of traffic. Therefore, some traffic needs to be distributed to other clusters for processing. That is, 60% of the traffic is processed by the target cluster, and the remaining 30% is processed by the other clusters.
[0051] Optionally, in the traffic allocation method provided in this application embodiment, determining the cluster used to process the target traffic and obtaining the target cluster includes: identifying the user terminal sending the target traffic and obtaining the target user terminal; determining the cluster associated with the target user terminal through a preset configuration table and obtaining the target cluster, wherein the preset configuration table includes multiple user terminals and the cluster associated with each user terminal.
[0052] Specifically, when determining the target cluster corresponding to the target traffic, the target cluster can be determined by identifying the client information of the client sending the target traffic and determining the name of the cluster corresponding to the client in the preset configuration table based on the client information.
[0053] In order to accurately calculate the cluster health rate and thus determine whether the target cluster is abnormal, optionally, in the traffic allocation method provided in this application embodiment, determining the health rate of the target cluster includes: obtaining the current status of each server in the target cluster to obtain multiple current statuses; determining the number of servers with a current status of normal to obtain a first number; obtaining the total number of servers in the target cluster and calculating the ratio of the first number to the total number to obtain the health rate.
[0054] Specifically, the health rate of a cluster is used to characterize the proportion of servers in the cluster that can be used normally. Therefore, when calculating the health rate, it is necessary to determine the status of each server in the cluster based on the proxy container and determine the number of servers in the normal status. The health rate can be obtained by dividing the number of servers in the normal status by the total number of servers in the cluster.
[0055] For example, if there are 10 servers in cluster B, 6 of which are in a normal state and 4 are in an abnormal state, then the health rate of cluster B is 60%.
[0056] Optionally, in the traffic allocation method provided in this application embodiment, determining whether the failure rate is an outlier and whether the health rate is an outlier includes: determining whether the failure rate is greater than a failure rate threshold; if the failure rate is greater than the failure rate threshold, determining that the failure rate is an outlier; determining whether the health rate is greater than a health rate threshold; if the health rate is less than the health rate threshold, determining that the health rate is an outlier.
[0057] Specifically, when determining whether there are anomalies in the failure rate and health rate, it is possible to check whether the failure rate is greater than the failure rate threshold and whether the health rate is greater than the health rate threshold. If the failure rate is greater than the failure rate threshold, it indicates that the server is experiencing a high number of failures when processing business traffic. Therefore, it is determined that the server corresponding to the target proxy container can no longer process business traffic, thus identifying the failure rate associated with the target proxy container as an anomaly.
[0058] Similarly, when the health rate is less than the health rate threshold, it indicates that the number of servers in the target cluster that can be used normally is small. In this case, the health rate of the target cluster can be determined to be an outlier.
[0059] Optionally, in the traffic allocation method provided in this application embodiment, after determining whether the failure rate is an outlier, the method further includes: if the failure rate is an outlier, obtaining the maximum traffic processing value of the target proxy container, wherein the maximum traffic processing value represents the maximum traffic value that the target proxy container can process in parallel; determining whether the maximum traffic processing value is less than a preset traffic processing value; if the maximum traffic processing value is less than or equal to the preset traffic processing value, changing the current state of the target proxy container to outlier and initializing the failure rate of the target proxy container; if the maximum traffic processing value is greater than the preset traffic processing value, reducing the maximum traffic processing value of the target proxy container.
[0060] Specifically, if the failure rate of the target proxy container is determined to be an outlier, the container needs to be downgraded, which means reducing the maximum traffic that the target proxy container can handle. After reducing the maximum traffic handling value, the failure rate of the target proxy container needs to be recalculated. That is, the target proxy container can still receive and process traffic normally, but the traffic it can handle is reduced, thereby achieving the effect of adjusting container load balancing based on container status.
[0061] Furthermore, if the maximum traffic processing value is less than the preset traffic processing value, it indicates that the maximum traffic processing value cannot be downgraded further. In this case, the target proxy container needs to be identified as an abnormal proxy container, and the current state of the target proxy container needs to be changed to abnormal. At this time, the health rate of the target cluster to which the target proxy container belongs will decrease due to the change in the state of the target proxy container.
[0062] Optionally, in the traffic allocation method provided in this application embodiment, determining the failure rate associated with the target proxy container includes: obtaining the historical traffic processing log of the target proxy container, and obtaining the historical processing results from the historical traffic processing log, wherein the maximum traffic processing value of the target proxy container in the historical traffic processing log is the same as the maximum traffic processing value of the target proxy container at the current moment; obtaining the total number of processing and the number of failed processing in the historical processing results, and calculating the proportion of the number of failed processing in the total number of processing to obtain the failure rate.
[0063] Specifically, when calculating the failure rate of the target proxy container at the current moment, it is first necessary to obtain the maximum traffic processing value of the target proxy container at the current moment, and obtain the historical processing results from the historical traffic processing log. The maximum traffic processing value of the target proxy container at the time when the historical processing result was generated should be the same as the maximum traffic processing value of the target proxy container at the current moment. For example, if the maximum traffic processing value of the target proxy container at the current moment is 20, the maximum traffic processing value of the target proxy container at the time when the historical processing result was generated should also be 20. Historical processing results under other maximum traffic processing values are not included in this failure rate calculation.
[0064] Furthermore, after obtaining the historical processing results, it is necessary to obtain the number of results that are failures, and divide the number of failures by the total number in the historical processing results to obtain the failure rate of the server associated with the target proxy capacity at the current moment, thereby achieving the effect of accurately calculating the failure rate of the server corresponding to the target proxy container.
[0065] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0066] This application also provides a traffic allocation device. It should be noted that the traffic allocation device of this application can be used to execute the traffic allocation method provided in this application. The traffic allocation device provided in this application will be described below.
[0067] Figure 3 This is a schematic diagram of a traffic distribution device provided according to an embodiment of this application. For example... Figure 3 As shown, the device includes: an identification unit 31, a determination unit 32, and a control unit 33.
[0068] The identification unit 31 is used to identify the target traffic flowing through the target gateway and determine the cluster used to process the target traffic to obtain the target cluster, wherein the target cluster includes multiple servers and a proxy container for each server.
[0069] The determining unit 32 is used to select any proxy container in the target cluster, obtain the target proxy container, determine the failure rate associated with the target proxy container, and determine the health rate of the target cluster. The failure rate is the failure rate of the server-side traffic processing business monitored by the target proxy container, and the health rate is determined by the running status of multiple servers in the target cluster.
[0070] Control unit 33 is used to determine whether the failure rate is an abnormal value and whether the health rate is an abnormal value. If the failure rate or health rate is an abnormal value, control the target gateway to send the target traffic to the server corresponding to the candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters.
[0071] The traffic allocation device provided in this application embodiment identifies target traffic flowing through a target gateway through an identification unit 31, and determines the cluster used to process the target traffic, thus obtaining a target cluster. The target cluster includes multiple servers and a proxy container for each server. A determination unit 32 selects any proxy container in the target cluster to obtain a target proxy container, determines the failure rate associated with the target proxy container, and determines the health rate of the target cluster. The failure rate is the failure rate of the server monitoring the traffic service processed by the target proxy container, and the health rate is determined by the operating status of multiple servers in the target cluster. A control unit 33 determines whether the failure rate and health rate are abnormal values. If either the failure rate or health rate is abnormal, the control unit controls the target gateway to send the target traffic to the server corresponding to the candidate proxy container. The candidate proxy container is located in the target cluster or in other clusters. This solves the problem in related technologies where the traffic pressure of each service cluster cannot be perceived, leading to abnormalities in the service cluster when processing business traffic. By associating a proxy container with each server, the failure rate and health rate of the server are monitored in real time through the proxy container. The controller then adjusts the traffic distribution method of the target cluster and the servers in the target cluster based on the failure rate and health rate detected by multiple proxy containers. This achieves the effect of real-time perception of the traffic pressure of each service cluster and adjustment of the traffic distribution method according to the traffic pressure.
[0072] Optionally, in the traffic allocation device provided in this application embodiment, the control unit 33 includes: a control module, configured to select any proxy container other than the target proxy container from the target cluster to obtain candidate proxy containers when the failure rate is an abnormal value, and control the target gateway to send the target traffic to the server corresponding to the candidate proxy container; a first determination module, configured to determine the total traffic received by the target cluster at the current time when the health rate is an abnormal value, and determine the ratio between the total traffic and the maximum processing traffic of the target cluster to obtain a target ratio; and a first judgment module, configured to judge whether the target ratio is greater than the health rate, and if the target ratio is greater than the health rate, send the target traffic to any proxy container in the remaining clusters, wherein the remaining clusters are any clusters other than the target cluster.
[0073] Optionally, in the traffic allocation device provided in this application embodiment, the identification unit 31 includes: an identification module, used to identify the user terminal sending the target traffic and obtain the target user terminal; and a second determination module, used to determine the cluster associated with the target user terminal through a preset configuration table and obtain the target cluster, wherein the preset configuration table includes multiple user terminals and the cluster associated with each user terminal.
[0074] Optionally, in the traffic allocation device provided in the embodiments of this application, the determining unit 32 includes: a first obtaining module, used to obtain the current status of each server in the target cluster, and obtain multiple current statuses; a third determining module, used to determine the number of servers with a current status of normal, and obtain a first number; and a second obtaining module, used to obtain the total number of servers in the target cluster, and calculate the ratio of the first number to the total number, and obtain a health rate.
[0075] Optionally, in the traffic distribution device provided in this application embodiment, the control unit 33 includes: a second judgment module, used to judge whether the failure rate is greater than the failure rate threshold; a fourth determination module, used to determine that the failure rate is an abnormal value when the failure rate is greater than the failure rate threshold; a third judgment module, used to judge whether the health rate is greater than the health rate threshold; and a fifth determination module, used to determine that the health rate is an abnormal value when the health rate is less than the health rate threshold.
[0076] Optionally, in the traffic allocation device provided in the embodiments of this application, the device further includes: an acquisition unit, configured to acquire the maximum traffic processing value of the target proxy container when the failure rate is an abnormal value, wherein the maximum traffic processing value represents the maximum traffic value that the target proxy container can process in parallel; a judgment unit, configured to judge whether the maximum traffic processing value is less than a preset traffic processing value; a change unit, configured to change the current state of the target proxy container to abnormal and initialize the failure rate of the target proxy container when the maximum traffic processing value is less than or equal to the preset traffic processing value; and a reduction unit, configured to reduce the maximum traffic processing value of the target proxy container when the maximum traffic processing value is greater than the preset traffic processing value.
[0077] Optionally, in the traffic allocation device provided in this application embodiment, the determining unit 32 includes: a third acquisition module, used to acquire the historical traffic processing log of the target proxy container and acquire the historical processing result from the historical traffic processing log, wherein the maximum traffic processing value of the target proxy container in the historical traffic processing log is the same as the maximum traffic processing value of the target proxy container at the current moment; and a fourth acquisition module, used to acquire the total number of processing and the number of failed processing in the historical processing result, and calculate the proportion of the number of failed processing in the total number of processing to obtain the failure rate.
[0078] The aforementioned flow distribution device includes a processor and a memory. The aforementioned identification unit 31, determination unit 32, control unit 33, etc., are all stored in the memory as program units. The processor executes the aforementioned program units stored in the memory to realize the corresponding functions.
[0079] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured. By adjusting kernel parameters, the problem of service clusters being unable to perceive traffic pressure in different service clusters, leading to anomalies when processing business traffic, can be solved.
[0080] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0081] This invention provides a computer-readable storage medium storing a program that, when executed by a processor, implements the traffic allocation method.
[0082] This invention provides a processor for running a program, wherein the program executes the traffic allocation method during runtime.
[0083] like Figure 4 As shown, this embodiment of the invention provides an electronic device 40, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: identifying target traffic flowing through a target gateway and determining a cluster for processing the target traffic to obtain a target cluster, wherein the target cluster includes multiple servers and a proxy container for each server; selecting any proxy container in the target cluster to obtain a target proxy container; determining the failure rate associated with the target proxy container and determining the health rate of the target cluster, wherein the failure rate is the failure rate of the server processing traffic services monitored by the target proxy container, and the health rate is determined by the operating status of multiple servers in the target cluster; determining whether the failure rate is an outlier and whether the health rate is an outlier; if the failure rate or health rate is an outlier, controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters. The device in this document can be a server, PC, PAD, mobile phone, etc.
[0084] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program with the following method steps: identifying target traffic flowing through a target gateway and determining a cluster for processing the target traffic to obtain a target cluster, wherein the target cluster includes multiple servers and a proxy container for each server; selecting any proxy container in the target cluster to obtain a target proxy container, determining the failure rate associated with the target proxy container, and determining the health rate of the target cluster, wherein the failure rate is the failure rate of the server processing traffic services monitored by the target proxy container, and the health rate is determined by the running status of multiple servers in the target cluster; determining whether the failure rate is an outlier and whether the health rate is an outlier; if the failure rate or health rate is an outlier, controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters.
[0085] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0086] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0087] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0088] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0089] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0090] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0091] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0092] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0093] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for allocating traffic, characterized in that, include: Identify the target traffic flowing through the target gateway and determine the cluster used to process the target traffic to obtain the target cluster, wherein the target cluster includes multiple servers and a proxy container for each server; Select any proxy container in the target cluster to obtain the target proxy container, determine the failure rate associated with the target proxy container, and determine the health rate of the target cluster. The failure rate is the failure rate of the server-side traffic processing service monitored by the target proxy container, and the health rate is determined by the running status of multiple servers in the target cluster. Determine whether the failure rate is an outlier and whether the health rate is an outlier. If the failure rate or the health rate is an outlier, control the target gateway to send the target traffic to the server corresponding to the candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters. In the event of an anomaly in the failure rate or health rate, controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container includes: in the event of an anomaly in the failure rate, selecting any proxy container other than the target proxy container from the target cluster to obtain the candidate proxy container, and controlling the target gateway to send the target traffic to the server corresponding to the candidate proxy container; in the event of an anomaly in the health rate, determining the total traffic received by the target cluster at the current moment, and determining the ratio between the total traffic and the maximum processing traffic of the target cluster to obtain a target ratio; determining whether the target ratio is greater than the health rate, and if the target ratio is greater than the health rate, sending the target traffic to any proxy container in the remaining clusters, wherein the remaining clusters are any clusters other than the target cluster.
2. The method according to claim 1, characterized in that, The target cluster is determined by identifying the cluster used to process the target traffic, and includes the following: Identify the user terminal sending the target traffic to obtain the target user terminal; The target cluster is obtained by determining the cluster associated with the target user terminal through a preset configuration table, wherein the preset configuration table includes multiple user terminals and the cluster associated with each user terminal.
3. The method according to claim 1, characterized in that, Determining the health rate of the target cluster includes: Obtain the current state of each server in the target cluster, resulting in multiple current states; Determine the number of servers currently in a normal state to obtain a first number; Obtain the total number of servers in the target cluster, and calculate the ratio of the first number to the total number to obtain the health rate.
4. The method according to claim 1, characterized in that, Determining whether the failure rate and the health rate are outliers includes: Determine whether the failure rate is greater than the failure rate threshold; If the failure rate is greater than the failure rate threshold, the failure rate is determined to be an outlier. Determine whether the health rate is greater than the health rate threshold; If the health rate is less than the health rate threshold, the health rate is determined to be an outlier.
5. The method according to claim 1, characterized in that, After determining whether the failure rate is an outlier, the method further includes: In the case of an outlier failure rate, the maximum traffic processing value of the target proxy container is obtained, wherein the maximum traffic processing value represents the maximum traffic value that the target proxy container can process in parallel; Determine whether the maximum traffic processing value is less than the preset traffic processing value; If the maximum traffic processing value is less than or equal to the preset traffic processing value, the current state of the target proxy container is changed to abnormal, and the failure rate of the target proxy container is initialized. If the maximum traffic processing value is greater than the preset traffic processing value, the maximum traffic processing value of the target proxy container is reduced.
6. The method according to claim 5, characterized in that, Determining the failure rate associated with the target proxy container includes: Obtain the historical traffic processing log of the target proxy container, and obtain the historical processing result from the historical traffic processing log, wherein the maximum traffic processing value of the target proxy container in the historical traffic processing log is the same as the maximum traffic processing value of the target proxy container at the current moment; Obtain the total number of processed items and the number of failed processed items from the historical processing results, and calculate the proportion of the number of failed processed items in the total number of processed items to obtain the failure rate.
7. A flow distribution device, characterized in that, include: The identification unit is used to identify target traffic flowing through the target gateway and determine the cluster used to process the target traffic to obtain the target cluster, wherein the target cluster includes multiple servers and a proxy container for each server. The determining unit is configured to select any proxy container in the target cluster to obtain the target proxy container, determine the failure rate associated with the target proxy container, and determine the health rate of the target cluster, wherein the failure rate is the failure rate of the server-side traffic processing services monitored by the target proxy container, and the health rate is determined by the running status of multiple servers in the target cluster. The control unit is used to determine whether the failure rate is an abnormal value and whether the health rate is an abnormal value. If the failure rate or the health rate is an abnormal value, the control unit controls the target gateway to send the target traffic to the server corresponding to the candidate proxy container, wherein the candidate proxy container is located in the target cluster or in other clusters. The control unit includes: a control module, used to select any proxy container other than the target proxy container from the target cluster to obtain candidate proxy containers when the failure rate is an anomaly, and control the target gateway to send the target traffic to the server corresponding to the candidate proxy container; a first determination module, used to determine the total traffic received by the target cluster at the current moment when the health rate is an anomaly, and determine the ratio between the total traffic and the maximum processing traffic of the target cluster to obtain the target ratio; and a first judgment module, used to judge whether the target ratio is greater than the health rate, and if the target ratio is greater than the health rate, send the target traffic to any proxy container in the remaining clusters, wherein the remaining clusters are any clusters other than the target cluster.
8. A computer storage medium, characterized in that, The computer storage medium is used to store a program, wherein the program, when running, controls the device where the computer storage medium is located to execute the traffic allocation method according to any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the traffic allocation method according to any one of claims 1 to 6.