Distributed current limiting control method and related device

Through the distributed flow limit control method, the flow limit operation is performed on user requests according to the flow limit policy, which solves the resource competition problem caused by concurrent access traffic and improves the quality of CDN service.

CN119496747AActive Publication Date: 2025-02-21AGRICULTURAL BANK OF CHINA

Patent Information

Application Number
CN202411713905.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-02-21
Estimated Expiration
2044-11-27

AI Technical Summary

Technical Problem

Excessively high concurrent access traffic will lead to competition for concurrent resources, which may lead to the enterprise's core application bandwidth being squeezed, thereby affecting the quality of CDN services.

Method used

A distributed current limit control method is provided. By obtaining the current limit configuration data, it determines whether the current limit operation is required for user requests. Based on the current limiting policy of the cluster or application, the request rate, the number of concurrent connections or the number of time window requests is limited.

Benefits of technology

It effectively avoids concurrent resource competition caused by excessively high concurrent access traffic in CDN cache clusters, protects the enterprise's core application bandwidth, and improves the CDN service quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119496747A_ABST
    Figure CN119496747A_ABST
Patent Text Reader

Abstract

The invention provides a distributed current limiting control method and a related device, and relates to the field of current limiting. After the user request is received, if it is judged that the user request needs to be subjected to the flow limiting operation, the flow limiting operation is executed on the user request based on the flow limiting strategy, the problem that the bandwidth of an enterprise core application is occupied due to concurrent resource competition caused by the fact that a CDN cache cluster responds to too high concurrent access flow is avoided, and the CDN service quality is improved. Besides, in the invention, during the current-limiting configuration, the current-limiting strategies of different target cache clusters are the same or different, and the current-limiting strategies of different applications configured in the target cache clusters are the same or different, so that the current-limiting requirements of different clusters or applications can be adapted, and the application range of the distributed current-limiting control method is improved. The method also supports the limitation of the request rate, the limitation of the concurrent connection number and the limitation of the time window request number, and can meet different current limiting demand scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of current limiting, and more specifically, to a distributed current limiting control method and related devices. Background Art

[0002] Content Delivery Network (CDN) is a network service based on a distributed architecture. By distributing content cache to server nodes across the country, it can increase the speed of content transmission, effectively optimize user experience, reduce network traffic, and improve network throughput and scalability.

[0003] When using a CDN cluster, excessive concurrent access traffic will lead to concurrent resource competition, which may cause the bandwidth of the enterprise's core applications to be squeezed, thereby affecting the quality of CDN services. Summary of the invention

[0004] In view of this, the present application provides a distributed current limiting control method and related devices to solve the problem that excessive concurrent access traffic will lead to concurrent resource competition, which may cause the bandwidth of the enterprise's core applications to be squeezed, thereby affecting the quality of CDN services.

[0005] In order to solve the above technical problems, this application adopts the following technical solutions:

[0006] A distributed current limiting control method is applied to any target cache cluster in a distributed content delivery network CDN cache cluster; the distributed current limiting control method comprises:

[0007] If a user request is received, current limiting configuration data is obtained; the current limiting configuration data includes the current limiting strategy corresponding to the target cache cluster and / or the current limiting strategy corresponding to the application in the target cache cluster; the current limiting strategies of different target cache clusters are the same or different; the current limiting strategies of different applications configured in the target cache cluster are the same or different; the current limiting strategy includes limiting the request rate, limiting the number of concurrent connections, or limiting the number of requests in a time window;

[0008] Determine whether the current limiting configuration data includes the current limiting policy corresponding to the target cache cluster;

[0009] If included, calling a cluster current limiting service to obtain current limiting configuration parameters of the target cache cluster, and performing a current limiting operation on the user request based on the current limiting configuration parameters of the target cache cluster;

[0010] If not included, obtain the target application that the user requests to access carried in the user request, and if the current limiting policy corresponding to the target application is included in the current limiting configuration data, perform a current limiting operation on the user request based on the current limiting policy corresponding to the target application.

[0011] Optionally, the storage process of the current limiting configuration data includes:

[0012] Monitor whether there is content update in the current limiting configuration directory corresponding to the target cache cluster;

[0013] If yes, obtain the current limiting configuration data corresponding to the target cache cluster from the configuration center;

[0014] Respond to the restart command from the management end and perform the restart operation;

[0015] After a successful restart, a cache service process loading interception operation is executed to read the current limiting configuration data and load the current limiting configuration data into the memory.

[0016] Optionally, based on the current limiting configuration parameters of the target cache cluster, performing a current limiting operation on the user request includes:

[0017] Based on the current limiting configuration parameters, determining whether to trigger a current limiting operation;

[0018] If so, the user request is intercepted and a preset current limiting fault code is fed back.

[0019] Optionally, judging whether to trigger a current limiting operation based on the current limiting configuration parameter includes:

[0020] Collect statistics on currently released requests;

[0021] Determine whether the released request data meets the current limiting condition corresponding to the current limiting configuration parameter;

[0022] If satisfied, it is determined that the current limiting operation is triggered.

[0023] Optionally, it also includes:

[0024] If it is determined that the current limiting operation is not triggered, determining whether the target data corresponding to the user request is stored locally;

[0025] If stored, output the target data;

[0026] If not stored, the target data is obtained based on a back-to-source operation, and the target data is output.

[0027] Optionally, based on the current limiting strategy corresponding to the target application, performing a current limiting operation on the user request includes:

[0028] In a case where the current limiting strategy corresponding to the target application is to limit the request rate, creating a current limiting instance based on the rate limiting parameters in the current limiting configuration data;

[0029] Define the current limiting key to obtain the current limiting return value during the current limiting process;

