Fuse current limiting method, device and readable storage medium

By obtaining container information from the API Server components of the K8s cluster, calculating the replica availability rate in real time, and generating current limit or fuse configurations, the problems of long execution time and inaccurate results in traditional technology are solved, and real-time and reliable fuse current limit are achieved.

CN118827457BActive Publication Date: 2024-11-19E SURFING VISION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411297224.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2024-11-19
Estimated Expiration
2044-09-18

AI Technical Summary

Technical Problem

In Kubernetes cluster, the traditional circuit breaking current limiting mechanism cannot realize circuit breaking current limiting in real time and reliably due to querying metric values ​​from external monitoring components of the cluster.

Method used

By directly obtaining the total number of replicas of the target container and the number of replicas in ready state from API Server components in the K8s cluster, calculating the replica availability rate in real time, generating a current limiting or fuse configuration based on the user-configured policy metrics and thresholds, and applying it directly to the container business to avoid external monitoring component query.

Benefits of technology

It reduces execution time, improves the accuracy of the results, realizes real-time and reliable fuse current limiting, avoids the risk of misreporting caused by monitoring component query, and improves the sensitivity of the fuse current limiting mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118827457B_ABST
    Figure CN118827457B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device and readable storage medium for circuit breaking and current limiting. The method includes: obtaining the total number of replicas corresponding to the target container and the number of replicas in the ready state from the API Server component in the K8s cluster; obtaining the first indicator value of the policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes the replica availability rate; if the first indicator value is lower than the first policy indicator threshold of the current limiting policy corresponding to the replica availability rate and is not lower than the second policy indicator threshold of the corresponding circuit breaking policy, then the current limiting configuration corresponding to the target container is generated; the current limiting configuration is used to limit the flow of the business corresponding to the target container; if the first indicator value is lower than the second policy indicator threshold, then the circuit breaking configuration corresponding to the target container is generated. The present method can realize circuit breaking and current limiting in real time and reliably; the circuit breaking configuration is used to fuse the business corresponding to the target container.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing technology, and in particular to a circuit breaker and current limiting method, device, and readable storage medium. Background Art

[0002] In recent years, cloud native technology based on Kubernetes (K8s for short) has developed rapidly. Gartner predicts that by 2025, cloud native platforms will serve as the basis for more than 95% of new digital initiatives, and most applications will be deployed in cloud native environments, and application microservices can be implemented through cloud native technologies.

[0003] In traditional technology, the circuit breaker and current limiting mechanism is a key capability in application microservice governance. The circuit breaker and current limiting mechanism is implemented by the Ingress controller, which can provide circuit breaker or current limiting strategies such as connection number circuit breaker and current limiting, QPS (Queries Per Second, the number of requests processed per second) circuit breaker and current limiting, and connection timeout circuit breaker and current limiting, so as to determine whether to perform circuit breaker or current limiting after executing the corresponding strategy.

[0004] However, when executing a circuit breaker or current limiting strategy, querying the indicator value from the monitoring component outside the K8s cluster will result in long execution time and inaccurate execution results. Summary of the invention

[0005] Based on this, it is necessary to provide a fuse current limiting method, device and readable storage medium that can implement fuse current limiting in real time and reliably to address the above technical problems.

[0006] In a first aspect, the present application provides a fusing and current limiting method, comprising:

[0007] Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API (Application Programming Interface) Server component in the K8s cluster;

[0008] Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0009] If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container;

[0010] If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0011] In one embodiment, obtaining the total number of replicas corresponding to the target container and the number of replicas in a ready state from the API Server component in the K8s cluster includes:

[0012] Listen to the API Server component in the K8s cluster to obtain the total number of replicas corresponding to the target container and the number of replicas in the ready state.

[0013] In one embodiment, the step of obtaining the total number of replicas and the number of replicas in a ready state corresponding to the target container from the API Server component in the K8s cluster includes:

[0014] In response to monitoring a K8s event, determining whether the K8s event is a target event based on the resource information to which the K8s event belongs; the target event includes a resource change event of the Ingress resource corresponding to the target container or a state change event corresponding to the target container;

[0015] If it is a target event, the corresponding device operation is performed.

[0016] In one embodiment, performing the corresponding device operation includes:

[0017] If the target event is a resource change event of the Ingress resource corresponding to the target container, the policy indicator threshold of the current limiting strategy corresponding to the replica availability rate is obtained from the changed Ingress resource to obtain the first policy indicator threshold, and the policy indicator threshold of the circuit breaker strategy corresponding to the replica availability rate is obtained to obtain the second policy indicator threshold.

[0018] In one embodiment, performing the corresponding device operation includes:

[0019] If the target event is the state change event, determine whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a fuse policy;

[0020] If a limited flow strategy or a circuit breaker strategy is configured, determining whether the state change event is an abnormal event;

[0021] If it is an abnormal event, the total number of replicas corresponding to the target container and the number of replicas in the ready state are obtained from the API Server component in the K8s cluster.

[0022] In one of the embodiments, determining whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a fuse policy includes:

[0023] Based on the resource information carried by the state change event, search for the Deployment resource corresponding to the Pod instance corresponding to the target container;

[0024] Determine the Ingress resource corresponding to the Deployment resource;

[0025] Determine whether the Ingress resource is configured with a limited flow policy or a circuit breaker policy.

[0026] In one embodiment, determining whether the state change event is an abnormal event includes:

[0027] Determine whether the type carried by the state change event is the target type;

[0028] If it is a non-target type, query at least one historical state change event corresponding to the target container;

[0029] If the types of the historical state change events are all non-target types, the state change event is determined to be an abnormal event.

[0030] In one embodiment, the strategy indicator further includes at least one other strategy indicator, and the method further includes:

[0031] Polling from an external monitoring component at a preset time interval to obtain a second indicator value of the other policy indicator;

[0032] After each polling of the second indicator value:

[0033] If both the first indicator value and the second indicator value are not lower than the indicator value of the policy indicator threshold of the corresponding fuse policy, and there are at least two indicator values ​​lower than the policy indicator threshold of the corresponding current limiting policy, then a fuse configuration corresponding to the target container is generated.

