Service mesh global throttling method, device, computer equipment, medium and product
By monitoring changes in custom global rate limiting resources through the global rate limiting controller component and automatically generating sidecar proxy filters, the problem of complex configuration of global rate limiting services in the service mesh is solved, and efficient and reliable global rate limiting service configuration is achieved.
Patent Information
- Application Number
- CN202411748850.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2044-12-02
AI Technical Summary
In existing technologies, the configuration process for global rate limiting services in service mesh is complex, resulting in low configuration efficiency. Users need to manually configure sidecar proxy filters.
The global rate limiting controller component listens for changes in custom global rate limiting resources, automatically generates sidecar proxy filters, and sends the filters to the sidecar proxy to achieve global rate limiting service.
It simplifies the configuration process of the global rate limiting service, improves configuration efficiency, reduces complexity, and increases configuration accuracy and reliability.
Smart Images

Figure CN119276796B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of cloud computing, and in particular to a service mesh global traffic limiting method and device, a computer device, a medium and a product. BACKGROUND
[0002] Service mesh global traffic limiting refers to implementing a unified traffic control policy on service requests within the entire service mesh in a distributed system or microservice architecture, to ensure the stability of the system and the rational allocation of resources. This mechanism is crucial for handling high-concurrency scenarios and avoiding service overload.
[0003] In related technologies, a service mesh can use some sidecar proxies to manage and control network traffic. For example, Envoy is a high-performance, open-source network proxy software commonly used as a sidecar proxy in a service mesh, used in cloud-native and microservice architecture design. To provide service mesh global traffic limiting services, it is usually necessary to configure a sidecar proxy filter, such as an Envoy filter (EnvoyFilter), for the sidecar proxy according to the global traffic limiting policy, so that the sidecar proxy can provide global traffic limiting services using the sidecar proxy filter.
[0004] However, in related technologies, when creating or updating global traffic limiting services in a service mesh, users need to manually configure sidecar proxy filters according to global traffic limiting policies, which complicates the configuration process and results in low configuration efficiency. SUMMARY
[0005] Embodiments of the present application provide a service mesh global traffic limiting method, device, computer device, medium and product, which can automatically generate a sidecar proxy filter, improving the efficiency of global traffic limiting configuration.
[0006] In a first aspect, the present application provides a service mesh global traffic limiting method applied to a container cluster, wherein the container cluster is deployed with a global traffic limiting custom resource component and a global traffic limiting controller component, and the method comprises:
[0007] listening to a global traffic limiting custom resource of the global traffic limiting custom resource component by the global traffic limiting controller component;
[0008] generating a sidecar proxy filter of a service mesh according to the global traffic limiting custom resource by the global traffic limiting controller component in the case of listening to changes in the global traffic limiting custom resource;
[0009] sending the sidecar proxy filter to a sidecar proxy to provide global traffic limiting services for the container cluster by the sidecar proxy using the sidecar proxy filter.
[0010] In one embodiment, the method further comprises:
[0011] In the case of listening to the global flow control custom resource change, the global flow control component is used to generate the flow control configuration corresponding to the sidecar proxy filter according to the global flow control custom resource;
[0012] The global flow control component is used to send the flow control configuration to the external flow control service corresponding to the sidecar proxy filter, so that the external flow control service controls the global flow control of the service request according to the flow control configuration.
[0013] In one of the embodiments, the method further comprises:
[0014] In the case of listening to the global flow control custom resource change, the global flow control component is used to generate the general request descriptor corresponding to the sidecar proxy filter according to the global flow control custom resource, and the general request descriptor is used to customize the global flow control service.
[0015] In one of the embodiments, the global flow control component is used to generate the sidecar proxy filter of the service mesh according to the global flow control custom resource in the case of listening to the global flow control custom resource change, and the method comprises:
[0016] In the case of listening to the global flow control custom resource change, the global flow control component is used to obtain a preset field association library.
[0017] The global flow control component is used to generate the sidecar proxy filter according to the field association library and the global flow control custom resource, and the field association relationship in the field association library is used to represent the association relationship between at least part of the fields in the global flow control custom resource and at least part of the fields in the sidecar proxy filter.
[0018] In one of the embodiments, the method further comprises:
[0019] The global flow control custom resource component is used to obtain the configuration information of the global flow control custom resource from the user end;
[0020] The global flow control custom resource component is used to update the global flow control custom resource according to the configuration information.
[0021] In one of the embodiments, the method further comprises:
[0022] The sidecar proxy is used to obtain the request descriptor parameter of the service request from the user end in response to the service request of the container cluster.
[0023] The sidecar agent calls an external traffic limiting service corresponding to the sidecar agent filter to determine a global traffic limiting control result of the service request according to the request descriptor parameter and a traffic limiting configuration corresponding to the sidecar agent filter through the external traffic limiting service.
[0024] The sidecar agent sends a request response corresponding to the service request to the user end according to the global traffic limiting control result.
[0025] In a second aspect, the present application provides a service mesh global traffic limiting device, applied to a container cluster, wherein the container cluster is deployed with a global traffic limiting custom resource component and a global traffic limiting controller component, and the device comprises:
[0026] A listening module is configured to listen to a global traffic limiting custom resource of the global traffic limiting custom resource component through the global traffic limiting controller component;
[0027] A generating module is configured to generate a sidecar agent filter of a service mesh according to the global traffic limiting custom resource through the global traffic limiting controller component when the global traffic limiting custom resource changes is listened to;
[0028] A sending module is configured to send the sidecar agent filter to the sidecar agent to provide a global traffic limiting service for the container cluster through the sidecar agent using the sidecar agent filter.
[0029] In a third aspect, the present application provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0030] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the above method when executed by a processor.
[0031] In a fifth aspect, the present application provides a computer program product, comprising a computer program, and the computer program implements the steps of the above method when executed by a processor.
[0032] The service mesh global flow limiting method, device, computer equipment, medium and product described above, through the global flow limiting controller component, the global flow limiting custom resource of the global flow limiting custom resource component is listened to, in the case of listening to the change of the global flow limiting custom resource, through the global flow limiting controller component, the sidecar proxy filter of the service mesh is generated according to the global flow limiting custom resource, and the sidecar proxy filter is sent to the sidecar proxy, so that the global flow limiting service is provided for the container cluster by the sidecar proxy using the sidecar proxy filter. The method deploys the global flow limiting controller component and the global flow limiting custom resource component in the container cluster, so that the user can customize the global flow limiting custom resource according to the global flow limiting demand based on the global flow limiting custom resource component, and the global flow limiting controller component not only has the function of listening to the global flow limiting custom resource, but also has the function of automatically generating the sidecar proxy filter, simplifying the global flow limiting service configuration process, and the configuration process does not need to consider the version of the sidecar proxy, and the user does not need to fully learn and master the sidecar proxy filter configuration rule, and only needs to configure a small amount of global flow limiting custom resource to realize the automatic configuration of the global flow limiting service. Compared with the manual configuration of the sidecar proxy filter, the configuration complexity is greatly reduced, the global flow limiting service configuration efficiency is improved, the test process after configuration is reduced, the configuration accuracy and reliability are improved. BRIEF DESCRIPTION OF DRAWINGS
[0033] Figure 1 A structural schematic diagram of a container cluster in an embodiment;
[0034] Figure 2 One of the flow schematic diagrams of the service mesh global flow limiting method in an embodiment;
[0035] Figure 3 The flow schematic diagram of the service mesh global flow limiting method in an embodiment;
[0036] Figure 4 The flow schematic diagram of the service mesh global flow limiting method in an embodiment;
[0037] Figure 5 The flow schematic diagram of the service mesh global flow limiting method in an embodiment;
[0038] Figure 6 The flow schematic diagram of the service mesh global flow limiting method in an embodiment;
[0039] Figure 7 The flow schematic diagram of the service mesh global flow limiting method in an embodiment;
[0040] Figure 8 The flow schematic diagram of the service mesh global flow limiting method in an embodiment;
[0041] Figure 9 A structural diagram of a service mesh global traffic limiting device in an embodiment;
[0042] Figure 10 An internal structural diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0043] In order to make the purposes, technical solutions and advantages of the present application clearer, further detailed description will be made to the present application in combination 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.
[0044] The service mesh global traffic limiting method provided by the embodiments of the present application can be applied to a container cluster as shown in Figure 1 The container cluster can be a cluster created based on Kubernetes. Kubernetes is an open source container orchestration engine, which is referred to as K8s. The container cluster can include multiple server nodes, and each server node can be a virtual machine or a physical host. Each server node can include one or more Pod groups (Pods) 10. A Pod is a basic unit for deploying, managing and orchestrating containerized applications in Kubernetes, and a Pod can include one or more containers.
[0045] In a cloud native architecture, a Pod sidecar container and an application container 12 are deployed in a Pod, as shown in Figure 1 The sidecar container is used to provide a sidecar proxy 11, such as Envoy, which can manage and control network traffic. Specifically, the sidecar proxy 11 is used to process each service request received by the Pod, including traffic limiting operation and distributing the corresponding service request to the corresponding Pod. The application container 12 is used to implement the business functions of the microservice. It can be understood that any service request needs to pass through the sidecar proxy 11 first, and the sidecar proxy 11 distributes the service request.
[0046] It can be understood that, Figure 1 The container cluster can be managed based on various microservices of a service mesh. The service mesh takes over the traffic of all microservice containers through a series of distributed interconnected sidecar proxies 11, and realizes flexible and fine microservice traffic control. In the service mesh, all incoming and outgoing traffic of the microservice container needs to be forwarded through the sidecar proxy 11.
[0047] In an embodiment, as shown in Figure 2 A service mesh global traffic limiting method is provided, and the method is applied to Figure 1The container cluster in the application is taken as an example for illustration, including the following steps S202 to S206.
[0048] S202: Listen to the global rate limit custom resource of the global rate limit custom resource component by the global rate limit controller component.
[0049] The container cluster is deployed with a global rate limit custom resource component (GlobalRateLimit Custom Resource Definition, GlobalRateLimit CRD) and a global rate limit controller (Controller) component. The global rate limit custom resource component is used to provide a global rate limit custom resource for users to declaratively configure the global rate limit service. Users can customize the global rate limit service by configuring the global rate limit custom resource. CRD is a powerful Kubernetes API (Application Program Interface) extension mechanism that allows users to create and manage custom resources, so that Kubernetes is not limited to built-in resources (such as Pod, Service, etc.), but also supports user-defined resource types.
[0050] The global rate limit controller component is a core component in Kubernetes, which is responsible for managing and maintaining the actual state of cluster resources and the user's desired state, and taking action to correct the deviation when detecting the deviation, thereby realizing the function of automatic management. In the embodiments of the present application, the global rate limit controller component is used to listen to the global rate limit custom resource state.
[0051] The global rate limit custom resource meets the preset CRD specification. In the application, users can submit configuration information (for example, global rate limit configuration) of the global rate limit custom resource according to the CRD specification to configure the global rate limit service. For example, the global rate limit custom resource includes at least one of an external rate limiting service, a rate limited service, and a global rate limit configuration.
[0052] Exemplarily, the external rate limiting service is configured to specify an external rate limiting service address and timeout information, for example, the external rate limiting service includes at least one of an external rate limiting service address and an external rate limiting service connection timeout. Exemplarily, the rate limited traffic is configured to specify rate limited traffic information, and support ingress or egress rate limiting, for example, the rate limited traffic includes at least one of a rate limited traffic service name and ingress or egress rate limiting of traffic. Exemplarily, the global rate limiting configuration can be configured in multiple pieces, and each piece of global rate limiting configuration is configured to configure a total amount of rate limiting per unit time for a specified path, for example, the global rate limiting configuration includes at least one of a threshold configuration and a matching condition, the threshold configuration is configured to specify a total amount of rate limiting per unit time, for example, support time / minute / second / day unit time, and the total amount is the number of times; the matching condition supports at least one of the following matching contents: request header, request IP (Internet Protocol), and request parameter, and at least one of the following matching modes: regular, prefix, suffix, include, and exact. The key fields in the global rate limiting custom resource are shown in Table 1.
[0053] Table 1
[0054]
[0055] It can be understood that the global rate limiting controller component depends on the creation of the global rate limiting custom resource component, and in the application, the global rate limiting custom resource component can be deployed in the container cluster first, and then the global rate limiting controller component is deployed.
[0056] S204: In the case of listening to the change of the global rate limiting custom resource, a sidecar proxy filter of the service mesh is generated according to the global rate limiting custom resource through the global rate limiting controller component.
[0057] Exemplarily, the global rate limiting controller component periodically detects whether the global rate limiting custom resource changes, if the global rate limiting custom resource changes are listened to, the corresponding sidecar proxy filter is automatically generated according to the global rate limiting custom resource; otherwise, the global rate limiting custom resource continues to be listened to.
[0058] Exemplarily, the sidecar proxy filter includes an EnvoyFilter (Envoy filter) based on Envoy. The EnvoyFilter is a powerful resource type in the control core component (for example, Istio) of the service mesh, which allows users to customize and extend the Envoy configuration generated by Istio. The EnvoyFilter resource provides a mechanism for operations and development personnel to finely adjust and enhance the behavior of Envoy without modifying the service code.
[0059] S206: sending the sidecar proxy filter to the sidecar proxy, so that the sidecar proxy provides the global traffic limiting service for the container cluster by using the sidecar proxy filter.
[0060] For example, the container cluster is also deployed with a control core component, such as an Envoy-based control core component Istio. For example, the sidecar proxy filter is sent to the sidecar proxy through the control component, so that the sidecar proxy provides the global traffic limiting service for the container cluster by using the sidecar proxy filter. For example, after the control core component Istio detects the EnvoyFilter change, the EnvoyFilter is pushed to the service mesh sidecar proxy Envoy through a preset communication protocol (for example, xds protocol), so that the Envoy provides the global traffic limiting service for the microservice in the corresponding Pod by using the EnvoyFilter.
[0061] The above-mentioned service mesh global traffic limiting method listens to the global traffic limiting custom resource of the global traffic limiting custom resource component through the global traffic limiting controller component, and in the case that the global traffic limiting custom resource changes, the global traffic limiting controller component generates the sidecar proxy filter of the service mesh according to the global traffic limiting custom resource, sends the sidecar proxy filter to the sidecar proxy, so that the sidecar proxy provides the global traffic limiting service for the container cluster by using the sidecar proxy filter. This method deploys the global traffic limiting controller component and the global traffic limiting custom resource component in the container cluster, so that the user can customize the global traffic limiting custom resource according to the global traffic limiting demand based on the global traffic limiting custom resource component, and the global traffic limiting controller component not only has the function of listening to the global traffic limiting custom resource, but also has the function of automatically generating the sidecar proxy filter, simplifying and abstracting the global traffic limiting service configuration process. The configuration process does not need to consider the version of the sidecar proxy, and the user does not need to fully learn and master the sidecar proxy filter configuration rule. Only a small amount of global traffic limiting custom resource configuration is needed to realize the automatic configuration of the global traffic limiting service. Compared with the manual configuration of the sidecar proxy filter, the configuration complexity is greatly reduced, the global traffic limiting service configuration efficiency is improved, the test process after configuration is reduced, and the configuration accuracy and reliability are improved.
[0062] In one embodiment, as shown in Figure 3 The service mesh global traffic limiting method further includes steps S302 and S304.
[0063] S302: In the case that the global traffic limiting custom resource changes, the global traffic limiting controller component generates the traffic limiting configuration corresponding to the sidecar proxy filter according to the global traffic limiting custom resource.
[0064] The sidecar proxy filter includes a throttling configuration. The throttling configuration is used to describe throttling rules of the global throttling service. For example, the throttling configuration includes a throttling domain and a general request descriptor, where the throttling domain is used to define the application scope of the global throttling service, and the throttling domain can also be used to organize and isolate different global throttling services.
[0065] S304: sending, by the global throttling control component, the throttling configuration to an external throttling service corresponding to the sidecar proxy filter, so as to perform global throttling control on the service request by the external throttling service according to the throttling configuration.
[0066] For example, the container cluster is deployed with an external throttling server, which is used to provide an external throttling service. In the application, the global throttling control component can send the throttling configuration to the external throttling server, so as to perform global throttling control on the service request by the external throttling service according to the throttling configuration, where the external throttling server is used to provide an external throttling service corresponding to the sidecar proxy filter.
[0067] The above service mesh global throttling method, in the case of listening to the change of the global throttling custom resource, generates the throttling configuration corresponding to the sidecar proxy filter according to the global throttling custom resource through the global throttling control component, and sends the throttling configuration to the external throttling service corresponding to the sidecar proxy filter through the global throttling control component, so as to perform global throttling control on the service request by the external throttling service according to the throttling configuration, which realizes automatic generation of the throttling configuration corresponding to the sidecar proxy filter, thereby providing technical support and guarantee for providing global throttling service based on the sidecar proxy filter and the throttling configuration, and reducing the global throttling service configuration complexity and improving the configuration efficiency compared with manually writing the throttling configuration.
[0068] In one embodiment, the service mesh global throttling method further includes: in the case of listening to the change of the global throttling custom resource, generating, by the global throttling control component, a general request descriptor corresponding to the sidecar proxy filter according to the global throttling custom resource, where the general request descriptor is used to customize the global throttling service. The sidecar proxy filter and the throttling configuration each include the general request descriptor. It should be noted that the general request descriptor is associated with the sidecar proxy filter. The general request descriptor is different from a default request descriptor based on the service mesh sidecar proxy, where the sidecar proxy filter also includes the default request descriptor. The general request descriptor can be used to customize the global throttling service based on the general request descriptor. The embodiments of the present application can not only generate the default request descriptor, but also generate the general request descriptor, which can be used to customize the global throttling service, and has stronger expansibility and higher flexibility.
[0069] In one embodiment, as Figure 4As shown, in step S204, in the case of listening to the global traffic limiting custom resource change, the global traffic limiting controller component generates a service mesh sidecar proxy filter according to the global traffic limiting custom resource, including the following steps S402 and S404.
[0070] S402: In the case of listening to the global traffic limiting custom resource change, the global traffic limiting controller component acquires a preset field association library.
[0071] S404: The global traffic limiting controller component generates a sidecar proxy filter according to the field association library and the global traffic limiting custom resource; wherein the field association relationship in the field association library is used to represent the association relationship between at least part of the fields in the global traffic limiting custom resource and at least part of the fields in the sidecar proxy filter.
[0072] The field association library can be understood as the basis for the global traffic limiting controller component to automatically generate a sidecar proxy filter. The field association library includes a plurality of field association relationships. Each field association relationship is used to represent the association relationship between at least part of the fields in the global traffic limiting custom resource and at least part of the fields in the sidecar proxy filter; wherein at least part of the fields in the global traffic limiting custom resource can be understood as key fields for generating a sidecar proxy filter, for example, the key fields include at least one of an external traffic limiting service field, a limited service field, a threshold configuration field in the global traffic limiting configuration, a matching mode field, and a matching path field. For example, the limited service field is set to gateway, workloadSelector, that is, the limited service is gateway service. For example, the threshold configuration field is set to limit one request per minute. For example, the matching content field is set to use the exact match mode for the path parameter in the request header. At least part of the fields in the sidecar proxy filter can be understood as associated fields that are associated with the key fields, or in other words, are mapped to associated fields of the sidecar proxy filter according to a preset rule, such as a traffic limiting configuration field and a general request descriptor field, etc.
[0073] In the application, the global traffic limiting controller component can parse the global traffic limiting custom resource to determine a plurality of key fields, and determine the associated fields corresponding to each key field according to the field association library, and then generate a sidecar proxy filter corresponding to the global traffic limiting custom resource according to each associated field.
[0074] The service mesh global flow limiting method, in the case of listening to the change of the global flow limiting custom resource, acquires the preset field association library through the global flow limiting controller component, and generates a sidecar proxy filter according to the field association library and the global flow limiting custom resource through the global flow limiting controller component, so that the global flow limiting controller component has the function of automatically generating the sidecar proxy filter, thereby realizing automatic generation of the sidecar proxy filter by the global flow limiting custom resource, and helping to improve the global flow limiting service configuration efficiency.
[0075] In one embodiment, as shown in Figure 5 The service mesh global flow limiting method further includes steps S502 and S504.
[0076] S502: Acquire, through the global flow limiting custom resource component, configuration information of the global flow limiting custom resource on the user side.
[0077] S504: Update, through the global flow limiting custom resource component, the global flow limiting custom resource according to the configuration information.
[0078] The configuration information is used to describe the related information of the custom configuration of the global flow limiting custom resource on the user side. In the application, the user can configure the global flow limiting custom resource according to the global flow limiting custom resource specification according to the global flow limiting service policy to be configured through the user side.
[0079] It can be understood that after the global flow limiting custom resource component acquires the configuration information of the global flow limiting custom resource, the global flow limiting custom resource can be updated according to the configuration information, and the global flow limiting controller component is triggered to generate the corresponding sidecar proxy filter according to the updated global flow limiting custom resource according to the change of the global flow limiting custom resource.
[0080] The service mesh global flow limiting method acquires the configuration information of the global flow limiting custom resource on the user side through the global flow limiting custom resource component, and updates the global flow limiting custom resource according to the configuration information through the global flow limiting custom resource component. On this basis, the user can realize the custom configuration of the global flow limiting custom resource through the global flow limiting custom resource component, thereby providing support for automatic generation of the global flow limiting service.
[0081] In one embodiment, as shown in Figure 6 The service mesh global flow limiting method further includes steps S602 to S606.
[0082] S602: Acquire, through the sidecar proxy, a request descriptor parameter of a service request in response to the service request of the container cluster on the user side.
[0083] In an application, the user end can send a service request to the container group, the sidecar proxy in the container group receives the service request, analyzes the service request, and obtains a request descriptor parameter in the service request. The request descriptor parameter is used to indicate a service or a service that needs to be called by the service request.
[0084] S604: Through the sidecar proxy, an external flow limiting service corresponding to the sidecar proxy filter is called to determine a global flow limiting control result of the service request according to the request descriptor parameter and a flow limiting configuration corresponding to the sidecar proxy filter through the external flow limiting service.
[0085] S606: Through the sidecar proxy, a request response corresponding to the service request is sent to the user end according to the global flow limiting control result.
[0086] The global flow limiting control result is used to indicate whether the service request is globally flow limited. The global flow limiting control result includes flow limiting or no flow limiting. For example, if the global flow limiting control result is no flow limiting, that is, the service request is not globally flow limited, in this case, the flow limiting service is normally called and a normal request response is sent to the user end to indicate that the service is normally called; if the global flow limiting control result is flow limiting, that is, the service request is globally flow limited, in this case, an error request response, for example, a flow limiting error code, is sent to the user end to indicate that the service is not normally called.
[0087] The above service mesh global flow limiting method, through the sidecar proxy, in response to a service request of a user end to a container cluster, obtains a request descriptor parameter of the service request, and calls an external flow limiting service corresponding to the sidecar proxy filter to determine a global flow limiting control result of the service request according to the request descriptor parameter and a flow limiting configuration corresponding to the sidecar proxy filter through the external flow limiting service, and sends a request response corresponding to the service request to the user end according to the global flow limiting control result, thereby achieving global flow limiting control of the service request, effectively controlling and managing traffic, and providing reliable global flow limiting services for the container cluster.
[0088] In one embodiment, as shown in Figure 7 and Figure 8 , a service mesh global flow limiting method is provided. The method is applied to a container cluster as shown in Figure 1 , and a global flow limiting rule is configured for a gateway entrance, and the flow limiting is limited to take effect only on requests accessing the / ratelimit path. The method includes the following steps S702 to S712.
[0089] S702: Deploy a global flow limiting custom resource component and a global flow limiting custom controller component in the container cluster.
[0090] S704: Obtain the configuration information of the global flow limiting custom resource submitted by the user terminal according to the global flow limiting custom resource specification through the global flow limiting custom resource component.
[0091] In the configuration information, the field of the limited flow service is a gateway, the threshold configuration field in the global flow limiting configuration is to limit the request once per minute, the matching mode field is to use an exact matching mode for the path parameter in the request header, the matching path field is / ratelimit, and the external flow limiting service field is not specified, so the default address parameter is used.
[0092] S706: The global flow limiting custom controller component listens to the change of the global flow limiting custom resource and generates the corresponding sidecar proxy filter, flow limiting configuration and general request descriptor according to the global flow limiting custom resource.
[0093] In the configuration information, the field of the limited flow service is a gateway, the threshold configuration field in the global flow limiting configuration is to limit the request once per minute, the matching mode field is to use an exact matching mode for the path parameter in the request header, the matching path field is / ratelimit, and the external flow limiting service field is not specified, so the default address parameter is used.
[0094] S708: The service mesh control core component of the container cluster deployment listens to the change of the Envoy filter and sends the sidecar proxy filter to the service mesh sidecar proxy through a preset protocol.
[0095] In the configuration information, the field of the limited flow service is a gateway, the threshold configuration field in the global flow limiting configuration is to limit the request once per minute, the matching mode field is to use an exact matching mode for the path parameter in the request header, the matching path field is / ratelimit, and the external flow limiting service field is not specified, so the default address parameter is used.
[0096] S710: The sidecar proxy calls the external flow limiting service corresponding to the sidecar proxy filter according to the request descriptor parameter of the received business request.
[0097] S712: The external flow limiting service determines whether to limit the request according to the request descriptor parameter and the flow limiting configuration, and returns a flow limiting error code if the request is limited, otherwise returns after normally calling the flow limiting service.
[0098] When a request is called to the limited flow service, it will first pass through the Envoy proxy, which will call the external flow limiting service with the request descriptor parameter. The external flow limiting service determines whether to limit the request according to the request descriptor parameter and the flow limiting configuration. For example, the first call does not trigger global flow limiting, and the flow limiting service is normally called and returned; the second call triggers global flow limiting, reaches the limit of one request per minute, and returns a flow limiting error code.
[0099] Compared with manually configuring EnvoyFilter in the related art, the service mesh global rate limiting method introduces a global rate limiting custom resource component (GlobalRateLimit CRD) and a global rate limiting custom controller component (GlobalRateLimit Controller), so that the global rate limiting rule is simpler and more friendly, and only a few lines of configuration are needed to realize the EnvoyFilter function, and the configuration efficiency is higher. In addition, compared with manually writing a rate limiting configuration in the related art, the embodiment of the application introduces a global rate limiting custom controller component to listen to changes of a global rate limiting custom resource (CRD), automatically converts and creates a complex EnvoyFilter rule, and automatically generates a rate limiting configuration according to the global rate limiting custom resource definition. In addition, compared with the rate limiting configuration in the related art which is only suitable for a default implemented rate limiting service, the embodiment of the application can not only generate a default rate limiting configuration, but also generate a general request descriptor description, which can be used for custom rate limiting services, and has stronger expansibility and stronger flexibility.
[0100] It should be understood that, although each step in the flowchart involved in each embodiment as described above is shown in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0101] Based on the same inventive concept, the embodiment of the application also provides a service mesh global rate limiting device for implementing the above-mentioned service mesh global rate limiting method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more service mesh global rate limiting device embodiments provided below can refer to the limitations of the service mesh global rate limiting method in the above text, which will not be repeated here.
[0102] In one embodiment, as Figure 9As shown, a service mesh global traffic limiting device is provided, which is applied to a container cluster, and the container cluster is deployed with a global traffic limiting custom resource component and a global traffic limiting controller component. The service mesh global traffic limiting device comprises a listening module, a generating module and a sending module. The listening module is configured to listen to the global traffic limiting custom resource of the global traffic limiting custom resource component through the global traffic limiting controller component. The generating module is configured to generate a sidecar proxy filter of the service mesh according to the global traffic limiting custom resource through the global traffic limiting controller component in the case of listening to the change of the global traffic limiting custom resource. The sending module is configured to send the sidecar proxy filter to the sidecar proxy to provide global traffic limiting service for the container cluster through the sidecar proxy using the sidecar proxy filter.
[0103] The service mesh global traffic limiting device listens to the global traffic limiting custom resource of the global traffic limiting custom resource component through the global traffic limiting controller component, generates a sidecar proxy filter of the service mesh according to the global traffic limiting custom resource through the global traffic limiting controller component in the case of listening to the change of the global traffic limiting custom resource, and sends the sidecar proxy filter to the sidecar proxy through the sending module to provide global traffic limiting service for the container cluster through the sidecar proxy using the sidecar proxy filter. The device deploys the global traffic limiting controller component and the global traffic limiting custom resource component in the container cluster, so that the user can customize the global traffic limiting custom resource according to the global traffic limiting requirement based on the global traffic limiting custom resource component, and the global traffic limiting controller component not only has the function of listening to the global traffic limiting custom resource, but also has the function of automatically generating the sidecar proxy filter, simplifying the global traffic limiting service configuration process, and the configuration process does not need to consider the version of the sidecar proxy, and the user does not need to fully learn and master the sidecar proxy filter configuration rule, and only needs to configure a small amount of global traffic limiting custom resource to realize the automatic configuration of the global traffic limiting service, which greatly reduces the configuration complexity, improves the global traffic limiting service configuration efficiency, reduces the test process after configuration, and improves the configuration accuracy and reliability.
[0104] In one embodiment, the generating module is further configured to generate a traffic limiting configuration corresponding to the sidecar proxy filter according to the global traffic limiting custom resource through the global traffic limiting control component in the case of listening to the change of the global traffic limiting custom resource. The sending module is further configured to send the traffic limiting configuration to an external traffic limiting service corresponding to the sidecar proxy filter through the global traffic limiting control component, so as to control the global traffic limiting of the business request through the external traffic limiting service according to the traffic limiting configuration.
[0105] In an embodiment, the generating module is further configured to, in response to detecting a change in the global traffic limiting custom resource, generate, by the global traffic limiting control component, a general request descriptor corresponding to the sidecar proxy filter according to the global traffic limiting custom resource, and the general request descriptor is used to customize the global traffic limiting service.
[0106] In an embodiment, the generating module is further configured to, in response to detecting a change in the global traffic limiting custom resource, obtain, by the global traffic limiting controller component, a preset field association library, and generate, by the global traffic limiting controller component, the sidecar proxy filter according to the field association library and the global traffic limiting custom resource, wherein the field association relationship in the field association library is used to represent an association relationship between at least part of the fields in the global traffic limiting custom resource and at least part of the fields in the sidecar proxy filter.
[0107] In an embodiment, the service mesh global traffic limiting apparatus further includes an obtaining module and an updating module. The obtaining module is configured to obtain, by the global traffic limiting custom resource component, configuration information of the global traffic limiting custom resource from a user end. The updating module is configured to update, by the global traffic limiting custom resource component, the global traffic limiting custom resource according to the configuration information.
[0108] In an embodiment, the service mesh global traffic limiting apparatus further includes an obtaining module and a calling module. The obtaining module is configured to obtain, by the sidecar proxy, a request descriptor parameter of a service request from a user end to a container cluster in response to the service request. The calling module is configured to call, by the sidecar proxy, an external traffic limiting service corresponding to the sidecar proxy filter, so as to determine a global traffic limiting control result of the service request by the external traffic limiting service according to the request descriptor parameter and a traffic limiting configuration corresponding to the sidecar proxy filter. The sending module is further configured to send, by the sidecar proxy, a request response corresponding to the service request to the user end according to the global traffic limiting control result.
[0109] The above-mentioned various modules of the service mesh global traffic limiting apparatus can be all or part realized by software, hardware, and combinations thereof. The above-mentioned various modules can be embedded in or independent of a processor in a computer device in a hardware form, or can be stored in a memory in a computer device in a software form, so as to be called and executed by a processor to perform the operations corresponding to the above-mentioned various modules.
[0110] In an embodiment, a computer device is provided, which can be a server, and an internal structure diagram of the computer device can be as shown in Figure 10As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor to implement a service mesh global flow limiting method.
[0111] Those skilled in the art can understand that, Figure 10 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0112] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the foregoing method.
[0113] In one embodiment, a computer readable storage medium is provided, having a computer program stored thereon, and the computer program is executed by a processor to implement the steps of the foregoing method.
[0114] In one embodiment, a computer program product is provided, including a computer program, and the computer program is executed by a processor to implement the steps of the foregoing method.
[0115] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.
[0116] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric 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 but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0117] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0118] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A service mesh global rate limiting method, comprising: Applied to a container cluster deployed with a global throttling custom resource component and a global throttling controller component, the method comprises: listening, by the global throttling controller component, to a global throttling custom resource of the global throttling custom resource component; in the case of listening to the change of the global throttling custom resource, generating, by the global throttling controller component, a sidecar proxy filter of a service mesh according to the global throttling custom resource; sending the sidecar proxy filter to a sidecar proxy to provide global throttling service for the container cluster by the sidecar proxy using the sidecar proxy filter.
2. The method of claim 1, wherein, The method further comprises: in the case of listening to the change of the global throttling custom resource, generating, by the global throttling control component, a throttling configuration corresponding to the sidecar proxy filter according to the global throttling custom resource; sending, by the global throttling control component, the throttling configuration to an external throttling service corresponding to the sidecar proxy filter, to control the global throttling of the service request by the external throttling service according to the throttling configuration.
3. The method of claim 1, wherein, The method further comprises: in the case of listening to the change of the global throttling custom resource, generating, by the global throttling control component, a general request descriptor corresponding to the sidecar proxy filter according to the global throttling custom resource, the general request descriptor being used for customizing the global throttling service.
4. The method according to any one of claims 1 to 3, characterized in that, The method further comprises: in the case of listening to the change of the global throttling custom resource, generating, by the global throttling control component, a general request descriptor corresponding to the sidecar proxy filter according to the global throttling custom resource, the general request descriptor being used for customizing the global throttling service. in the case of listening to the change of the global throttling custom resource, obtaining, by the global throttling controller component, a preset field association library; 5. The method according to any one of claims 1 to 3, characterized in that, generating, by the global throttling controller component, the sidecar proxy filter according to the field association library and the global throttling custom resource; wherein the field association relationship in the field association library is used to represent the association relationship between at least part of the fields in the global throttling custom resource and at least part of the fields in the sidecar proxy filter. The method further comprises: obtaining, by the global throttling custom resource component, configuration information of the global throttling custom resource from a user end; 6. The method according to any one of claims 1 to 3, characterized in that, updating, by the global throttling custom resource component, the global throttling custom resource according to the configuration information. The method further comprises: obtaining, by the sidecar proxy, a request descriptor parameter of a service request of the container cluster in response to the service request from a user end; calling, by the sidecar proxy, an external throttling service corresponding to the sidecar proxy filter, to determine a global throttling control result of the service request by the external throttling service according to the request descriptor parameter and the throttling configuration corresponding to the sidecar proxy filter; 7. A service mesh global traffic shaping apparatus, comprising: sending, by the sidecar proxy, a request response corresponding to the service request to the user end according to the global throttling control result. Applied to a container cluster deployed with a global throttling custom resource component and a global throttling controller component, the method comprises: The listening module is configured to listen to a global traffic limiting custom resource of the global traffic limiting custom resource component through the global traffic limiting controller component. The generating module is configured to generate, through the global traffic limiting controller component, a sidecar proxy filter of a service mesh according to the global traffic limiting custom resource when the global traffic limiting custom resource changes are listened to. The sending module is configured to send the sidecar proxy filter to the sidecar proxy, so that the sidecar proxy provides global traffic limiting services for the container cluster by using the sidecar proxy filter.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
Citation Information
Patent Citations
Route updating method and device
CN111314141A
Gateway interface resource management method and device, storage medium and electronic equipment
CN117112260A