[0030] Determine whether to trigger a current limiting operation based on the current limiting return value;

[0031] If a current limiting operation is triggered, the user request is intercepted and a preset current limiting fault code is fed back;

[0032] If the current limiting operation is not triggered, determine whether delay processing is required based on the configured leaky bucket parameters;

[0033] If it is determined that delayed processing is required, a delayed current limiting operation is performed.

[0034] Optionally, the updating process of the current limiting configuration parameters of the target cache cluster includes:

[0035] The updated current limiting configuration parameters corresponding to the target cache cluster are obtained from the preset interface of the management end, and the updated current limiting configuration parameters are used to replace the current limiting configuration parameters of the target cache cluster stored in the memory.

[0036] A distributed current limiting control device is applied to any target cache cluster in a distributed content delivery network CDN cache cluster; the distributed current limiting control device comprises:

[0037] A data acquisition module is used to obtain current limiting configuration data if a user request is received; the current limiting configuration data includes the current limiting strategy corresponding to the target cache cluster and / or the current limiting strategy corresponding to the application in the target cache cluster; the current limiting strategies of different target cache clusters are the same or different; the current limiting strategies of different applications configured in the target cache cluster are the same or different; the current limiting strategy includes limiting the request rate, limiting the number of concurrent connections, or limiting the number of requests in a time window;

[0038] A policy judgment module, used to judge whether the current limiting configuration data includes the current limiting policy corresponding to the target cache cluster;

[0039] A first current limiting module, for, if included, invoking a cluster current limiting service to obtain current limiting configuration parameters of the target cache cluster, and performing a current limiting operation on the user request based on the current limiting configuration parameters of the target cache cluster;

[0040] The second current limiting module is used to obtain the target application that the user requests to access carried in the user request, if not included, and perform current limiting operations on the user request based on the current limiting policy corresponding to the target application when the current limiting configuration data includes the current limiting policy corresponding to the target application.

[0041] An electronic device comprises at least one processor and a memory connected to the processor, wherein:

[0042] The memory is used to store computer programs;

[0043] The processor is used to execute the computer program so that the electronic device can implement the above-mentioned distributed current limiting control method.

[0044] A computer storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the above-mentioned distributed current limiting control method.

[0045] The present application provides a distributed current limiting control method and related devices. In the present application, after receiving a user request, if it is determined that a current limiting operation needs to be performed on the user request, the current limiting operation is performed on the user request based on the current limiting strategy, thereby avoiding the problem that the CDN cache cluster responds to excessive concurrent access traffic, resulting in concurrent resource competition, and then causing the bandwidth of the enterprise's core applications to be squeezed, thereby improving the CDN service quality. In addition, in the present invention, when configuring current limiting, the current limiting strategies of different target cache clusters are the same or different, and the current limiting strategies of different applications configured in the target cache cluster are the same or different, which can adapt to the current limiting requirements of different clusters or applications, and improve the application breadth of the distributed current limiting control method. In addition, the present invention supports limiting the request rate, limiting the number of concurrent connections, and limiting the number of time window requests, which can meet different current limiting demand scenarios. In addition, when the present invention specifically executes current limiting, it first determines whether to execute the cluster current limiting strategy, and then determines whether to execute the application current limiting strategy. It can perform current limiting control from different angles based on demand, and improve the scope of application scenarios of current limiting. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0047] Figure 1 A flow chart of a distributed current limiting control method provided by an embodiment of the present invention;

[0048] Figure 2 An overall architecture for issuing current limiting configurations provided by an embodiment of the present invention;

[0049] Figure 3 A schematic diagram of request interception processing provided by an embodiment of the present invention;

[0050] Figure 4 A flowchart of a method for limiting request rate provided by an embodiment of the present invention;

[0051] Figure 5 A flowchart of a method for loading the latest current limiting configuration in a distributed cache cluster provided by an embodiment of the present invention;

[0052] Figure 6 A flow chart of hot update processing of current limiting configuration provided by an embodiment of the present invention;

[0053] Figure 7 A schematic structural diagram of a distributed current limiting control device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] In order to enable those skilled in the art to more clearly understand the present invention, the professional terms in the present invention are now explained.

[0056] CDN (Content Delivery Network): CDN is a network architecture designed to improve the efficiency and performance of network content transmission. It deploys server nodes around the world and caches content close to users, thereby enabling local access to content. CDN can effectively improve the speed and quality of content transmission, reduce network latency and congestion, and improve user experience.

[0057] Cache cluster: A cluster of multiple servers used to store and provide content cache services. In a CDN system, cache clusters are usually deployed in multiple nodes around the world to store content caches close to users, enabling local access to content and accelerating transmission.

[0058] Current limiting: Current limiting is a network traffic management mechanism that controls the rate and number of network requests to protect server resources and ensure service stability. In a CDN system, current limiting can help manage and control network traffic, prevent server overload, reduce network congestion, and improve service availability and performance.

[0059] In actual applications, content distribution network CDN is a network service based on a distributed architecture. By distributing content cache to server nodes across the country, it can increase the speed of content transmission, effectively optimize user experience, reduce network traffic, and improve network throughput and scalability.

[0060] Large enterprises involved in cross-regional business often face problems such as network delays, network congestion, and bandwidth bottlenecks. In order to ensure the stability of the business, user experience, and data transmission security of the enterprise, more and more enterprises choose to build internal content distribution networks. However, in the process of CDN cluster construction, the business access traffic in different regions is different, and the access traffic of different applications at different times in the same region is also quite different. Excessive concurrent access traffic will lead to concurrent resource competition, which may cause the bandwidth of the enterprise's core applications to be squeezed, thereby affecting the quality of CDN services. Therefore, it is necessary to have good flow limiting means to control it, protect CDN server resources, improve service quality, and ensure the reliability and stability of CDN acceleration.