[0034] In a second aspect, the present application also provides a fuse current limiting device, comprising:

[0035] The first processing module is used to obtain the total number of replicas corresponding to the target container and the number of replicas in the ready state from the API Server component in the K8s cluster;

[0036] A second processing module, configured to obtain a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0037] The first generation module is used to generate a current limiting configuration corresponding to the target container if the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability rate and is not lower than the second policy indicator threshold of the corresponding fuse policy; the current limiting strategy and the fuse policy both include user-configured policy indicators, policy indicator thresholds and corresponding configuration generation conditions; the current limiting configuration is used to limit the business corresponding to the target container; if the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the business corresponding to the target container.

[0038] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0039] Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster;

[0040] Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0041] If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container;

[0042] If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0043] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0044] Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster;

[0045] Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0046] If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container;

[0047] If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0048] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0049] Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster;

[0050] Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0051] If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container;

[0052] If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0053] The above-mentioned circuit breaker and current limiting method, device and readable storage medium obtain the total number of replicas and the number of replicas in the ready state from the API Server component in the K8s cluster, thereby obtaining the first indicator value, thereby avoiding obtaining the indicator value from the monitoring component outside the K8s cluster, thereby reducing the execution time and making the execution result more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0055] Figure 1 This is an application environment diagram of a fuse current limiting method in an embodiment;

[0056] Figure 2 A schematic diagram of a flow chart of a fusing and current limiting method in an embodiment;

[0057] Figure 3 A system structure block diagram of a fuse current limiting method in an embodiment;

[0058] Figure 4 A schematic diagram of a flow chart of a fusing and current limiting method in another embodiment;

[0059] Figure 5 is a structural block diagram of a fuse current limiting device in one embodiment;

[0060] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0062] For ease of understanding, some terms involved in the embodiments of the present application are explained below:

[0063] Kubernetes (K8s for short): An open source system for automatically deploying, scaling, and managing "containerized applications." Designed by Google and donated to the Cloud Native Computing Foundation, the system aims to provide "a platform for automatically deploying, scaling, and running application containers across host clusters."

[0064] Container: A lightweight, portable, and self-contained software unit that packages an application and its dependencies so that it can run in any environment. This packaging enables the container to be ported across different machines or cloud platforms without additional configuration or modification. In K8s, it generally refers to Docker containers.

[0065] Pod: In K8s, Pod is the smallest unit for deploying, managing, and scaling applications. A Pod can contain at least one container, which share the same network namespace, storage volume, and IPC (Inter-Process Communication) namespace. Containers in a Pod usually work closely together to complete a task or application.

[0066] Replica: In K8s, replica is an important concept, which is mainly used to improve the reliability and fault tolerance of applications. Specifically, a replica refers to a group of identical Pod instances running in a K8s cluster, which are managed through specific controller objects (such as ReplicaSet, Deployment, etc.) to ensure high availability and load balancing of applications.

[0067] Resource Objects: In K8s, resource objects are the core concept for defining and configuring various components and resources in a cluster. These resource objects describe applications, services, configurations, etc., and are managed through the K8s API. In K8s, Ingress and Deployment are two important resource objects, which are used to manage external access routing and internal application deployment respectively.

[0068] Ingress: A resource object in K8s that manages HTTP (HyperText Transfer Protocol) and HTTPS (Hypertext TransferProtocol Secure) routing from outside the cluster to internal services. By defining Ingress resources, you can flexibly control how to route external requests to different services within the cluster. The Ingress resource itself does not handle traffic routing, but as a set of declarative configurations, it tells the K8s cluster how to handle external traffic entering the cluster.

[0069] Deployment: A resource object in K8s that provides a declarative way to define and manage the desired state of an application. It ensures that the actual state of the application is consistent with the desired state. As a controller, it is responsible for creating, updating, and deleting Pods (and indirectly managing Pods through ReplicaSet) to ensure high availability and consistency of the application.

[0070] API Server: A component of the K8s control plane that exposes the K8s API and handles receiving requests.

[0071] List / Watch: An important resource monitoring and event processing mechanism in K8s, which ensures the real-time, reliability, sequentiality, and high performance of messages, and lays a good foundation for declarative APIs.

[0072] Informer: A core toolkit in the K8s client (client-go) library, used to monitor and manage the state changes of resource objects in the K8s cluster efficiently and in real time. Specifically, Informer is a client with a local cache and index mechanism, which can register an event handler (EventHandler) to monitor the addition, deletion, and modification of resource objects (such as Ingress, Deployment, etc.) on the API Server.

[0073] Ingress controller: A very important component in K8s, it is responsible for routing external HTTP and HTTPS traffic to services inside the cluster. The Ingress controller is a dedicated load balancer for K8s (and other containerized) environments. It abstracts the complexity of K8s application traffic routing and builds a bridge between K8s services and external services. The implementation of the Ingress controller can be based on a variety of different software, the most commonly used of which are Nginx and Traefik. Taking Ingress-Nginx as an example, it converts the declarative configuration in the Ingress resource into Nginx configuration, and uses Nginx as a reverse proxy and load balancer to handle external traffic.

[0074] Reverse proxy: The request is sent from the client and directly reaches the reverse proxy server, which then forwards the request to the server in the internal network (such as the K8s cluster). For the client, the reverse proxy server is like the target server itself, and the client does not need to know the address of the actual server. Since the reverse proxy is exactly the opposite of the forward proxy in terms of request flow and proxy object (i.e. "reverse"), it is named reverse proxy. The forward proxy is the proxy client to request the server, while the reverse proxy is the proxy server to respond to the client's request.

[0075] For example, the fuse current limiting method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, server 102 communicates with cluster 104 through the network. The data storage system can store data that cluster 104 needs to process. The data storage system can be integrated on cluster 104, or it can be placed on the cloud or other network servers. Among them, server 102 can be but is not limited to Nginx server and Traefik server. Cluster 104 is a distributed system composed of multiple physical servers.

