Cluster Traffic Management Method, Device, Computer Equipment and Storage Medium
By performing exception detection and traffic weight determination on the target cluster when receiving the service access request, and generating target routing configuration information, Nginx's access request interruption problem when the container cluster is abnormal, realizing the continuity of intelligent scheduling and access requests.
Patent Information
- Application Number
- CN202211516095.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-30
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2042-11-30
AI Technical Summary
When an exception occurs in the container cluster, the existing Nginx needs to passively modify the configuration file and restart the service, resulting in interruption of access requests and inability to achieve intelligent scheduling.
When receiving the service access request, determine the multiple target clusters in which the target application service is located, perform exception detection, determine traffic weights, and generate target routing configuration information based on the preset routing configuration rules, and directly send access requests to the target cluster to ensure the continuity of access requests.
It realizes no need to interrupt access requests when container cluster abnormalities, ensures intelligent scheduling of access requests, avoids delays, and improves the accuracy and flexibility of access requests.
Smart Images

Figure CN115914404B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of cloud platforms, and particularly to a method and device for cluster traffic management, a computer device, and a storage medium. Background Art
[0002] Generally, multiple application services are deployed in different container clusters. When accessing the traffic between application services within a cross-container cluster, it is necessary to pre-configure multiple egress gateway Nginx proxies, and then forward the access request to the target container cluster and the target application service.
[0003] Currently, after an exception occurs in the container cluster, the existing Nginx can only passively modify the configuration file, and it is necessary to restart the Nginx proxy service or reload the configuration file to make the access request take effect again. Therefore, how to actively detect the exception of the container cluster without interrupting the access request, so as to achieve intelligent scheduling of the access request is the problem to be solved by the present application. Summary of the Invention
[0004] Based on this, in view of the above technical problems, it is necessary to provide a method and device for cluster traffic management, a computer device, a storage medium, and a computer program product for intelligent scheduling of access requests.
[0005] In a first aspect, the present application provides a method for cluster traffic management. The method includes:
[0006] When receiving a service access request, determining the target application service in the service access request and multiple target clusters where the target application service is located;
[0007] Performing anomaly detection on each of the target clusters to obtain a detection result corresponding to each of the target clusters, and determining a traffic weight corresponding to each of the target clusters according to the detection results;
[0008] Determining target routing configuration information including a target configuration state and multiple traffic weights according to a preset routing configuration rule;
[0009] When the target configuration state is a target state, sending the service access request to each of the target clusters according to the target routing configuration information;
[0010] Wherein, the sent service access request is used to trigger the target cluster to access the target application service to obtain application data related to the target application service; the amount of data obtained for the application data corresponds to the traffic weight in the target routing configuration information.
[0011] In one embodiment, the anomaly detection for each of the target clusters to obtain the detection result corresponding to each target cluster includes: for each target cluster among a plurality of target clusters, performing anomaly detection on the current target cluster to obtain an initial detection result; when the initial detection result indicates an anomaly, performing node detection on the current target cluster a preset number of times at preset time intervals to obtain the detection result of the current target cluster; when the initial detection result indicates normal, using the initial detection result as the detection result of the current target cluster.
[0012] In one embodiment, the determining of the traffic weight corresponding to each target cluster according to each of the detection results includes: determining the initial weight corresponding to each target cluster according to preset gateway parameters; when each of the detection results indicates normal, using each of the initial weights as the traffic weight corresponding to the corresponding target cluster; when any one of the detection results indicates an anomaly, using a preset weight as the traffic weight of the target cluster whose detection result indicates an anomaly; obtaining the traffic weight of the target cluster whose detection result indicates normal according to the plurality of initial weights and the preset weight.
[0013] In one embodiment, determining the target routing configuration information including the target configuration state and a plurality of the traffic weights according to preset routing configuration rules includes: obtaining a routing domain name, and associating the routing domain name with the target application service according to the routing configuration rules to obtain a routing label of the target application service; searching the artifact library for historical routing configuration information identical to the routing label to obtain a search result, and determining the target configuration state corresponding to the service access request according to the search result; combining the routing label, the target configuration state, and the plurality of traffic weights to obtain initial routing configuration information corresponding to the target application service; when the target configuration state is the release state, using the initial routing configuration information as the target routing configuration information.
[0014] In one embodiment, determining the target routing configuration information including the target configuration state and multiple traffic weights according to the preset routing configuration rules includes: generating initial routing configuration information according to the preset routing configuration rules; the initial routing configuration information includes an initial version number and a target configuration state; in response to a modification configuration operation for the initial routing configuration information, obtaining modified routing configuration information; the modified routing configuration information includes a modified version number and a modified configuration state; the modified version number is generated by the routing configuration rules and the initial version number; updating the target configuration state in the initial routing configuration information to the offline state, and updating the modified configuration state in the modified routing configuration information to the published state; replacing the initial routing configuration information with the modified routing configuration information in the published state to obtain the target routing configuration information.
[0015] In one embodiment, determining the target routing configuration information including the target configuration state and multiple traffic weights according to the preset routing configuration rules includes: generating initial routing configuration information according to the preset routing configuration rules; the initial routing configuration information includes a routing label; when a target event occurs for the initial gateway in the container cluster, searching for historical routing configuration information with the same routing label from the data warehouse; the historical routing configuration information includes a historical configuration state; updating the historical configuration state from the offline state to the published state, and replacing the initial routing configuration information with the historical routing configuration information in the published state to obtain the target routing configuration information; the above method further includes: storing the target routing configuration information in the artifact library, and backing up the information in the artifact library in the data warehouse.
[0016] In a second aspect, the present application further provides a cluster traffic management device. The device includes:
[0017] A request receiving module, configured to determine a target application service in the service access request and multiple target clusters where the target application service is located when receiving the service access request;
[0018] An information determination module, configured to perform anomaly detection on each of the target clusters to obtain a detection result corresponding to each of the target clusters, and determine a traffic weight corresponding to each of the target clusters according to each detection result; determine target routing configuration information including a target configuration state and multiple traffic weights according to the preset routing configuration rules;
[0019] A request sending module, configured to, when the target configuration state is the target state, send the service access request to each of the target clusters according to the target routing configuration information; wherein, the sent service access request is used to trigger the target clusters to access the target application service, so as to obtain application data related to the target application service; the amount of the obtained application data corresponds to the traffic weight in the target routing configuration information.
[0020] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the following steps are implemented:
[0021] When receiving a service access request, determine the target application service in the service access request and multiple target clusters where the target application service is located;
[0022] Perform anomaly detection on each of the target clusters to obtain a detection result corresponding to each target cluster, and determine a traffic weight corresponding to each target cluster according to each detection result;
[0023] Determine target routing configuration information including a target configuration state and multiple traffic weights according to a preset routing configuration rule;
[0024] When the target configuration state is the target state, send the service access request to each of the target clusters according to the target routing configuration information;
[0025] Wherein, the sent service access request is used to trigger the target clusters to access the target application service, so as to obtain application data related to the target application service; the amount of the obtained application data corresponds to the traffic weight in the target routing configuration information.
[0026] In a fourth aspect, the present application further provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the following steps are implemented:
[0027] When receiving a service access request, determine the target application service in the service access request and multiple target clusters where the target application service is located;
[0028] Perform anomaly detection on each of the target clusters to obtain a detection result corresponding to each target cluster, and determine a traffic weight corresponding to each target cluster according to each detection result;
[0029] Determine target routing configuration information including a target configuration state and multiple traffic weights according to a preset routing configuration rule;
[0030] When the target configuration state is the target state, send the service access request to each of the target clusters according to the target routing configuration information;
[0031] Among them, the sent service access request is used to trigger the target cluster to access the target application service to obtain application data related to the target application service; the amount of the obtained application data corresponds to the traffic weight in the target routing configuration information.
[0032] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0033] When receiving a service access request, determine the target application service in the service access request and multiple target clusters where the target application service is located;
[0034] Perform anomaly detection on each of the target clusters to obtain a detection result corresponding to each of the target clusters, and determine a traffic weight corresponding to each of the target clusters according to each of the detection results;
[0035] Determine target routing configuration information including a target configuration state and multiple of the traffic weights according to a preset routing configuration rule;
[0036] When the target configuration state is the target state, send the service access request to each of the target clusters according to the target routing configuration information;
[0037] Among them, the sent service access request is used to trigger the target cluster to access the target application service to obtain application data related to the target application service; the amount of the obtained application data corresponds to the traffic weight in the target routing configuration information.
[0038] The above cluster traffic management method, device, computer device, storage medium, and computer program product can determine the target application service in the service access request and the multiple target clusters where the target application service is located when receiving the service access request. Then, by performing anomaly detection on each target cluster, the detection result corresponding to each target cluster can be obtained, and based on each detection result, the traffic weight corresponding to each target cluster can be determined. In this way, according to the preset routing configuration rules, the target routing configuration information including the target configuration state and multiple traffic weights can be determined. When the target configuration state is the target state, the service access request can be directly sent to each target cluster according to the target routing configuration information. Since this application can directly determine the traffic weight after actively performing anomaly detection on the target cluster, compared with the traditional method of passively modifying the configuration file after an anomaly occurs in the container cluster, this application ensures that the sending process of the access request is not interrupted and avoids the delay in accessing the target application service in the target cluster. Therefore, the scheduling of the access request is made more intelligent. At the same time, through the accurately obtained target routing configuration information, the amount of application data accessed can correspond to the traffic weight in the target routing configuration information, improving the accuracy of sending the access request. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is an application environment diagram of the cluster traffic management method in an embodiment;
[0040] Figure 2 It is a flowchart of the cluster traffic management method in an embodiment;
[0041] Figure 3 It is a schematic diagram of the principle of accessing application services between container clusters in an embodiment;
[0042] Figure 4 It is a schematic diagram of the principle of sending a service access request in an embodiment;
[0043] Figure 5 It is a flowchart of the process of determining the target routing configuration information in an embodiment;
[0044] Figure 6 It is a timing diagram of determining the target routing configuration information in an embodiment;
[0045] Figure 7 It is a structural block diagram of the cluster traffic management device in an embodiment;
[0046] Figure 8 It is an internal structure diagram of a computer device in an embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0047] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to 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.
[0048] The cluster traffic management method provided by the present application can be applied to an application environment as Figure 1 shown. Among them, the terminal 102 communicates with the server 104 through a network, and the server 104 communicates with the computer device 106 through a network; the terminal 102 and the server 104 are located in the same initial cluster, and the computer device 106 is located in a target cluster different from the initial cluster. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed in the cloud or other network servers. The terminal 102 is used to provide a service access request; when the server 104 receives the service access request, it determines the target application service in the service access request and the multiple target clusters where the target application service is located, and performs anomaly detection on each target cluster to obtain the detection result corresponding to each target cluster; the server 104 is also used to determine the traffic weight corresponding to each target cluster according to each detection result, and determine the target routing configuration information including the target configuration state and multiple traffic weights according to the preset routing configuration rules; the server 104 is also used to, when the target configuration state is the target state, send the service access request to the computer device 106 corresponding to each target cluster according to the target routing configuration information. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers. The server 104 can be a kind of intelligent gateway.
[0049] In one of the embodiments, as Figure 2 shown, a cluster traffic management method is provided. This method is executed by taking the server in Figure 1 as an example, and includes the following steps:
[0050] Step 202, when receiving a service access request, determine the target application service in the service access request and the multiple target clusters where the target application service is located.
[0051] Among them, multiple application services, egress modules, ingress modules, and load balancing modules corresponding to the application services are deployed in different container clusters; the container clusters include an initial cluster and a target cluster. When traffic access occurs between application services within different container clusters, it needs to be triggered by a service access request. For example, the first container cluster is the initial cluster, the second container cluster is the target cluster, and the initial application service in the initial cluster accesses the target application service in the target cluster for traffic.
[0052] Specifically, as Figure 3 shown, Figure 3 is a schematic diagram of the principle for accessing application services between container clusters. When the terminal where the initial application service is located responds to the user's trigger operation, a service access request is generated, and through the initial load balancing module in the initial cluster, the service access request is sent to the initial egress module in the initial cluster, so that the initial egress module determines the target application service in the service access request and the multiple target clusters where the target application service is located.
[0053] In one embodiment, the server executing the cluster traffic management method can be the initial egress module, and the initial egress module can also be the initial gateway.
[0054] In one embodiment, a blacklist can be provided in the server. The blacklist includes the IP addresses, network segment ranges, etc. of POD containers, and is used to restrict the source of traffic access for some application services. When the terminal where the initial application service is located responds to the user's trigger operation, it determines the target application service selected by the user and the IP address of the target application service, and compares this IP address with the blacklist. When this IP address is not in the blacklist, a service access request is generated according to the target application service and the IP address.
[0055] In one embodiment, the egress module in the container cluster can be a kind of gateway, such as the APISIX gateway; the ingress module in the container cluster can be the Ingress CLB module.
[0056] In one embodiment, the APISIX gateway supports the etcd cluster, which enhances the availability of the cluster traffic management system through the etcd cluster. When all configurations are uniformly stored and managed through the etcd cluster, problems such as messy configuration management and high maintenance costs can be avoided.
[0057] In one embodiment, the target ingress module in the target cluster, as the unified traffic entry of the container cluster, is used to receive all service access requests and forward the service access requests to the target load balancing module in the target cluster, so that through the target load balancing module, the service access requests are forwarded to the POD containers in the target application service for processing.
[0058] Step 204: Perform anomaly detection on each target cluster to obtain the detection result corresponding to each target cluster, and determine the traffic weight corresponding to each target cluster according to each detection result.
[0059] In one embodiment, performing anomaly detection on each target cluster to obtain the detection result corresponding to each target cluster includes: for each target cluster among multiple target clusters, performing anomaly detection on the current target cluster to obtain an initial detection result; when the initial detection result indicates an anomaly, performing node detection on the current target cluster a preset number of times at a preset time interval to obtain the detection result of the current target cluster; when the initial detection result indicates normal, using the initial detection result as the detection result of the current target cluster.
[0060] Specifically, the server includes a detection module, such as the Upstream module. When a target cluster fails, the application services in the target cluster cannot be accessed by the outside world. Therefore, it is necessary for the detection module to perform anomaly detection on each target cluster among multiple target clusters to obtain the initial detection result corresponding to the current target cluster. When the initial detection result indicates an anomaly, that is, it is detected that there is a traffic scheduling anomaly in the current target cluster. Therefore, the server can perform node detection on the current target cluster a preset number of times at a preset time interval to obtain the detection result of the current target cluster. For example, perform node detection once every 1 second, and if it is detected that all 3 times are traffic scheduling anomalies, then determine that the detection result is abnormal.
[0061] Furthermore, since the target application services in different target clusters have different priorities, when the server determines the detection result corresponding to each target cluster, the traffic weight corresponding to each target cluster can be determined in combination with the priorities of different target clusters.
[0062] In one embodiment, the server can also configure the field information in the Upstream module. For example, the interval field and the http_failures field. The field information can implement automatic kick-out operations and automatic recovery operations after a period of time when the target application service fails.
[0063] Step 206: Determine the target routing configuration information including the target configuration state and multiple traffic weights according to the preset routing configuration rules.
[0064] In one embodiment, according to the preset routing configuration rules, determining target routing configuration information including a target configuration state and multiple traffic weights includes: obtaining a routing domain name, and associating the routing domain name with a target application service according to the routing configuration rules to obtain a routing label for the target application service; searching for historical routing configuration information identical to the routing label in an artifact repository to obtain a search result, and determining the target configuration state corresponding to a service access request according to the search result; and combining the routing label, the target configuration state, and multiple traffic weights to obtain initial routing configuration information corresponding to the target application service.
[0065] Specifically, the server associates the obtained routing domain name with the routing path corresponding to the target application service according to the routing configuration rules to obtain a routing label for the target application service. Among them, the same routing label represents a routing policy for the same purpose, and the routing label can be used for routing grouping and version control. For example, when the routing configuration rule is {"host": {domain name}, "uri": {path}}, the routing label is {"host": "www.baidu.com", "uri": " / index.html"}. The server searches for historical routing configuration information identical to the routing label in the artifact repository. If historical routing configuration information identical to the routing label can be found, it indicates that the configuration has been modified based on the historical routing configuration information; if historical routing configuration information identical to the routing label cannot be found, it indicates that the routing configuration information to be generated this time is the first formed routing configuration information. Among them, the artifact repository is used to uniformly manage routing configuration information of different versions, that is, it is used to store the routing configuration information formed after each configuration modification.
[0066] Further, when the search result is that it is found, the server can determine that the target configuration state is the release state; when the search result is that it is not found, the server can determine that the target configuration state is the offline state, etc. The server combines the routing label, the target configuration state, and multiple traffic weights to obtain initial routing configuration information corresponding to the target application service. Then the server determines whether a special event has been triggered, and processes the initial routing configuration information according to the type of the special event to obtain the target routing configuration information. Among them, the special events include that a target event occurs in the initial gateway, the target routing configuration information needs to be configured and modified, and the initial routing configuration information is the first formed routing configuration information, which can be directly stored, etc.
[0067] In one embodiment, when the initial configuration state is the release state, it indicates that the special event is that the initial routing configuration information is the first formed routing configuration information, which can be directly stored. At this time, the server uses the initial routing configuration information as the target routing configuration information.
[0068] In one embodiment, the target routing configuration information further includes routing naming, creation time, description, etc. Among them, according to the routing configuration rule of {domain name}_{version number}_{creation time}, the routing naming is determined, and the description is used to illustrate the usage scenario corresponding to the target application service.
[0069] Step 208, when the target configuration state is the target state, according to the target routing configuration information, send the service access request to each target cluster.
[0070] Among them, the target state can be the release state, and the release state indicates that the service access request can be distributed to each target cluster. The sent service access request is used to trigger the target cluster to access the target application service to obtain application data related to the target application service; the amount of application data obtained corresponds to the traffic weight in the target routing configuration information.
[0071] Specifically, the server determines the transmission path for sending the service access request to each target cluster according to the IP address in the target routing configuration information, and sends the service access request to each target cluster respectively according to the transmission path and the traffic weight. As Figure 4 shown, Figure 4 is a schematic diagram of the principle of sending a service access request. Among them, if the initial cluster is the first container cluster, the target clusters can be determined as the third container cluster and the fourth container cluster, the traffic weight corresponding to the third container cluster is 99%, and the traffic weight corresponding to the fourth container cluster is 1%, etc.
[0072] In one embodiment, when the target entry module in the target cluster receives the service access request, it reads the application data during the operation of the target application service according to the corresponding traffic weight.
[0073] In the above cluster traffic management method, when a service access request is received, the target application service in the service access request and multiple target clusters where the target application service is located can be determined. Then, by performing anomaly detection on each target cluster, the detection result corresponding to each target cluster can be obtained, and based on each detection result, the traffic weight corresponding to each target cluster can be determined. In this way, according to the preset routing configuration rules, the target routing configuration information including the target configuration state and multiple traffic weights can be determined. When the target configuration state is the target state, the service access request can be directly sent to each target cluster according to the target routing configuration information. Since in this application, after actively performing anomaly detection on the target cluster, the traffic weight can be directly determined. Compared with the traditional method of passively modifying the configuration file after an anomaly occurs in the container cluster, this application ensures that the sending process of the access request is not interrupted and avoids the delay in accessing the target application service by the target cluster. Therefore, the scheduling of the access request is made more intelligent; at the same time, through the accurately obtained target routing configuration information, the amount of application data accessed can correspond to the traffic weight in the target routing configuration information, improving the flexibility of sending the access request.
[0074] In one embodiment, determining the traffic weight corresponding to each target cluster according to each detection result includes: determining the initial weight corresponding to each target cluster according to the preset gateway parameters; when each detection result indicates normal, using each initial weight as the traffic weight corresponding to the corresponding target cluster; when any one of the detection results indicates an anomaly, using the preset weight as the traffic weight of the target cluster whose detection result indicates an anomaly; and obtaining the traffic weight of the target cluster whose detection result indicates normal according to multiple initial weights and the preset weight.
[0075] Specifically, the Upstream module in the server can be used for intelligent traffic scheduling. By configuring the gateway parameters in the Upstream module, the initial weight corresponding to each target cluster can be determined, that is, the weight of the target entry module of each destination cluster, so as to control the proportion of traffic scheduling. Refer to Figure 4 As shown, the gateway parameters preconfigured in the Upstream module of the first container cluster respectively point to the entry module of the third container cluster and the entry module of the fourth container cluster, and the initial weight corresponding to the third container cluster is 99% and the initial weight corresponding to the fourth container cluster is 1%. Therefore, when performing anomaly detection on each target cluster and each detection result indicates normal, the server can directly use each initial weight as the traffic weight corresponding to the corresponding target cluster.
[0076] Further, the server determines that the target application services in each target cluster have different priorities, and takes the target application service in the target cluster with a higher priority as the primary service, and takes the target application service in the target cluster with a lower priority as the standby service. For example, the target application service of the third container cluster is the primary service, and the target application service of the fourth container cluster is the standby service. When the detection result corresponding to the primary service indicates an abnormality, and the access traffic cannot be scheduled to the primary service at this time, the traffic needs to be scheduled to the standby service. Therefore, the server can change the traffic weight of the primary service to a preset weight. For example, change the initial weight of 99% corresponding to the third container cluster to 2%; the server can also change the traffic weight of the primary service to the traffic weight corresponding to the standby service. For example, change 99% to the initial weight of 1% corresponding to the fourth container cluster, etc.
[0077] Since the total weight can be determined to be 1 based on multiple initial weights, the difference between the total weight and the preset weight can be used as the traffic weight of the target cluster whose detection result indicates normal, that is, the traffic weight corresponding to the standby server. For example, use 98% as the traffic weight corresponding to the standby server; the server can also change the traffic weight of the standby server to the traffic weight corresponding to the primary service. For example, change 1% to the initial weight of 99% corresponding to the third container cluster, etc. Therefore, the primary server after the traffic weight change serves as the new standby server, and the standby server after the traffic weight change serves as the new primary server.
[0078] In this embodiment, by performing anomaly detection on each target cluster, the traffic weight corresponding to each target cluster is accurately obtained, and when the detection result is abnormal, according to the priority of the target application service in the target cluster, the scheduling ratio of the traffic outflow direction of the cluster can be freely increased or decreased; at the same time, by performing routing configuration with a mutual primary-standby relationship on different target clusters, the access traffic can be smoothly migrated among the target clusters with a primary-standby relationship. Therefore, the loss rate of traffic scheduling for service access is reduced, the potential safety hazard caused by the lack of active anomaly detection is avoided, the stability of cross-container cluster access is improved, and the intelligent scheduling of access requests is also realized.
[0079] In one of the embodiments, as Figure 5 shown, Figure 5 is a schematic flow diagram for determining the target routing configuration information. According to the preset routing configuration rules, determine the target routing configuration information including the target configuration state and multiple traffic weights, including the following steps:
[0080] Step 502, generate the initial routing configuration information according to the preset routing configuration rules.
[0081] Among them, for the specific implementation steps of generating the initial routing configuration information, reference can be made to the specific process in step 206, and details are not described herein again in this application.
[0082] Step 504, in response to a modification configuration operation for the initial routing configuration information, obtain the modified routing configuration information.
[0083] Among them, the initial routing configuration information includes an initial version number and a target configuration state; the modified routing configuration information includes a modified version number, a modified configuration state, and a modified routing label; the modified version number is generated through routing configuration rules and the initial version number.
[0084] Specifically, as Figure 6 shown, Figure 6 is a timing diagram for determining the target routing configuration information. When the terminal where the initial application service is located responds to the user's modification configuration operation, configuration modification is performed based on the initial routing configuration information. Among them, the configuration modification includes changes in the target cluster, changes in the target application service, modification of the IP address of the target application service, and adjustment of the access traffic ratio of the target cluster, etc. For each modification based on the target application service in the initial routing configuration information, a single modified routing configuration information can be newly added, and then the server will add the modified routing configuration information newly added each time.
[0085] In one embodiment, each time a configuration modification is performed, the server will increment itself based on the initial version number through routing configuration rules, so as to generate a new modified version number. The server uses the routing configuration rule of {domain name}_{version number}_{creation time} to name the newly added routing policy, that is, {host}_{version}_{createTime}, where the routing policies in the same group have the same routing label.
[0086] In one embodiment, after each configuration modification is completed, the server exports the configuration file corresponding to the latest modified routing configuration information. The content format of the configuration file is json, and the naming format is "{container cluster name}_full - volume APISIX routing configuration_{version number}_{time}.json". The specified artifact library path in the container cluster is " / app / apisix / {version number} / {container cluster name}_full - volume APISIX routing configuration_{incremented version number}_{time}.json".
[0087] In one embodiment, the server also includes a latest file, that is, the Latest file. The Latest file is used to save the modified version number in the modified routing configuration information obtained after the last modification of the initial routing configuration information, that is, the latest version number; that is, each time a configuration modification is performed, the version number in the Latest file needs to be updated to ensure that when it is necessary to roll back the routing configuration information corresponding to the version number, it is the target routing configuration information after the latest modification.
[0088] Step 506: Update the target configuration status in the initial routing configuration information to the offline status, and update the modified configuration status in the modified routing configuration information to the published status.
[0089] Specifically, the server can query the routing configuration information identical to the modified routing label from the artifact repository through {domain name}_{path}, that is, determine the routing configuration information in the same group as the modified routing configuration information and with the latest version number, that is, determine the routing configuration information that is the previous version of the modified routing configuration information. When the initial routing configuration information is the routing configuration information with the latest version number, the server updates the target configuration status in the initial routing configuration information to the offline status, that is, sets status to 0, and updates the modified configuration status in the modified routing configuration information to the published status, that is, sets status to 1.
[0090] Step 508: Replace the initial routing configuration information with the modified routing configuration information in the published status to obtain the target routing configuration information.
[0091] Among them, since the modified configuration status in the modified routing configuration information has been updated to the published status, it indicates that it can be used as the target routing configuration information, and the service access request can be distributed to each target cluster according to the target routing configuration information.
[0092] In one embodiment, as shown in Figure 6 the server stores the target routing configuration information in the artifact repository and backs up the information in the artifact repository in the data warehouse. Among them, the data warehouse can be a Git repository, and the backed-up information includes the configuration file corresponding to the modified routing configuration information and the Latest file.
[0093] In this embodiment, for this special event that the target routing configuration information needs to be configured and modified, through the preset routing configuration rules, the configuration can be accurately modified on the basis of the initial routing configuration information. After determining the routing configuration information of the previous version in the same group as the modified routing configuration information, the modified configuration status is updated to the published status, so that the single routing configuration information referred to by the service access request is the modified routing configuration information with the latest version number, improving the accuracy of subsequent sending of service access requests; at the same time, determining the target routing configuration information through the version number also makes the implementation process more concise and efficient.
[0094] In addition, since the newly added modified routing configuration information takes effect immediately after being saved, there is no need to restart the initial gateway or trigger it from the initial application service at the source, that is, a hot deployment of traffic routing switching is achieved, reducing the possibility of traffic access interruption and improving the efficiency of sending service access requests.
[0095] In one embodiment, according to the preset routing configuration rules, determining the target routing configuration information including the target configuration state and multiple traffic weights includes: generating the initial routing configuration information according to the preset routing configuration rules; when a target event occurs in the initial gateway in the container cluster, looking up the historical routing configuration information with the same routing label from the data warehouse; updating the historical configuration state from the offline state to the published state, and replacing the initial routing configuration information with the historical routing configuration information in the published state to obtain the target routing configuration information.
[0096] Among them, the initial routing configuration information includes the routing label; the historical routing configuration information includes the historical configuration state. For the specific implementation steps of generating the initial routing configuration information, reference can be made to the specific process in step 206, which will not be elaborated in this application.
[0097] Specifically, as shown in Figure 6 When a target event occurs in the initial gateway in the container cluster, for example, after the initial gateway fails and is restarted; after adding other gateways, gateway migration is required, etc. The server looks up the historical routing configuration information with the same routing label from the data warehouse, that is, the historical routing configuration information in the same group as the initial routing configuration information and with the latest version number, so that the historical routing configuration information is restored in the artifact repository, and the server rolls back the historical routing configuration information. The server updates the historical configuration state from the offline state to the published state, that is, sets status from 0 to 1, and uses the historical routing configuration in the published state as the target routing configuration information.
[0098] In this embodiment, for this special event of the target event occurring in the initial gateway, through the preset routing configuration rules, when the historical routing configuration information with the same routing label is found, the version of the historical routing configuration information can be quickly rolled back, realizing the smooth scheduling of traffic access, ensuring the further management of the configuration information, and also improving the accuracy of sending service access requests according to the rolled-back historical routing configuration information subsequently.
[0099] It should be understood that although the steps in the flowcharts involved in the above embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0100] Based on the same inventive concept, an embodiment of the present application further provides a cluster traffic management device for implementing the above-mentioned cluster traffic management method. The implementation solution provided by this device to solve problems is similar to the implementation solution described in the above method. Therefore, the specific limitations in one or more embodiments of the cluster traffic management device provided below can refer to the limitations on the cluster traffic management method in the above text, and will not be repeated here.
[0101] In one embodiment, as Figure 7 shown, a cluster traffic management device 700 is provided, including: a request receiving module 702, an information determining module 704, and a request sending module 706, where:
[0102] The request receiving module 702 is configured to determine a target application service in the service access request and multiple target clusters where the target application service is located when receiving the service access request.
[0103] The information determining module 704 is configured to perform anomaly detection on each target cluster to obtain a detection result corresponding to each target cluster, and determine a traffic weight corresponding to each target cluster according to each detection result; determine target routing configuration information including a target configuration state and multiple traffic weights according to a preset routing configuration rule.
[0104] The request sending module 706 is configured to send the service access request to each target cluster according to the target routing configuration information when the target configuration state is the target state; where the sent service access request is used to trigger the target cluster to access the target application service to obtain application data related to the target application service; the amount of application data obtained corresponds to the traffic weight in the target routing configuration information.
[0105] In one embodiment, the information determination module 704 further includes an anomaly detection module 7041, which is configured to perform anomaly detection on each target cluster among a plurality of target clusters to obtain an initial detection result; when the initial detection result indicates an anomaly, perform node detection on the current target cluster a preset number of times at a preset time interval to obtain the detection result of the current target cluster; when the initial detection result indicates normal, use the initial detection result as the detection result of the current target cluster.
[0106] In one embodiment, the information determination module 704 further includes a weight determination module 7042, which is configured to determine the respective initial weights corresponding to each target cluster according to preset gateway parameters; when all the detection results indicate normal, use each initial weight as the traffic weight corresponding to the respective target cluster; when any one of the detection results indicates an anomaly, use a preset weight as the traffic weight of the target cluster whose detection result indicates an anomaly; obtain the traffic weights of the target clusters whose detection results indicate normal according to a plurality of initial weights and the preset weight.
[0107] In one embodiment, the information determination module 704 is further configured to obtain a routing domain name, and associate the routing domain name with the target application service according to a routing configuration rule to obtain a routing label of the target application service; search for historical routing configuration information identical to the routing label in an artifact repository to obtain a search result, and determine a target configuration status corresponding to a service access request according to the search result; synthesize the routing label, the target configuration status, and a plurality of traffic weights to obtain initial routing configuration information corresponding to the target application service; when the target configuration status is a release status, use the initial routing configuration information as the target routing configuration information.
[0108] In one embodiment, the information determination module 704 further includes a configuration modification module 7043, which is configured to generate initial routing configuration information according to a preset routing configuration rule; in response to a modification configuration operation on the initial routing configuration information, obtain modified routing configuration information; the modified routing configuration information includes a modified version number and a modified configuration status; the modified version number is generated through the routing configuration rule and an initial version number; update the target configuration status in the initial routing configuration information to an offline status, and update the modified configuration status in the modified routing configuration information to a release status; replace the initial routing configuration information with the modified routing configuration information in the release status to obtain the target routing configuration information.
[0109] In one embodiment, the information determination module 704 is further configured to generate initial routing configuration information according to a preset routing configuration rule; the initial routing configuration information includes a routing label; when a target event occurs to an initial gateway in the container cluster, look up historical routing configuration information with the same routing label from a data warehouse; the historical routing configuration information includes a historical configuration status; update the historical configuration status from an offline status to a published status, and replace the initial routing configuration information with the historical routing configuration information in the published status to obtain target routing configuration information.
[0110] Each module in the above cluster traffic management device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or stored in a memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0111] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 8 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. 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 cluster traffic management data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication 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, it implements a cluster traffic management method.
[0112] Those skilled in the art can understand that Figure 8 the structure shown in is only a block diagram of some structures 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 some components, or have different component arrangements.
[0113] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0114] In one of the embodiments, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, implements the steps in the above-described method embodiments.
[0115] In one of the embodiments, a computer program product or a computer program is provided. The computer program product or the computer program includes computer instructions which are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to execute the steps in the above-described method embodiments.
[0116] Those of ordinary skill in the art can understand that all or part of the processes of implementing the above method embodiments can be completed by instructing relevant hardware through a computer program. 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 above method embodiments. Among them, any reference to a memory, a database, or other media provided in the various embodiments of the present application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRAM), magnetoresistive random access memories (MRAM), ferroelectric random access memories (FRAM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memory (RAM) or external cache memories, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the various embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the various embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logics, data processing logics based on quantum computing, etc., without limitation.
[0117] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, 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, it should be considered as the scope recorded in this specification.
[0118] The above embodiments only express several implementation manners of the present application, and their descriptions are relatively specific and detailed. However, it should not be understood as a limitation to the scope of the patent of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several deformations and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method for cluster traffic management, characterized in that, The method includes: When receiving a service access request, determining a target application service in the service access request and multiple target clusters where the target application service is located; Performing anomaly detection on each of the target clusters to obtain a detection result corresponding to each of the target clusters, and determining a traffic weight corresponding to each of the target clusters according to the detection results; Determining target routing configuration information including a target configuration state and multiple traffic weights according to a preset routing configuration rule, including: obtaining a routing domain name, and associating the routing domain name with the target application service according to the routing configuration rule to obtain a routing label of the target application service; searching for historical routing configuration information identical to the routing label in an artifact library to obtain a search result, and determining the target configuration state corresponding to the service access request according to the search result; the target configuration state includes a release state and a down state; When the target configuration state is the release state, determining a transmission path for sending the service access request to each of the target clusters according to an IP address in the target routing configuration information, and sending the service access request to each of the target clusters respectively according to the transmission path and multiple traffic weights; Wherein, the sent service access request is used to trigger the target cluster to access the target application service to obtain application data related to the target application service; the amount of the application data corresponds to the traffic weight in the target routing configuration information.
2. The method according to claim 1, wherein The performing anomaly detection on each of the target clusters to obtain a detection result corresponding to each of the target clusters includes: For each of the multiple target clusters, performing anomaly detection on the current target cluster to obtain an initial detection result; When the initial detection result indicates an anomaly, performing node detection on the current target cluster a preset number of times at a preset time interval to obtain the detection result of the current target cluster; When the initial detection result indicates normal, using the initial detection result as the detection result of the current target cluster.
3. The method according to claim 1, wherein The determining a traffic weight corresponding to each of the target clusters according to the detection results includes: Determining an initial weight corresponding to each of the target clusters according to a preset gateway parameter; When all the detection results indicate normal, using each of the initial weights as the traffic weight corresponding to the corresponding target cluster; When any one of the detection results indicates an anomaly, using a preset weight as the traffic weight of the target cluster whose detection result indicates an anomaly; Obtaining the traffic weight of the target cluster whose detection result indicates normal according to multiple initial weights and the preset weight.
4. The method according to claim 1, characterized in that The determining target routing configuration information including a target configuration state and multiple traffic weights according to a preset routing configuration rule includes: Combining the routing label, the target configuration state and multiple traffic weights to obtain initial routing configuration information corresponding to the target application service; When the target configuration state is the release state, use the initial routing configuration information as the target routing configuration information.
5. The method according to claim 1, characterized in that, The determining the target routing configuration information including the target configuration state and multiple traffic weights according to the preset routing configuration rules includes: Generating initial routing configuration information according to the preset routing configuration rules; the initial routing configuration information includes an initial version number and a target configuration state; In response to a modification configuration operation for the initial routing configuration information, obtaining modified routing configuration information; the modified routing configuration information includes a modified version number and a modified configuration state; the modified version number is generated through the routing configuration rules and the initial version number; Updating the target configuration state in the initial routing configuration information to the offline state, and updating the modified configuration state in the modified routing configuration information to the release state; Replacing the initial routing configuration information with the modified routing configuration information in the release state to obtain the target routing configuration information.
6. The method according to claim 1, wherein The determining the target routing configuration information including the target configuration state and multiple traffic weights according to the preset routing configuration rules includes: Generating initial routing configuration information according to the preset routing configuration rules; the initial routing configuration information includes a routing label; When a target event occurs in the initial gateway in the container cluster, looking up historical routing configuration information with the same routing label in the data warehouse; the historical routing configuration information includes a historical configuration state; Updating the historical configuration state from the offline state to the release state, and replacing the initial routing configuration information with the historical routing configuration information in the release state to obtain the target routing configuration information; The method further includes: storing the target routing configuration information in the artifact library, and backing up the information in the artifact library in the data warehouse.
7. A cluster traffic management device, characterized in that, The apparatus includes: A request receiving module, configured to determine a target application service in the service access request and multiple target clusters where the target application service is located when receiving the service access request; An information determining module, configured to perform anomaly detection on each of the target clusters to obtain a detection result corresponding to each of the target clusters, and determine a traffic weight corresponding to each of the target clusters according to each of the detection results; the determining the target routing configuration information including the target configuration state and multiple traffic weights according to the preset routing configuration rules includes: obtaining a routing domain name, and associating the routing domain name with the target application service according to the routing configuration rules to obtain a routing label of the target application service; looking up historical routing configuration information with the same routing label in the artifact library to obtain a lookup result, and determining a target configuration state corresponding to the service access request according to the lookup result; the target configuration state includes a release state and an offline state; A request sending module, configured to, when the target configuration state is the release state, determine a transmission path for sending the service access request to each of the target clusters according to the IP addresses in the target routing configuration information, and send the service access request to each of the target clusters respectively according to the transmission path and multiple traffic weights; wherein the sent service access request is used to trigger the target clusters to access the target application service to obtain application data related to the target application service; and the data volume of the application data corresponds to the traffic weights in the target routing configuration information.
8. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. 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 6 are implemented.
10. A computer program product, comprising a computer program, 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 6 are implemented.
Citation Information
Patent Citations
Micro-service traffic scheduling method and related components
CN112333096A
Access flow forwarding method, cluster management method and related devices
CN112565327A