[0061] In the specific flow control, in order to solve the problem of sending flow control configuration, enterprise-level CDN has hundreds or even thousands of cache servers deployed all over the country, and the flow control configuration of each cache cluster is different. When the flow control configuration is centrally managed, the cluster administrator of each cache cluster manually updates, manages and maintains it, which makes it difficult to ensure consistency and makes operation and maintenance complex. To this end, in the embodiment of the present invention, a distributed flow control configuration center is designed to uniformly manage and automatically schedule the flow control configuration of the global cache cluster, and ensure data consistency and sequential consistency, so as to avoid abnormal or unavailable flow control services due to configuration problems.

[0062] In addition, regarding the design of the current limiting strategy, due to the different current limiting scenarios, the current limiting requirements of different applications are different. How to ensure the richness of the current limiting strategy to meet different current limiting demand scenarios. In addition, there are many applications connected to the enterprise-level CDN. How to ensure that each application has an independent current limiting strategy without affecting each other. To this end, the embodiment of the present invention designs three different current limiting strategies, including limiting the request rate, limiting the number of concurrent connections, and limiting the number of time window requests. These strategies can be flexibly configured according to application requirements and cluster requirements, and the current limiting configuration of each application is independently limited by the host field in the HTTP (Hypertext Transfer Protocol) request header, so as to achieve current limiting isolation of different applications without affecting each other, thereby ensuring the stability and reliability of the system.

[0063] Regarding the hot update problem of current limiting configuration, when there is a current limiting configuration update in the cache cluster, it is usually necessary to stop or restart the cache server, which will cause the cache service to be interrupted. The embodiment of the present invention implements hot update of the current limiting configuration in the memory dictionary by designing a customized API (Application Programming Interface) interface, which can realize instant update of the current limiting configuration without stopping or restarting the server, improve the flexibility and maintainability of the system, and ensure the user experience and business continuity when the current limiting configuration update takes effect.

[0064] On the basis of the above content, an embodiment of the present invention provides a distributed current limiting control method and related devices. In this application, after receiving a user request, if it is determined that a current limiting operation needs to be performed on the user request, the current limiting operation is performed on the user request based on the current limiting strategy, thereby avoiding the problem that the CDN cache cluster responds to excessive concurrent access traffic, resulting in concurrent resource competition, and then causing the bandwidth of the enterprise's core applications to be squeezed, thereby improving the CDN service quality. In addition, in the present invention, when configuring current limiting, the current limiting strategies of different target cache clusters are the same or different, and the current limiting strategies of different applications configured in the target cache cluster are the same or different, which can adapt to the current limiting requirements of different clusters or applications, and improve the application breadth of the distributed current limiting control method. In addition, the present invention supports limiting the request rate, limiting the number of concurrent connections, and limiting the number of time window requests, which can meet different current limiting demand scenarios. In addition, when the present invention specifically executes current limiting, it first determines whether to execute the cluster current limiting strategy, and then determines whether to execute the application current limiting strategy. It can perform current limiting control from different angles based on demand, and improve the scope of application scenarios of current limiting.

[0065] Reference Figure 1 An embodiment of the present invention provides a distributed current limiting control method, which is applied to any target cache cluster in a distributed content delivery network CDN cache cluster.

[0066] In actual scenarios, such as Figure 2 As shown, the distributed cache cluster 1-n is the CDN cache cluster in the embodiment of the present invention, which is deployed in a distributed structure. The distributed cache cluster is configured with a cache service for providing cache services to users, such as providing data, videos and other content to users. The cache service includes a proxy service, and the proxy service user performs current limiting operations, including current limiting configuration updates, current limiting control and other operations.

[0067] In actual applications, for the above-mentioned distributed cache clusters 1-n, a current limiting configuration center is designed to uniformly manage and automatically schedule the current limiting configuration of cache clusters at each level of the enterprise-level CDN, ensuring the consistency and sequential consistency of the current limiting configuration and ensuring the high availability of the current limiting service. In actual scenarios, the current limiting configuration data of each distributed cache cluster may be the same or different. For example, the current limiting configuration data of distributed cache clusters in different provinces are different, and the current limiting configuration data of each distributed cache cluster in the same province are the same. The specific setting can be based on the actual configuration.

[0068] During the specific configuration, the administrator calls the management end node through the API service to control the service node. The API service can be a web configuration end, where the administrator configures the current limiting strategy. Figure 2As shown in the figure, when configuring the current limiting strategy, the platform administrator configures the cluster-level current limiting strategy or the application-level current limiting strategy on the platform management end to limit the number of requests to the server or a certain access application. The platform management end generates a current limiting strategy configuration file. The current limiting configuration data issued by the configuration center is stored in the form of a JSON (JavaScript Object Notation) file. The current limiting configuration includes fields such as cluster name, application name, current limiting type, and specific current limiting parameters. The configuration center synchronizes to the cache cluster through the configuration distribution mechanism to implement the actual current limiting operation.

[0069] To elaborate, the administrator configures the flow control policy for the cache cluster server or for a certain access application on the management side, and stores the specific configuration persistently in the database and file storage service.

[0070] After receiving the user configuration, the node configuration service on the management side generates a flow control policy configuration file and synchronizes it to the distributed cache cluster through the distribution mechanism of the configuration center. Among them, the flow control policy configuration file issued by the configuration center can adopt the master-slave backup method, in which, Figure 2 The master is the main one, and the follower is the slave. The master and slave have the same content. The master-slave backup is only set to execute the slave content when the master content is wrong or abnormal, so as to ensure the reliability of configuration delivery. The master-slave content includes the configuration content of each CDN, such as node1, node2, node3, etc.