[0076] As mentioned in the background technology, querying the indicator value from the monitoring component outside the K8s cluster will result in long execution time and inaccurate execution results. The applicant found that since the indicator value needs to be queried from the monitoring component, the query and response process is relatively complicated, which makes it impossible to obtain the indicator value in real time, and the monitoring component needs to collect corresponding data to generate the indicator value, which may cause risks such as missed collection and missed reporting when collecting the corresponding data.

[0077] To solve the above problems, in an exemplary embodiment, Figure 2 As shown, a fuse current limiting method is provided, which is applied to Figure 1 The server 102 in the example is used as an example to illustrate, including the following steps 202 to 208. Among them:

[0078] Step 202, obtain the total number of replicas corresponding to the target container and the number of replicas in the ready state from the API Server component in the K8s cluster.

[0079] The total number of replicas can be obtained through the "replicas" attribute of the "spec" field of the resource object of the Deployment resource, that is, by calling Deployment.spec.replicas; the number of replicas in the ready state can be obtained through the "readyReplicas" attribute of the "status" field of the resource object of the Deployment resource, that is, by calling Deployment.status.readyReplicas.

[0080] For example, if the return parameter of Deployment.spec.replicas is 20, the total number of replicas is 20; if the return parameter of Deployment.status.readyReplicas is 15, the number of replicas in the ready state is 15.

[0081] Among them, the API Server component is a component inside the K8s cluster. The process of its providing data is basically delay-free, and there is no risk of information omission or underreporting such as in the monitoring component.

[0082] The monitoring component can monitor traffic, and the indirect indicators of the traffic include but are not limited to the number of connections, QPS, latency, and request error rate. The monitoring component can be Prometheus.

[0083] It should be noted that the total number of replicas and the number of replicas can be directly provided by the API Server component, while data such as the number of connections, QPS, and connection timeout cannot be directly provided by the API Server component or even the K8s cluster, but need to be provided indirectly by the monitoring component. On this basis, this method does not need to query the corresponding data from the monitoring component, avoiding the complex query and response process, so that the first indicator value can be obtained in real time; and because the corresponding data indirectly provided by the monitoring component is not required to generate the first indicator value, the risk of missing or missing data when the monitoring component collects the corresponding data is avoided, making the first indicator value more reliable.

[0084] Step 204: obtain a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate.

[0085] The replica availability rate is the ratio of the number of replicas in the ready state to the total number of replicas. According to the association between containers and replicas, a replica is a Pod replica, and a Pod contains at least one container, and the replica availability rate refers to the availability rate of the Pod replica that contains the target container.

[0086] The policy indicator refers to the judgment indicator used in the circuit breaker policy or the current limiting policy to determine whether to trigger the corresponding policy. The circuit breaker policy or the current limiting policy is provided by the Ingress resource corresponding to the target container, and the Ingress resource defines the traffic rules of the target container.

[0087] Step 206: If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability rate and is not lower than the second policy indicator threshold of the corresponding fuse policy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse policy include user-configured policy indicators, policy indicator thresholds, and corresponding configuration generation conditions; the current limiting configuration is used to limit the business corresponding to the target container.

[0088] Among them, for the current limiting strategy, the generation condition refers to the first indicator value being lower than the first strategy indicator threshold corresponding to the replica availability and not lower than the second strategy indicator threshold of the corresponding circuit breaker strategy; for the circuit breaker strategy, the generation condition refers to the first indicator value being lower than the second strategy indicator threshold. For example, if the first strategy indicator threshold is 80% and the second strategy indicator threshold is 60%, then when the first indicator value is between 60% and 80%, the generation condition corresponding to the current limiting strategy is triggered, and when the first indicator value is lower than 60%, the generation condition corresponding to the circuit breaker strategy is triggered.

[0089] Among them, current limiting is implemented by the reverse proxy server according to the fuse configuration, that is, after the generation conditions in the fuse policy are triggered, the current limiting configuration will be generated and the original configuration in the reverse proxy server will be updated (such as unlimited); accordingly, the fuse of the service is implemented by the reverse proxy server according to the fuse configuration, that is, after the generation conditions in the fuse policy are triggered, the fuse configuration will be generated and the original configuration in the reverse proxy server (such as current limiting configuration) will be updated.

[0090] The fuse strategy and current limiting strategy refer to user-defined strategies. Users can also customize the first strategy indicator threshold and the second strategy indicator threshold. The strategy and strategy indicator threshold can be implemented by users configuring Ingress resources.

[0091] When configuring Ingress resources, users can submit configuration files in YAML (a file format) or JSON (JavaScript Object Notation, JavaScript (a scripting language) object representation) format to the K8s cluster, which is received by the API Server and changes the corresponding Ingress resources based on the configuration files. The configuration files provide detailed information, including but not limited to namespaces, container names, and policy indicator thresholds.

[0092] Among them, the namespace and container name are used to uniquely specify the container, which is equivalent to locating the full path of a container. The same container name may exist in different namespaces, so the namespace and container name are needed in the configuration file to uniquely specify the container corresponding to the Ingress resource that needs to be configured. That is, the configuration file is used to configure the Ingress resource corresponding to the corresponding container. The Ingress resource has the routing rules for the corresponding business of the container. That is, after external access arrives, the external access can reach the container through the routing rules, so that the container can provide services.

[0093] The container specified in the configuration file can be a certain container, some containers, or even all containers in the K8s cluster.

[0094] Among them, circuit breaking and current limiting refer to the business corresponding to the target container, that is, they are used to control the external access corresponding to the target container. Circuit breaking means that the target container does not provide services, and current limiting means that the target container only provides services for some external accesses, for example, it receives 100 requests and provides services for 60 of them. It can be understood that circuit breaking is more stringent in controlling external access than current limiting, that is, circuit breaking is equivalent to an upgrade of current limiting.

[0095] Exemplarily, whether the current limiting strategy is triggered is determined by the first indicator value and the first policy indicator threshold. If triggered, whether the circuit breaker strategy is triggered is determined by the first indicator value and the second policy indicator threshold. If not triggered, a current limiting configuration corresponding to the target container is generated, thereby limiting the business corresponding to the target container.