[0071] The proxy service in the distributed cache cluster monitors the content of the configuration center in real time. When it finds that the content has changed, it updates its own current limiting configuration. The cache service loads the current limiting configuration of the cluster into the memory when it starts to implement the current limiting of user access. If during the current limiting process, for the user request that is released, if the content requested by the user is not stored locally in the distributed cache cluster, a callback operation is executed to obtain the corresponding content from the management end and feedback to the user.

[0072] Distributed current limiting control methods include:

[0073] S11. If a user request is received, obtain current limiting configuration data.

[0074] The current limiting configuration data includes a current limiting strategy corresponding to a target cache cluster and / or a current limiting strategy corresponding to an application in the target cache cluster.

[0075] For example, for distributed cache clusters 1-n, different current limiting strategies can be configured for each cluster, or the same current limiting strategy can be set for some clusters and the same current limiting strategy can be set for other clusters. For example, the current limiting strategies for clusters in each province are the same, while the current limiting strategies for clusters in different provinces are different.

[0076] In addition to configuring the current limiting strategy from the cluster perspective, you can also configure the current limiting strategy from the application perspective, such as setting one current limiting strategy for application A and another current limiting strategy for application B. In addition, you can also set current limiting strategies for both clusters and applications. For example, set a corresponding current limiting strategy for application A in cluster 1, and set a corresponding current limiting strategy for application B in cluster 2. How to configure the current limiting strategy for clusters and applications can be based on administrator needs. In the final configured current limiting strategy, the current limiting strategies of different target cache clusters are the same or different, and the current limiting strategies of different applications configured in the target cache cluster are the same or different to meet actual current limiting requirements.

[0077] In addition, the present invention supports a variety of current limiting strategies, such as limiting the request rate, limiting the number of concurrent connections, or limiting the number of time window requests.

[0078] Limiting the request rate limits traffic based on the number of requests per second. It is suitable for scenarios where the number of requests needs to be limited, such as limiting the number of requests per IP (Internet Protocol) within a certain period of time to prevent malicious requests or protect resources. Limiting the number of concurrent connections limits traffic based on the number of concurrent connections. It is suitable for scenarios where the number of concurrent connections needs to be limited to prevent system resources from being exhausted due to too many connections. Limiting the number of requests in a time window is based on a custom counter and can be flexibly configured according to specific business logic.

[0079] For clusters or applications, you can configure the above-mentioned request rate limit, concurrent connection limit, or time window request limit. For example, for cluster 1, configure its current limiting strategy to limit request rate. For application 2, configure its current limiting strategy to limit concurrent connections. For application 3 in cluster 2, configure its current limiting strategy to limit time window requests.

[0080] S12. Determine whether the current limiting configuration data includes the current limiting policy corresponding to the target cache cluster; if so, execute step S13; if not, execute step S14.

[0081] Specifically, Figure 3As shown, the user can make a routing request through HTTP, and the distributed cache cluster receives the user request. The distributed cache cluster first intercepts the request in the access stage to determine whether cluster flow control is configured. The specific judgment may be to determine whether the flow limiting configuration data includes the flow limiting policy corresponding to the target cache cluster. If included, the cluster-level flow limiting operation is performed. If not included, determine whether application flow control is configured. The specific judgment may be to determine whether the flow limiting configuration data includes the flow limiting policy corresponding to the target application accessed by the user. If included, the application-level flow limiting operation is performed. If neither cluster flow control nor application flow control is configured, the user request is released, and the cluster responds to the user request and performs the operation corresponding to the request. If the data requested by the user is not stored locally in the cluster, a back-to-source operation is performed from the management end, and the data obtained by back-to-source is stored locally and fed back to the user.

[0082] S13: Call the cluster current limiting service to obtain the current limiting configuration parameters of the target cache cluster, and perform a current limiting operation on the user request based on the current limiting configuration parameters of the target cache cluster.

[0083] Specifically, the target cache cluster's current limiting configuration parameters are as follows: Figure 3 The flow control configuration in can be obtained from the memory, and the cluster flow limiting service is called to obtain the flow limiting configuration parameters from the memory. Taking the request rate limiting as an example, the flow limiting configuration parameters can be specific rate limit values. The subsequent cluster flow limiting service performs flow limiting operations on the user request based on the flow limiting configuration parameters of the target cache cluster.

[0084] In specific implementation, the cluster current limiting service determines the current limiting type based on the current limiting configuration parameters, such as which one of limiting the request rate, limiting the number of concurrent connections, and limiting the number of time window requests. Then call the current limiting module to perform the current limiting operation. In the specific current limiting operation, based on the current limiting configuration parameters, determine whether the current limiting operation is triggered. In specific implementation, the requests that have been received and the request data that have been released can be counted. With the current limiting strategy as the number of time window requests, it can be determined whether the released request data meets the current limiting conditions of the current limiting configuration parameters, such as whether the flow or number of released requests reaches the maximum value of the number of time window requests. If it is reached, it means that the current request should not be released, then it is determined that the current limiting operation is triggered, and the user request is intercepted at this time, and the preset current limiting fault code, such as the 429 status code, is fed back to the user, so that the user understands that the current request is limited and the request cannot be executed.

[0085] If the current limit is not triggered, the request is released, and the cluster performs the operation corresponding to the user request. During the specific execution, it is determined whether the target data corresponding to the user request is stored locally. If it is stored, the target data is output to the user. If it is not stored, the target data is obtained based on the back-to-source operation and the target data is output. For example, if the user requests the bill data for this month, the cluster can query whether the user's bill for this month is stored locally. If so, the bill is sent to the user. If not, the bill can be obtained from the management end through the back-to-source operation, fed back to the user, and stored locally.

[0086] S14. Obtain a target application that the user requests to access and that is carried in the user request. If the current limiting configuration data includes a current limiting policy corresponding to the target application, perform a current limiting operation on the user request based on the current limiting policy corresponding to the target application.

[0087] Specifically, if the current limiting configuration data does not include the current limiting policy corresponding to the target cache cluster, it is further determined whether application flow control is configured. For specific implementation, refer to the above corresponding description.

[0088] Reference Figure 4 , taking the current limiting strategy corresponding to the target application as limiting the request rate as an example, the current limiting process at the application level is introduced. If it is determined that there is application flow control, the target application that the user request carries in the user request can be obtained, specifically, the application host information can be obtained from the user request header, and then it is determined that the current limiting configuration data includes the current limiting strategy corresponding to the target application host. If yes, the current limiting type is specifically obtained, such as the above-mentioned limiting request rate, limiting the number of concurrent connections, or limiting the number of requests in the time window, and then the current limiting module can be called according to the current limiting strategy corresponding to the target application to perform current limiting operations on the user request.

[0089] To expand, the current limiting process is:

[0090] According to the host, the rate limiting parameters in the current limiting configuration data are obtained from the memory, and based on the rate limiting parameters, the rate limiting parameters are defined. Based on the defined parameters, a current limiting instance is created, and the current limiting key is defined to perform current limiting processing. During the current limiting processing, the current limiting return value is obtained, and finally, it is determined whether the current limiting is triggered based on the return value. If triggered, the request will be intercepted and the preset current limiting fault code (such as 429 status code) will be fed back. Otherwise, it is determined whether to perform delay processing based on whether the leaky bucket parameters are configured. If it is determined that delay processing is required, a delayed current limiting operation is performed.

[0091] The leaky bucket parameter is a parameter in the leaky bucket algorithm, which is the core algorithm for current limiting. The core algorithms for current limiting mainly include the token bucket algorithm and the leaky bucket algorithm. Both algorithms are flow control algorithms based on fixed time windows, which can limit and adjust requests.

[0092] The token bucket algorithm maintains a token bucket containing a certain number of tokens. Each token represents the permission of a request, and the token bucket adds tokens to the bucket at a certain rate. When a request arrives, if there are enough tokens in the bucket, the request is allowed to pass and consumes a token; if there are not enough tokens in the bucket, the request is restricted. By controlling the generation rate and consumption rate of tokens, the flow control of requests can be achieved.

[0093] The leaky bucket algorithm simulates a leaky bucket. Requests are regarded as water drops, and water drops are injected into the leaky bucket at a fixed rate. When a request arrives, if the bucket is not full, the request is allowed to pass and consumes a water drop from the leaky bucket; if the bucket is full, the request is restricted. By controlling the injection rate and the leakage rate, the flow control of requests can be achieved.

[0094] In the implementation of current limiting, the current limiting strategy needs to be defined in advance, including limiting parameters such as request rate and number of concurrent connections. These limiting parameters can be configured according to the characteristics of the system and business requirements to achieve precise current limiting control. Whenever a request arrives, the script will perform traffic statistics on the request. By counting the number of requests and the time window, it can be determined whether the limit of the current limiting strategy is exceeded. If the limit is exceeded, the request is rejected; if the limit is not exceeded, the request is allowed to pass and the traffic statistics are updated.

[0095] The leaky bucket algorithm is also configured with a delay current limiting strategy. If it is determined based on the configured leaky bucket parameters that delay processing is required, the corresponding delay current limiting operation is performed. Specifically, in the leaky bucket algorithm, when the bucket is full, in addition to being directly intercepted and rejected, new incoming requests can also be processed in a delayed manner. At this time, a delay is made for a period of time, and the current limiting strategy is analyzed again. If it is determined that current limiting operation is still required, the request is intercepted and a 429 status code is returned.

[0096] In the above embodiments, current limiting operations are performed at the cluster and application levels, that is, the request will be intercepted at the access stage, and whether the node is configured with cluster current limiting is determined by querying whether there is cluster current limiting configuration data in the shared memory. Similarly, whether current limiting interception is performed is determined by querying whether there is current limiting configuration data of the application to which the request belongs in the shared memory. If the current limiting strategy is configured, the current limiting module will be called, which includes different current limiting types such as limiting the request rate, limiting the number of concurrent connections, and limiting the number of requests in the time window. Based on the current limiting type to which the request belongs, the corresponding current limiting method is called to determine whether it exceeds the limit. If it exceeds the limit, the request will be intercepted and returned, and if it does not exceed the limit, the request will be released.

[0097] In addition, you can also configure the flow control operations of the cluster and the application at the same time, such as flow control operations on application A in cluster 1. At this time, first determine whether the request meets the cluster flow control. If it does, then limit the request flow according to the cluster flow control. If the flow control determines that it needs to be released, then continue to apply the application flow control to determine whether to limit or release.

[0098] In this embodiment, after receiving a user request, if it is determined that a flow limiting operation needs to be performed on the user request, a flow limiting operation is performed on the user request based on a flow limiting strategy, thereby avoiding the problem that the CDN cache cluster responds to excessively high concurrent access traffic, resulting in concurrent resource competition, and then causing the bandwidth of the enterprise's core applications to be squeezed, thereby improving the CDN service quality. In addition, in the present invention, when configuring flow limiting, the flow limiting strategies of different target cache clusters are the same or different, and the flow limiting strategies of different applications configured in the target cache cluster are the same or different, which can adapt to the flow limiting requirements of different clusters or applications, and improve the application breadth of the distributed flow limiting control method. In addition, the present invention supports limiting the request rate, limiting the number of concurrent connections, and limiting the number of time window requests, which can meet different flow limiting demand scenarios. In addition, when the present invention specifically executes flow limiting, it first determines whether to execute the cluster flow limiting strategy, and then determines whether to execute the application flow limiting strategy. It can perform flow limiting control from different angles based on demand, and improve the scope of application scenarios of flow limiting.