[0096] It can be understood that when the current limiting policy is not triggered, the target container serves external access normally.

[0097] Step 208: If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0098] Exemplarily, when the first indicator value is lower than the second policy indicator threshold, a service corresponding to the target container is fused by generating a fused configuration corresponding to the target container.

[0099] In this embodiment, the method obtains the total number of replicas and the number of replicas in the ready state from the API Server component in the K8s cluster, thereby obtaining the first indicator value, thereby avoiding obtaining the indicator value from a monitoring component outside the K8s cluster, thereby reducing the execution time and making the execution result more accurate.

[0100] In an exemplary embodiment, the traditional technology needs to poll the monitoring components outside the K8s cluster to obtain the corresponding data of the policy judgment indicators (such as the number of connections) corresponding to the corresponding policy, so as to calculate the indicator value through the corresponding data, and then execute the fuse policy or current limiting policy through the indicator value. Polling is queried once at a certain interval, resulting in the fuse and current limiting mechanism being not sensitive enough.

[0101] In order to solve the problem that the circuit breaker and current limiting mechanism is not sensitive enough, this embodiment obtains the corresponding data, namely the total number of replicas corresponding to the target container and the number of replicas in the ready state, by monitoring, that is, the total number of replicas corresponding to the target container and the number of replicas in the ready state are obtained from the API Server component in the K8s cluster.

[0102] Among them, monitoring is responsive monitoring, which means that system components can respond to changes in data or status in real time and automatically without external intervention or polling. For example, when a Deployment resource changes, the API Server component can generate the corresponding resource change event in time and push it to the Ingress controller. The Ingress controller can monitor and consume the resource change event in real time, and the Ingress controller does not need to obtain the resource change event through external intervention or polling. Therefore, the Ingress controller can process changes in resource objects in real time through responsive monitoring, which improves the sensitivity of the circuit breaker and current limiting mechanism.

[0103] Among them, monitoring is implemented through List / Watch. The resources monitored through List / Watch include but are not limited to Ingress resources, Service resources, EndPoint resources, Deployment resources, Configmap resources, and Event resources.

[0104] Exemplarily, the change information of the Deployment resources provided by the API Server component in the K8s cluster is obtained through List / Watch monitoring, and the total number of replicas and the number of replicas in the ready state are obtained from the change information.

[0105] In an exemplary embodiment, after a K8s event is monitored, in response to the K8s event being monitored, it is determined whether the K8s event is a target event based on the resource information to which the K8s event belongs. If it is a target event, a corresponding device operation is performed; if it is not a target event, the K8s event is processed by a corresponding processing method.

[0106] The resource information records the resources to which the K8s event belongs, such as Ingress resources and container resources.

[0107] The target event includes a resource change event of the Ingress resource corresponding to the target container or a state change event corresponding to the target container.

[0108] It should be noted that since the Ingress controller is responsible for implementing the routing rules defined in the Ingress resources, in order to achieve this, the Ingress controller needs to monitor the K8s events in the API Server through List / Watch to understand the changes of the Ingress resources in the K8s cluster in real time, and update its internal configuration according to these changes, so as to correctly route external access to the services corresponding to the containers in the cluster.

[0109] Among them, resource change events are generated due to changes in Ingress resources, which are caused by users reconfiguring Ingress resources. Reconfiguration may be reconfiguring the current limiting policy, circuit breaker policy, policy indicator threshold, etc.

[0110] Among them, state change events include normal events and abnormal events, and abnormal events include failure events and recovery events.

[0111] Among them, normal events refer to K8s events such as manual operations by operation and maintenance personnel or automatic scheduling of containers by K8s. Normal events include but are not limited to state change events caused by operations such as construction by operation and maintenance personnel, rolling upgrades of containers, expansion and reduction of capacity, configuration modification, and host failure evacuation.

[0112] Among them, the fault event is generated by the container and application health check mechanism provided by K8s when the container or application abnormality is detected.

[0113] Among them, the recovery event is generated when the container or application recovers from a fault. At this time, the replica availability of the container is greater than or equal to the policy indicator threshold corresponding to the current limiting policy, and the container or application is running normally.

[0114] It should be noted that the above step 202 is performed after the corresponding device operation is performed.

[0115] Among them, for executing corresponding equipment operations, specific processing needs to be performed for specific events. For resource change events, they can be processed through method one; for state change events, they can be processed through method two.

[0116] Method 1:

[0117] From the changed Ingress resource, obtain the policy indicator threshold of the current limiting policy corresponding to the replica availability to obtain the first policy indicator threshold, and obtain the policy indicator threshold of the circuit breaker policy corresponding to the replica availability to obtain the second policy indicator threshold.

[0118] It is understandable that after the Ingress resource is changed, the fuse strategy, current limiting strategy and corresponding policy indicator thresholds in the above step 206 and / or step 208 may change, for example, the current limiting strategy in the original Ingress resource is deleted, the policy indicator threshold corresponding to the current limiting strategy is modified, etc. Therefore, when executing step 206 and / or step 208, it is necessary to execute according to the changed Ingress resource.

[0119] Method 2:

[0120] First, determine whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a circuit breaker policy. If not, no subsequent steps are required.

[0121] Secondly, if a limited flow strategy or a circuit breaker strategy is configured, determine whether the state change event is an abnormal event; if it is a normal event, there is no need to perform subsequent steps, such as no need for current limiting or circuit breaking.

[0122] Finally, if it is an abnormal event, the total number of replicas corresponding to the target container and the number of replicas in the ready state are obtained from the API Server component in the K8s cluster.

[0123] Exemplarily, the second approach implements two-layer screening, thereby screening out state change events that do not need to be further processed, thereby improving event processing efficiency.

[0124] In one embodiment, to determine whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a circuit breaker policy, this can be achieved by searching for the Deployment resource corresponding to the Pod instance corresponding to the target container based on the resource information carried by the state change event; determining the Ingress resource corresponding to the Deployment resource; and determining whether the Ingress resource is configured with a limited flow policy or a circuit breaker policy.