[0099] In addition, the current flow limiting method is a flow limiting management solution based on Nginx. In practical applications, Nginx itself provides a flow limiting module to achieve flow limiting, but the flow limiting module of Nginx is usually configured and effective on a single server, and it is impossible to achieve centralized management and dynamic distribution of flow limiting configuration. In the embodiment of the present invention, centralized management of multiple distributed cache clusters and dynamic distribution according to actual needs are achieved through the management end and the configuration center, thereby improving the ability of unified management of cache clusters.

[0100] In addition, the design includes three flow limiting strategy mechanisms, including limiting request rate, number of concurrent connections, and number of time window requests. And the flow limiting configuration of each application is carried out through the host field in the HTTP request header to limit the flow of different applications. The flow limits of different applications are isolated from each other, ensuring the stability and reliability of the system.

[0101] The above embodiment introduces that the current limiting configuration data needs to be stored in the memory. The present embodiment introduces the storage process of the current limiting configuration data. Figure 5 , the proxy end refers to the proxy service in the cache service in the distributed cache cluster. The configuration center generally stores the current limiting configuration data in the specified current limiting configuration directory. The paths of the current limiting configuration directories corresponding to different clusters are different. The proxy service will monitor whether there are any content updates in the current limiting configuration directory corresponding to the target cache cluster. During specific monitoring, the distributed cache cluster proxy service always monitors the directory by configuring the monitoring class. Once the current limiting configuration in the current limiting configuration directory is found to have changed, the cluster will immediately obtain the latest current limiting configuration data of the cluster from the configuration center, replace and update the local current limiting file, so that the cluster always has the latest current limiting strategy and can perform corresponding current limiting operations according to the configuration.

[0102] After the current limiting file is updated, the status information will be returned to the management end, such as the update is completed, so that the management end can confirm the cluster status information. If the cluster update is confirmed to be completed, a restart command for restarting the cache to take effect is issued. After the proxy service receives the request, it performs a restart operation. After a successful restart, the cache service will perform a loading operation. At this time, the current limiting script will perform a cache service process loading interception operation in the initialization phase, read the latest current limiting configuration data, and if the data content is not empty, load the current limiting configuration data into the memory. The data in the memory is in a key-value pair format, with the key key being the unique application host identifier or cluster identifier of the application, and the value value being the current limiting configuration of the application or cluster. After the data is loaded into the memory, the cache service continues to perform the loading service. After the loading is completed, after the distributed node, that is, the distributed cache cluster, receives the request, it can determine whether to intercept and perform the current limiting operation based on whether the cluster or the application to which the request belongs is configured with current limiting. Specifically, when a user initiates a resource access request, the cache cluster node intercepts and determines the request according to the current limiting strategy. If the current limiting requirement is not met, it is released and the resource is obtained from the cache node; if the current limiting requirement is met, access is directly denied. When the cache node has no cache, it returns to the origin site to request resources.

[0103] If the data content is empty, the step of loading the current limiting configuration data into the memory is not executed, and the cache service continues to perform the loading operation.

[0104] Based on this embodiment, an update operation of the current limiting configuration parameters of the target cache cluster is supported, and the update process includes:

[0105] Obtain updated current limiting configuration parameters corresponding to the target cache cluster from a preset interface of the management end, and replace the current limiting configuration parameters of the target cache cluster stored in the memory with the updated current limiting configuration parameters.

[0106] Specifically, for the current limiting management solution based on Nginx, when updating the current limiting configuration, it is usually necessary to modify the Nginx configuration file and restart the server, which will cause business interruption and downtime, which will cause cache service interruption. In an embodiment of the present invention, a method for updating the current limiting configuration is provided to realize hot update of the current limiting configuration in the memory. Instant update of the current limiting configuration is achieved without stopping or restarting the server, improving the flexibility and maintainability of the system. Specifically, a set of preset ports of the management end can be customized, such as an API interface. If the administrator needs to update the current limiting configuration parameters, the latest current limiting configuration parameters can be configured on the web configuration end of the management end. The management end calls the API interface to send the current limiting configuration to be updated, that is, to send the latest current limiting configuration parameters to the cache service in the cluster. The cache service obtains the current limiting configuration parameters to be updated from the sent data, and then interacts with the current limiting configuration dictionary maintained in the memory for storing the current limiting configuration data in the interface to achieve the purpose of updating the current limiting configuration parameters. After the update is completed, the interface status is returned to the management end so that the management end can understand the latest status. The specific interaction process is as follows Figure 6 shown.

[0107] This method allows administrators to implement hot updates of current limiting configurations by calling the interface, and update the current limiting policy without restarting the cache service. This greatly reduces the downtime of system maintenance and improves the availability and stability of the system.

[0108] It can be seen from the above that an embodiment of the present invention provides a distributed current limiting design method for an enterprise-level content distribution network. The current limiting configuration data issued by the configuration center is stored in the form of a JSON file. The current limiting configuration includes fields such as cluster name, application name, current limiting type, and specific current limiting parameters. It meets different current limiting scenarios with different current limiting requirements for clusters or applications, ensures the richness of current limiting strategies, and sets current limiting for applications or clusters separately, so that clusters or applications can have independent current limiting strategies without affecting each other.

[0109] Each cache cluster will count the request traffic when it receives a request. By counting the number of requests and the time window, it can be determined whether the limit of the current limiting policy is exceeded. If the limit is exceeded, the node can take corresponding current limiting measures, such as rejecting the request, delaying processing, etc., to ensure the stability and reliability of the system, realize the traffic control of the cache cluster, protect the CDN server resources, improve the service quality, and ensure the reliability and stability of CDN acceleration.

[0110] In this embodiment, in a distributed cluster environment, by limiting the request flow of the system, it is possible to effectively prevent the system from being overloaded and affected by malicious requests, improve the processing capacity and response speed of the system, and protect the stability and reliability of the system.

[0111] Based on the above-mentioned embodiment of the distributed current limiting control method, another embodiment of the present invention provides a distributed current limiting control device, which is applied to any target cache cluster in a distributed content delivery network CDN cache cluster. Figure 7 , the distributed current limiting control device comprises:

[0112] The data acquisition module 11 is used to obtain the current limiting configuration data if a user request is received; the current limiting configuration data includes the current limiting strategy corresponding to the target cache cluster and / or the current limiting strategy corresponding to the application in the target cache cluster; the current limiting strategies of different target cache clusters are the same or different; the current limiting strategies of different applications configured in the target cache cluster are the same or different; the current limiting strategy includes limiting the request rate, limiting the number of concurrent connections, or limiting the number of requests in a time window;

[0113] A policy determination module 12 is used to determine whether the current limiting configuration data includes a current limiting policy corresponding to the target cache cluster;

[0114] A first current limiting module 13, for, if included, calling a cluster current limiting service to obtain current limiting configuration parameters of the target cache cluster, and performing a current limiting operation on the user request based on the current limiting configuration parameters of the target cache cluster;

[0115] The second current limiting module 14 is used to obtain the target application that the user requests to access carried in the user request, if not included, and perform a current limiting operation on the user request based on the current limiting policy corresponding to the target application when the current limiting configuration data includes a current limiting policy corresponding to the target application.

[0116] In one implementation, a storage module is also included, and the storage module includes:

[0117] A monitoring submodule, used to monitor whether there is content update in the current limiting configuration directory corresponding to the target cache cluster;

[0118] A data acquisition submodule, used for obtaining the current limiting configuration data corresponding to the target cache cluster from the configuration center;

[0119] The restart submodule is used to respond to the restart command from the management end and perform the restart operation;

[0120] The data loading submodule is used to perform a cache service process loading interception operation after a successful restart to read the current limiting configuration data and load the current limiting configuration data into the memory.

[0121] In one implementation, the first current limiting module 13 includes:

[0122] A current limiting judgment submodule, used to judge whether to trigger a current limiting operation based on the current limiting configuration parameters;

[0123] The request interception submodule is used to intercept the user request and feedback a preset current limiting fault code.

[0124] In one implementation, the current limiting judgment submodule is specifically used for:

[0125] The current released request data is counted to determine whether the released request data satisfies the current limiting condition corresponding to the current limiting configuration parameter. If so, it is determined to trigger the current limiting operation.

[0126] In one implementation, it also includes a request execution module, which is used to determine whether the target data corresponding to the user request is stored locally if it is determined that the current limiting operation is not triggered. If stored, the target data is output; if not stored, the target data is obtained based on a back-to-source operation and the target data is output.

[0127] In one implementation, the second current limiting module 14 includes:

[0128] An instance creation submodule, used to create a current limiting instance based on the rate limiting parameters in the current limiting configuration data when the current limiting strategy corresponding to the target application is to limit the request rate;

[0129] Define submodules to define current limiting keys to obtain current limiting return values ​​during current limiting processing;

[0130] A trigger judgment submodule, used to judge whether to trigger a current limiting operation based on the current limiting return value;

[0131] The request processing submodule is used to intercept the user request and feedback a preset current limiting fault code if a current limiting operation is triggered;

[0132] The delay judgment submodule is used to determine whether delay processing is required based on the configured leaky bucket parameters if the current limiting operation is not triggered;

[0133] The delay processing submodule is used to perform a delay current limiting operation if it is determined that delay processing is required.

[0134] In one implementation, an update module is also included, which is used to:

[0135] Obtain updated current limiting configuration parameters corresponding to the target cache cluster from a preset interface of the management end, and replace the current limiting configuration parameters of the target cache cluster stored in the memory with the updated current limiting configuration parameters.

[0136] In this embodiment, after receiving a user request, if it is determined that a flow limiting operation needs to be performed on the user request, a flow limiting operation is performed on the user request based on a flow limiting strategy, thereby avoiding the problem that the CDN cache cluster responds to excessively high concurrent access traffic, resulting in concurrent resource competition, and then causing the bandwidth of the enterprise's core applications to be squeezed, thereby improving the CDN service quality. In addition, in the present invention, when configuring flow limiting, the flow limiting strategies of different target cache clusters are the same or different, and the flow limiting strategies of different applications configured in the target cache cluster are the same or different, which can adapt to the flow limiting requirements of different clusters or applications, and improve the application breadth of the distributed flow limiting control method. In addition, the present invention supports limiting the request rate, limiting the number of concurrent connections, and limiting the number of time window requests, which can meet different flow limiting demand scenarios. In addition, when the present invention specifically executes flow limiting, it first determines whether to execute the cluster flow limiting strategy, and then determines whether to execute the application flow limiting strategy. It can perform flow limiting control from different angles based on demand, and improve the scope of application scenarios of flow limiting.

[0137] It should be noted that, for the working process of each module and sub-module in this embodiment, please refer to the corresponding description in the above embodiment, which will not be repeated here.