[0125] Exemplarily, based on determining that the K8s event is an event corresponding to the container, the Deployment resource corresponding to the target container can be further located through the resource information. It should be noted that in the process of searching for Deployment resources and determining the corresponding Ingress resources, there is no need to directly determine the target container, that is, in this process, the target container is unknown. However, the target container is a bridge that is associated with the Deployment resource and the Ingress resource, that is, the correspondence between the Deployment resource and the Ingress resource refers to the same container.

[0126] In one embodiment, determining whether a state change event is an abnormal event includes: determining whether a type carried by the state change event is a target type; if it is a target type, determining that the state change event is a normal event; if it is a non-target type, querying at least one historical state change event corresponding to the target container; if the types of the historical state change events are all non-target types, determining that the state change event is an abnormal event; if the types of the historical state change events include the target type, determining that the state change event is an abnormal event.

[0127] The target type is Normal, and the type also includes Warning.

[0128] The query of historical status change events is done from the local cache or API Server component.

[0129] It should be noted that the reason for querying historical status change events is to avoid misjudgment. Because the operation of the operation and maintenance personnel may also trigger abnormal events, but because the abnormal event is related to the operation and maintenance construction, it is not necessary to fuse or limit the flow of the business corresponding to the container. Therefore, if the status change event is directly determined as an abnormal event after determining that the type is a non-target type, it will cause misjudgment and may perform unnecessary or inappropriate configuration operations, such as generating a fuse configuration.

[0130] For example, a container status event is monitored at time T0, and the type carried by the event is the target type. Another container status event is monitored at time T5, and the type carried by the other container status event is a non-target type. The reason carried by the other container status event is a copy change. If the other container status event is directly determined to be an abnormal event, it may cause the corresponding container's business to be fused or limited, which is obviously a misjudgment. At this time, after determining that the type carried by the other container status event is a non-target type, query at least one historical status change event corresponding to the container corresponding to the other container status event, then the container status event monitored at time T0 can be queried, and the type carried by the event at time T0 can be used to determine whether the other container status event monitored at time T5 is an abnormal event, so that an accurate judgment can be made, thereby avoiding misjudgment.

[0131] It should be noted that for historical state change events, generally speaking, K8s events are only saved for one hour in the etcd system (distributed key-value storage system) at the bottom of the K8s cluster. During this hour, normal events and abnormal events will not occur at the same time. Therefore, determining whether a state change event is an abnormal event through historical state change events can ensure the accuracy of the judgment.

[0132] In an exemplary embodiment, the policy indicator also includes at least one other policy indicator, such as the number of connections, QPS, connection timeout and other policy indicators, and the other policy indicators have corresponding current limiting policies and / or circuit breaking policies. The second indicator values ​​of the other policy indicators are obtained by traditional technology, that is, the second indicator values ​​of the other policy indicators are obtained by polling from an external monitoring component at a preset time interval.

[0133] The preset time interval can be set as needed, for example, the preset time interval is 1 second.

[0134] After each poll to the second indicator value:

[0135] If both the first indicator value and the second indicator value are not lower than the indicator value of the policy indicator threshold of the corresponding fuse policy, and there are at least two indicator values ​​lower than the policy indicator threshold of the corresponding current limiting policy, then a fuse configuration corresponding to the target container is generated.

[0136] Exemplarily, even if the indicator value does not trigger the circuit breaker policy, the current limiting can be automatically upgraded to circuit breaker.

[0137] For example, the threshold of the first policy indicator is 60%, and the threshold of the second policy indicator is 30%. The current limiting policy is to generate the corresponding current limiting configuration of the container when the first indicator value does not reach 60% but reaches 30%; the fuse policy is to generate the corresponding fuse configuration of the container when the first indicator value does not reach 30%. Other policy indicators are request error rate, and the corresponding current limiting policy is to generate the corresponding current limiting configuration of the container when the second indicator value reaches more than 10% but less than 15%, and the corresponding fuse policy is to generate the corresponding fuse configuration of the container when the second indicator value reaches 15%.

[0138] Assume that both the first indicator value and the second indicator value trigger the current limiting strategy. At this time, the business of the container can no longer be provided normally. However, since neither of the fuse strategies is triggered, the container is still providing services. The quality of the service is obviously poor. In order to isolate the impact scope of the fault, the current limiting is upgraded to fuse in this embodiment.

[0139] In one embodiment, the abnormal event is a recovery event, and the recovery event corresponds to fault recovery, that is, the indicator value may return to normal. When consuming the recovery event, if the indicator value does not trigger the current limiting strategy and the fuse strategy, and there is a current limiting configuration or a fuse configuration, then the current limiting configuration or the fuse configuration is cleared; if the indicator value triggers the current limiting strategy but does not trigger the fuse strategy, and there is a fuse configuration, then the current limiting configuration is generated and updated, so that the fuse is downgraded to current limiting.

[0140] In one embodiment, if a current limiting configuration or a fuse configuration is generated, an alarm message corresponding to the current limiting configuration or the fuse configuration is generated. The alarm message may include the alarm type (such as fuse, current limiting), the alarm reason (such as low replica availability), etc. The alarm message is used to notify the operation and maintenance personnel to perform corresponding processing, that is, to handle the fault corresponding to the alarm message.

[0141] In an exemplary embodiment, the Ingress controller can be deployed in a K8s cluster or in other network servers independent of the K8s cluster.

[0142] like Figure 3As shown, the circuit breaker and current limiting method is applied to the ingress controller (Ingress controller) to implement some functions of the Ingress controller. The Ingress controller listens to the interface service component (API Server component) in the server cluster (K8s cluster) through the listener (Informer), so as to obtain the K8s event pushed by the API Server component in real time, and push the K8s event to the event queue. The controller consumes the K8s event cached in the event queue. When it is necessary to generate the circuit breaker configuration or current limiting configuration corresponding to the container, the current limiting configuration is generated through the static configuration generation component, and the circuit breaker configuration is generated through the dynamic configuration generation component. Among them, after the configuration is generated, for the current limiting configuration, the reverse proxy server needs to be restarted to make the current limiting configuration effective in the reverse proxy server; for the circuit breaker configuration, the corresponding interface of the reverse proxy server can be called to make the circuit breaker configuration effective in the reverse proxy server.