[0138] An embodiment of the present application also provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:

[0139] The memory is used to store computer programs;

[0140] The processor is used to execute the computer program so that the electronic device can implement the above-mentioned distributed current limiting control method.

[0141] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any of the distributed current limiting control methods provided in the embodiments of the present application.

[0142] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any distributed current limiting control method provided in the embodiment of the present application.

[0143] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A distributed current limiting control method, characterized in that: Applied to any target cache cluster in a distributed content delivery network CDN cache cluster; the distributed current limiting control method includes: If a user request is received, current limiting configuration data is obtained; the current limiting configuration data includes the current limiting strategy corresponding to the target cache cluster and / or the current limiting strategy corresponding to the application in the target cache cluster; the current limiting strategies of different target cache clusters are the same or different; the current limiting strategies of different applications configured in the target cache cluster are the same or different; the current limiting strategy includes limiting the request rate, limiting the number of concurrent connections, or limiting the number of requests in a time window; Determine whether the current limiting configuration data includes the current limiting policy corresponding to the target cache cluster; If included, calling a cluster current limiting service to obtain current limiting configuration parameters of the target cache cluster, and performing a current limiting operation on the user request based on the current limiting configuration parameters of the target cache cluster; If not included, obtain the target application that the user requests to access carried in the user request, and if the current limiting configuration data includes a current limiting policy corresponding to the target application, perform a current limiting operation on the user request based on the current limiting policy corresponding to the target application.

2. The distributed current limiting control method according to claim 1, characterized in that: The storage process of the current limiting configuration data includes: Monitor whether there is content update in the current limiting configuration directory corresponding to the target cache cluster; If yes, obtain the current limiting configuration data corresponding to the target cache cluster from the configuration center; Respond to the restart command from the management end and perform the restart operation; After a successful restart, a cache service process loading interception operation is executed to read the current limiting configuration data and load the current limiting configuration data into the memory.

3. The distributed current limiting control method according to claim 1, characterized in that: Based on the current limiting configuration parameters of the target cache cluster, a current limiting operation is performed on the user request, including: Based on the current limiting configuration parameters, determining whether to trigger a current limiting operation; If so, the user request is intercepted and a preset current limiting fault code is fed back.

4. The distributed current limiting control method according to claim 3, characterized in that: Based on the current limiting configuration parameters, determining whether to trigger a current limiting operation includes: Collect statistics on currently released requests; Determine whether the released request data meets the current limiting condition corresponding to the current limiting configuration parameter; If satisfied, it is determined that the current limiting operation is triggered.

5. The distributed current limiting control method according to claim 3, characterized in that: Also includes: If it is determined that the current limiting operation is not triggered, determining whether the target data corresponding to the user request is stored locally; If stored, output the target data; If not stored, the target data is obtained based on a back-to-source operation, and the target data is output.

6. The distributed current limiting control method according to claim 1, characterized in that: Based on the current limiting strategy corresponding to the target application, a current limiting operation is performed on the user request, including: In a case where the current limiting strategy corresponding to the target application is to limit the request rate, creating a current limiting instance based on the rate limiting parameters in the current limiting configuration data; Define the current limiting key to obtain the current limiting return value during the current limiting process; Determine whether to trigger a current limiting operation based on the current limiting return value; If a current limiting operation is triggered, the user request is intercepted and a preset current limiting fault code is fed back; If the current limiting operation is not triggered, determine whether delay processing is required based on the configured leaky bucket parameters; If it is determined that delayed processing is required, a delayed current limiting operation is performed.

7. The distributed current limiting control method according to claim 1, characterized in that: The updating process of the current limiting configuration parameters of the target cache cluster includes: The updated current limiting configuration parameters corresponding to the target cache cluster are obtained from the preset interface of the management end, and the updated current limiting configuration parameters are used to replace the current limiting configuration parameters of the target cache cluster stored in the memory.

8. A distributed current limiting control device, characterized in that: Applicable to any target cache cluster in a distributed content delivery network CDN cache cluster; the distributed current limiting control device includes: A data acquisition module is used to obtain current limiting configuration data if a user request is received; the current limiting configuration data includes the current limiting strategy corresponding to the target cache cluster and / or the current limiting strategy corresponding to the application in the target cache cluster; the current limiting strategies of different target cache clusters are the same or different; the current limiting strategies of different applications configured in the target cache cluster are the same or different; the current limiting strategy includes limiting the request rate, limiting the number of concurrent connections, or limiting the number of requests in a time window; A policy judgment module, used to judge whether the current limiting configuration data includes the current limiting policy corresponding to the target cache cluster; A first current limiting module, for, if included, invoking a cluster current limiting service to obtain current limiting configuration parameters of the target cache cluster, and performing a current limiting operation on the user request based on the current limiting configuration parameters of the target cache cluster; The second current limiting module is used to obtain the target application that the user requests to access carried in the user request, if not included, and perform current limiting operations on the user request based on the current limiting policy corresponding to the target application when the current limiting configuration data includes the current limiting policy corresponding to the target application.

9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the distributed current limiting control method as described in any one of claims 1 to 7.

10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the distributed current limiting control method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • API distributed current limiting implementation method

    CN110276182A

  • Current limiting method and device based on application program, equipment, medium and product

    CN112804160A

  • Flow limiting method and device for access request, electronic equipment and storage medium

    CN113285883A

  • Distributed cluster current limiting system and method and distributed cluster node

    CN113923216A

  • Current limiting processing method and device, electronic equipment and computer readable medium

    CN116846831A

Cited By

  • Content distribution method and system, electronic equipment, storage medium and program product

    CN121217653A