[0143] like Figure 4 As shown, in this embodiment, the Ingress controller is implemented by Ingress-Nginx, the server is Nginx (ie, a reverse proxy server), and the method includes steps 1 to 11. Among them:

[0144] Step 1, the user configures the policy threshold and custom circuit breaker and current limiting policy of the ingress (Ingress), and submits the configuration file to the APIServer component. The policy indicators include the number of connections, QPS, connection timeout and other policy indicators of the native Ingress-Nginx and the replica availability provided by the embodiment of the present application. Among them, the custom circuit breaker and current limiting policy describes the detailed information of the replica availability, including the namespace, container name, policy indicator threshold and other information applicable to the policy. Among them, the replica availability is calculated by the monitored Deployment resources, and the calculation formula is: replica availability = Deployment.status.readyReplicas / Deployment.spec.replicas. Since the replica availability is directly calculated by the resources monitored from the API Server, there is no need to query from external monitoring components such as Prometheus, the indicator value is basically delayed, and there is no risk of missed collection and missed reporting of the monitoring component, which can reflect the operation of the replica more sensitively, reliably and in real time.

[0145] Step 2: Ingress-Nginx monitors the container resources in K8s APIServer through List / Watch. The container resources can include Ingress, Service, EndPoint, Deployment, Configmap and Event to monitor the container status (i.e., status change events) and ingress configuration events (i.e., resource change events). Event is a native K8s resource that triggers an Event notification when other container resources change.

[0146] Step 3: Ingress-Nginx receives the monitoring event.

[0147] Step 4: Check whether the Ingress corresponding to the event has been configured with a circuit breaker and current limiting strategy (i.e., whether circuit breaker and current limiting are enabled). Among them, the events in K8s contain information such as category, cause, and resource. The inspection process is to first determine whether it is a container event based on the resource information of the event. If it is, then find the corresponding Pod and Deployment based on the resource information. Finally, find the Ingress resources and custom circuit breaker and current limiting strategy corresponding to the Deployment based on the association relationship. If the custom circuit breaker and current limiting strategy is not configured, exit directly.

[0148] Step 5, the embodiment of the present application determines whether the container change is caused by the operation and maintenance personnel by monitoring the type and cause of the Event. Specifically, all container events of the Ingress-associated container are queried from the APIServer, and whether the container is normally constructed by the operation and maintenance personnel is determined based on the event type and cause. For example, if the event type is Normal and the cause is ScalingReplicaSet, it means that the operation and maintenance personnel are expanding the replica. The operation and maintenance personnel's execution of container rolling upgrades, expansion and contraction, and configuration modifications will cause changes in the container status and the number of available replicas, but this scenario does not require circuit breaking and current limiting, and directly exits the circuit breaking and current limiting process.

[0149] Step 6: Query the number of container connections, QPS, and connection timeout from Ingress-Nginx, query the replica availability from APIServer, and compare the policy indicator threshold of the current limiting policy to determine whether the container triggers the current limiting policy.

[0150] In step 6.1, if the policy is not triggered, clear the container current limiting configuration (clear the circuit breaker current limiting rules) and generate a current limiting recovery alarm.

[0151] In step 6.2, if the policy is triggered, a current limiting configuration is generated for the container (configure current limiting rules).

[0152] Step 7: Compare the indicator value queried in step 6 with the policy indicator threshold of the circuit breaker policy to determine whether the container triggers the circuit breaker policy.

[0153] Step 7.1: If the policy is not triggered, clear the container circuit breaker configuration (clear the circuit breaker and current limiting rules) and generate a circuit breaker recovery alarm.

[0154] In step 7.2, if the policy is triggered, a fuse configuration is generated for the container (configure fuse rules), and all Pod addresses of the container are deleted in the load balancer in Ingress-Nginx to implement business fuse.

[0155] Step 8: When multiple current limiting policies are triggered at the same time, check whether they are upgraded to fuses. For example, if the replica availability rate is less than 30% and the request error rate is greater than 10%, the container business can no longer provide normal services. In order to isolate the scope of the fault, the current limiting policy is upgraded to a fuse policy.

[0156] Step 9: Generate a corresponding alarm based on the level of the fuse and current limiting, and notify the operation and maintenance personnel to handle it.

[0157] Step 10: Restart Nginx or the interface provided by Nginx to update the circuit breaker and current limiting configurations generated for the container to Nginx. At this time, the circuit breaker and current limiting policies take effect.

[0158] Step 11: Complete all fuse and current limiting configuration and inspection processes.

[0159] Based on the same inventive concept, the embodiment of the present application also provides a fuse current limiting device for implementing the above-mentioned fuse current limiting method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more fuse current limiting device embodiments provided below can refer to the above-mentioned limitations on the fuse current limiting method, and will not be repeated here.

[0160] In an exemplary embodiment, Figure 5 As shown, a fuse current limiting device is provided, including: a first processing module 502, a second processing module 504 and a first generating module 506, wherein:

[0161] The first processing module 502 is used to obtain the total number of replicas corresponding to the target container and the number of replicas in a ready state from the API Server component in the K8s cluster;

[0162] A second processing module 504 is used to obtain a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0163] The first generation module 506 is used to generate a current limiting configuration corresponding to the target container if the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability rate and is not lower than the second policy indicator threshold of the corresponding fuse policy; the current limiting strategy and the fuse policy both include user-configured policy indicators, policy indicator thresholds and corresponding configuration generation conditions; the current limiting configuration is used to limit the business corresponding to the target container; if the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the business corresponding to the target container.

[0164] In one embodiment, the first processing module 502 includes:

[0165] The monitoring unit is used to monitor the total number of replicas corresponding to the target container and the number of replicas in the ready state from the API Server component in the K8s cluster.

[0166] In one embodiment, the fuse current limiting device further includes:

[0167] A determination module, configured to determine, in response to monitoring a K8s event, whether the K8s event is a target event based on the resource information to which the K8s event belongs; the target event includes a resource change event of the Ingress resource corresponding to the target container or a state change event corresponding to the target container;

[0168] The execution module is used to execute the corresponding device operation if it is a target event.

[0169] In one embodiment, the execution module includes:

[0170] An acquisition unit is used to obtain the policy indicator threshold of the current limiting strategy corresponding to the replica availability from the changed Ingress resource to obtain the first policy indicator threshold if the target event is a resource change event of the Ingress resource corresponding to the target container, and to obtain the policy indicator threshold of the circuit breaker strategy corresponding to the replica availability to obtain the second policy indicator threshold.

[0171] In one embodiment, the execution module includes:

[0172] A first determining unit, configured to determine whether the Ingress resource corresponding to the state change event is configured with a limited flow strategy or a fuse strategy if the target event is the state change event;

[0173] A second determining unit, configured to determine whether the state change event is an abnormal event if a limited flow strategy or a fuse strategy is configured;

[0174] The execution unit is used for, if it is an abnormal event, executing the step of obtaining the total number of replicas corresponding to the target container and the number of replicas in a ready state from the API Server component in the K8s cluster.

[0175] In one embodiment, the first determining unit is specifically configured to:

[0176] Based on the resource information carried by the state change event, search for the Deployment resource corresponding to the Pod instance corresponding to the target container;

[0177] Determine the Ingress resource corresponding to the Deployment resource;

[0178] Determine whether the Ingress resource is configured with a limited flow policy or a circuit breaker policy.

[0179] In one embodiment, the second determining unit is specifically configured to:

[0180] Determine whether the type carried by the state change event is the target type;

[0181] If it is a non-target type, query at least one historical state change event corresponding to the target container;

[0182] If the types of the historical state change events are all non-target types, the state change event is determined to be an abnormal event.

[0183] In one embodiment, the strategy indicator further includes at least one other strategy indicator, and the fuse current limiting device further includes:

[0184] A polling module, used for polling from an external monitoring component at a preset time interval to obtain a second indicator value of the other policy indicator;

[0185] The second generation module is used to generate a fuse configuration corresponding to the target container after each polling of the second indicator value: if the first indicator value and the second indicator value are both not lower than the indicator value of the policy indicator threshold of the corresponding fuse policy, and there are at least two indicator values ​​that are lower than the policy indicator threshold of the corresponding current limiting policy.

[0186] The embodiment of the fuse current limiting device in this embodiment is basically the same as the embodiments of each step of the above-mentioned fuse current limiting method, and will not be repeated here.

[0187] Each module in the above-mentioned fuse current limiting device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of 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.

[0188] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to 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 can be used to store data such as frequent item sets and data streams. The input / output interface of the computer device is used to exchange information between the processor and an external device. 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, a fuse current limiting method is implemented.

[0189] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0190] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0191] Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster;

[0192] Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0193] If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container;

[0194] If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0195] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0196] Listen to the API Server component in the K8s cluster to obtain the total number of replicas corresponding to the target container and the number of replicas in the ready state.

[0197] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0198] In response to monitoring a K8s event, determining whether the K8s event is a target event based on the resource information to which the K8s event belongs; the target event includes a resource change event of the Ingress resource corresponding to the target container or a state change event corresponding to the target container;

[0199] If it is a target event, the corresponding device operation is performed.

[0200] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0201] If the target event is a resource change event of the Ingress resource corresponding to the target container, the policy indicator threshold of the current limiting strategy corresponding to the replica availability rate is obtained from the changed Ingress resource to obtain the first policy indicator threshold, and the policy indicator threshold of the circuit breaker strategy corresponding to the replica availability rate is obtained to obtain the second policy indicator threshold.

[0202] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0203] If the target event is the state change event, determine whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a fuse policy;

[0204] If a limited flow strategy or a circuit breaker strategy is configured, determining whether the state change event is an abnormal event;

[0205] If it is an abnormal event, the total number of replicas corresponding to the target container and the number of replicas in the ready state are obtained from the API Server component in the K8s cluster.

[0206] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0207] Based on the resource information carried by the state change event, search for the Deployment resource corresponding to the Pod instance corresponding to the target container;

[0208] Determine the Ingress resource corresponding to the Deployment resource;

[0209] Determine whether the Ingress resource is configured with a limited flow policy or a circuit breaker policy.

[0210] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0211] Determine whether the type carried by the state change event is the target type;

[0212] If it is a non-target type, query at least one historical state change event corresponding to the target container;

[0213] If the types of the historical state change events are all non-target types, the state change event is determined to be an abnormal event.

[0214] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0215] Polling from an external monitoring component at a preset time interval to obtain a second indicator value of the other policy indicator;

[0216] After each polling of the second indicator value:

[0217] If both the first indicator value and the second indicator value are not lower than the indicator value of the policy indicator threshold of the corresponding fuse policy, and there are at least two indicator values ​​lower than the policy indicator threshold of the corresponding current limiting policy, then a fuse configuration corresponding to the target container is generated.

[0218] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0219] Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster;

[0220] Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0221] If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container;

[0222] If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0223] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0224] If the target event is a resource change event of the Ingress resource corresponding to the target container, the policy indicator threshold of the current limiting strategy corresponding to the replica availability rate is obtained from the changed Ingress resource to obtain the first policy indicator threshold, and the policy indicator threshold of the circuit breaker strategy corresponding to the replica availability rate is obtained to obtain the second policy indicator threshold.

[0225] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0226] If the target event is the state change event, determine whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a fuse policy;

[0227] If a limited flow strategy or a circuit breaker strategy is configured, determining whether the state change event is an abnormal event;

[0228] If it is an abnormal event, the total number of replicas corresponding to the target container and the number of replicas in the ready state are obtained from the API Server component in the K8s cluster.

[0229] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0230] Based on the resource information carried by the state change event, search for the Deployment resource corresponding to the Pod instance corresponding to the target container;

[0231] Determine the Ingress resource corresponding to the Deployment resource;

[0232] Determine whether the Ingress resource is configured with a limited flow policy or a circuit breaker policy.

[0233] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0234] Determine whether the type carried by the state change event is the target type;

[0235] If it is a non-target type, query at least one historical state change event corresponding to the target container;

[0236] If the types of the historical state change events are all non-target types, the state change event is determined to be an abnormal event.

[0237] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0238] Polling from an external monitoring component at a preset time interval to obtain a second indicator value of the other policy indicator;

[0239] After each polling of the second indicator value:

[0240] If both the first indicator value and the second indicator value are not lower than the indicator value of the policy indicator threshold of the corresponding fuse policy, and there are at least two indicator values ​​lower than the policy indicator threshold of the corresponding current limiting policy, then a fuse configuration corresponding to the target container is generated.

[0241] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0242] Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster;

[0243] Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate;

[0244] If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container;

[0245] If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

[0246] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0247] If the target event is a resource change event of the Ingress resource corresponding to the target container, the policy indicator threshold of the current limiting strategy corresponding to the replica availability rate is obtained from the changed Ingress resource to obtain the first policy indicator threshold, and the policy indicator threshold of the circuit breaker strategy corresponding to the replica availability rate is obtained to obtain the second policy indicator threshold.

[0248] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0249] If the target event is the state change event, determine whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a fuse policy;

[0250] If a limited flow strategy or a circuit breaker strategy is configured, determining whether the state change event is an abnormal event;

[0251] If it is an abnormal event, the total number of replicas corresponding to the target container and the number of replicas in the ready state are obtained from the API Server component in the K8s cluster.

[0252] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0253] Based on the resource information carried by the state change event, search for the Deployment resource corresponding to the Pod instance corresponding to the target container;

[0254] Determine the Ingress resource corresponding to the Deployment resource;

[0255] Determine whether the Ingress resource is configured with a limited flow policy or a circuit breaker policy.

[0256] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0257] Determine whether the type carried by the state change event is the target type;

[0258] If it is a non-target type, query at least one historical state change event corresponding to the target container;

[0259] If the types of the historical state change events are all non-target types, the state change event is determined to be an abnormal event.

[0260] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0261] Polling from an external monitoring component at a preset time interval to obtain a second indicator value of the other policy indicator;

[0262] After each polling of the second indicator value:

[0263] If both the first indicator value and the second indicator value are not lower than the indicator value of the policy indicator threshold of the corresponding fuse policy, and there are at least two indicator values ​​lower than the policy indicator threshold of the corresponding current limiting policy, then a fuse configuration corresponding to the target container is generated.

[0264] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0265] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0266] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A fusing current limiting method, characterized in that: The method comprises: Get the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster; Obtaining a first indicator value of a policy indicator corresponding to the target container based on the total number of replicas and the number of replicas; the policy indicator includes a replica availability rate; If the first indicator value is lower than the first policy indicator threshold of the current limiting strategy corresponding to the replica availability and is not lower than the second policy indicator threshold of the corresponding fuse strategy, a current limiting configuration corresponding to the target container is generated; both the current limiting strategy and the fuse strategy include a user-configured policy indicator, a policy indicator threshold, and a generation condition of the corresponding configuration; the current limiting configuration is used to limit the business corresponding to the target container; If the first indicator value is lower than the second policy indicator threshold, a fuse configuration corresponding to the target container is generated; the fuse configuration is used to fuse the service corresponding to the target container.

2. The method according to claim 1, characterized in that: The total number of replicas corresponding to the target container and the number of replicas in the ready state obtained from the API Server component in the K8s cluster include: Listen to the API Server component in the K8s cluster to obtain the total number of replicas corresponding to the target container and the number of replicas in the ready state.

3. The method according to claim 2, characterized in that The process of monitoring the total number of replicas and the number of replicas in the ready state corresponding to the target container from the API Server component in the K8s cluster includes: In response to monitoring a K8s event, determining whether the K8s event is a target event based on the resource information to which the K8s event belongs; the target event includes a resource change event of the Ingress resource corresponding to the target container or a state change event corresponding to the target container; If it is a target event, the corresponding device operation is performed.

4. The method according to claim 3, characterized in that The performing of corresponding device operations comprises: If the target event is a resource change event of the Ingress resource corresponding to the target container, the policy indicator threshold of the current limiting strategy corresponding to the replica availability rate is obtained from the changed Ingress resource to obtain the first policy indicator threshold, and the policy indicator threshold of the circuit breaker strategy corresponding to the replica availability rate is obtained to obtain the second policy indicator threshold.

5. The method according to claim 3, characterized in that: The performing of corresponding device operations comprises: If the target event is the state change event, determine whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a fuse policy; If a limited flow strategy or a circuit breaker strategy is configured, determining whether the state change event is an abnormal event; If it is an abnormal event, the total number of replicas corresponding to the target container and the number of replicas in the ready state are obtained from the API Server component in the K8s cluster.

6. The method according to claim 5, characterized in that Determining whether the Ingress resource corresponding to the state change event is configured with a limited flow policy or a fuse policy includes: Based on the resource information carried by the state change event, search for the Deployment resource corresponding to the Pod instance corresponding to the target container; Determine the Ingress resource corresponding to the Deployment resource; Determine whether the Ingress resource is configured with a limited flow policy or a circuit breaker policy.

7. The method according to claim 4, characterized in that Determining whether the state change event is an abnormal event includes: Determine whether the type carried by the state change event is the target type; If it is a non-target type, query at least one historical state change event corresponding to the target container; If the types of the historical state change events are all non-target types, the state change event is determined to be an abnormal event.

8. The method according to any one of claims 1 to 7, characterized in that: The strategy indicator further includes at least one other strategy indicator, and the method further includes: Polling from an external monitoring component at a preset time interval to obtain a second indicator value of the other policy indicator; After each polling of the second indicator value: If both the first indicator value and the second indicator value are not lower than the indicator value of the policy indicator threshold of the corresponding fuse policy, and there are at least two indicator values ​​lower than the policy indicator threshold of the corresponding current limiting policy, then a fuse configuration corresponding to the target container is generated.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.