Self-adaptive multi-dimensional flow control method, system, equipment and medium

Through the adaptive multi-dimensional flow control method, the key-value pair information requested by the client is analyzed to match the flow control configuration strategy, and dynamic adjustment strategy is combined with the token bucket status information, which solves the problem of difficulty in dynamically adjusting the traffic control strategy in the existing technology, and realizes efficient and flexible traffic management, improving the stability and user experience of the system.

CN119697121AActive Publication Date: 2025-03-25SINOPHARM HEALTH SOLUTIONS (SHANGHAI) CO LTD

Patent Information

Application Number
CN202411752007.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-25
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

In a highly concurrent network environment, it is difficult for the prior art to dynamically adjust traffic control strategies based on real-time network traffic conditions and business needs, resulting in inefficient server processing and poor user experience.

Method used

Adaptive multi-dimensional flow control method is adopted to match the information with the preset flow control configuration strategy by analyzing the key value requested by the client, and dynamically adjust the flow control strategy in combination with the token bucket status information to achieve real-time traffic management.

Benefits of technology

It improves the efficiency of request information processing, realizes refined traffic control, has good scalability and flexibility, and can self-adjust according to real-time request characteristics and system status, improving the robustness and stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697121A_ABST
    Figure CN119697121A_ABST
Patent Text Reader

Abstract

The invention provides a self-adaptive multi-dimensional flow control method, system and device and a medium. The method comprises the following steps: creating a flow control configuration strategy based on service requirements; receiving and analyzing a client request to obtain corresponding key value pair information; matching the key value pair information with the flow control configuration strategy to obtain a matching result; and dynamically adjusting the flow control configuration strategy based on the matching result to obtain an execution strategy, thereby executing a flow control operation based on the execution strategy. According to the adaptive multi-dimensional flow control method, system and equipment and the medium, the technical problems of low efficiency of extraction of mass request information, limitation and static property of flow control and insufficient system expansibility in a high-concurrency network environment are solved, the request information processing efficiency is remarkably improved, and the service life of the system is prolonged. Fine flow control is achieved, and certain expandability and flexibility are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of flow control, and in particular relates to an adaptive multi-dimensional flow control method, system, device and medium. Background Art

[0002] In modern network applications and services, a large number of requests are processed on the server side. With the expansion of network scale and the sharp increase in the number of requests, the server is facing tremendous pressure. At present, the server side often lacks a unified and efficient processing method when extracting request information; in terms of traffic management, the traditional fixed parameter control method is no longer sufficient to cope with the complex and changing network environment, which leads to low efficiency of the server when processing massive requests and difficulty in ensuring user experience.

[0003] Therefore, how to provide a traffic management method to solve the above problems has become a technical problem that technical personnel in this field urgently need to overcome. Summary of the invention

[0004] The purpose of the present invention is to provide an adaptive multi-dimensional flow control method, system, medium and device to solve the problem that the control strategy cannot be dynamically adjusted according to the real-time network flow status and business needs in a high-concurrency network environment.

[0005] In a first aspect, the present invention provides an adaptive multi-dimensional flow control method, the method comprising the following steps: creating a flow control configuration strategy based on business needs, wherein the flow control configuration strategy includes setting flow control rules, configuring flow control parameters, and maintaining token bucket status information; receiving and parsing the client request to obtain corresponding key-value pair information; matching the extracted key-value pair information with the flow control configuration strategy to obtain a matching result; dynamically adjusting the flow control configuration strategy based on the matching result to obtain an execution strategy, thereby performing flow control operations based on the execution strategy.

[0006] In this implementation, by parsing the key-value pair information obtained from the client request and matching it with the preset flow control configuration strategy, and continuously adjusting it in combination with the token bucket status information to determine the flow control decision and flow control operation corresponding to the client request, the technical effect of dynamically adjusting the control strategy according to the real-time network traffic status and business needs can be achieved.

[0007] In an implementation of the first aspect, receiving and parsing the client request and obtaining corresponding key-value pair information includes the following steps: identifying request characteristics of the client request, wherein the request characteristics include customer attribute characteristics and behavior characteristics; extracting the target field of the client request based on the request characteristics and converting it into corresponding key-value pair information.

[0008] In this implementation, by identifying customer attribute characteristics and behavior characteristics, the characteristics of client requests can be fully understood from multiple perspectives. The process of converting target fields into key-value pairs allows the structure and content of data to be flexibly defined according to different business needs. You can choose which dimensions of data to focus on based on specific analysis goals or application scenarios, thereby providing more customized services.

[0009] In an implementation of the first aspect, creating a flow control configuration strategy based on business needs includes the following steps: setting flow control rules based on the business needs of the flow control strategy, and configuring corresponding flow control parameters for the flow control rules; initializing the status information of the token bucket based on the flow control parameters, and obtaining a preset flow control strategy to guide the flow management process; wherein the flow control parameters include core control parameters, condition matching parameters, custom behavior parameters, and priority parameters.

[0010] In this implementation, through specific flow control rules and refined parameter configuration, the most appropriate flow control strategy can be formulated for different application scenarios, and can also be adjusted according to actual needs, thereby optimizing system performance and resource utilization.

[0011] In an implementation of the first aspect, the traffic control rules include: static configuration rules and dynamic configuration rules; the static configuration rules are set by annotating parameters inside the code, and are used for static resource configuration, fixed business logic, and system configuration with low change frequency; the dynamic configuration rules are set through an external configuration center, and are used for dynamic resource configuration, business logic with high change frequency, and system configuration adjusted in real time; wherein, the dynamic configuration rules are set by the nacos configuration center.

[0012] In this implementation, by combining static and dynamic configuration rules, different types of resources and business logic can be flexibly managed. Using the nacos configuration center enables the present invention to update configuration information in real time without shutting down the system, significantly improving the flexibility and response speed of the system.

[0013] In an implementation of the first aspect, the extracted key-value pair information is matched with the traffic control policy, and obtaining the matching result includes the following steps: identifying the traffic control rule corresponding to the key-value pair information in the traffic control policy; performing field matching on the key-value pair information and the traffic control parameters configured in the traffic control rule to obtain a preliminary matching result; performing conditional matching on the preliminary matching result and the traffic control parameters configured in the traffic control rule to obtain a final matching result.

[0014] In this implementation, by accurately matching and dynamically adjusting the key-value pair information and the flow control configuration strategy, it is ensured that corresponding control measures are taken for specific traffic types or user behaviors, thereby achieving effective control and management of network traffic.

[0015] In an implementation of the first aspect, the matching result is combined with the status information of the token bucket to identify the need to adjust the flow control configuration policy; based on the need to adjust the flow control configuration policy, the status information of the token bucket is adjusted to obtain the execution policy; the flow control operation is performed based on the execution policy; wherein the status information of the token bucket includes the current number of tokens, the token generation rate, the token consumption rate, and the token bucket capacity.

[0016] In this implementation, by dynamically adjusting the flow control configuration strategy, it is possible to flexibly respond to real-time traffic fluctuations. Combined with the status information of the token bucket, network resources can be managed and allocated more accurately to ensure efficient use of resources. The dynamic adjustment mechanism enables the system to better respond to sudden traffic and abnormal situations, and improves the robustness and stability of the system.

[0017] In an implementation of the first aspect, the method also includes an exception handling mechanism: classifying the detected client exception requests to obtain the exception request classification, wherein the exception request classification includes temporary exceptions, recoverable exceptions, and systemic exceptions; setting corresponding exception handling strategies for different categories of exception requests, wherein the exception handling strategies include ignoring exceptions, retrying requests, and notifying alarms; and performing corresponding flow control operations according to the exception request classification and the exception handling strategy.

[0018] In this implementation, the stability and reliability of traffic management are improved by introducing an exception handling mechanism. The risk of crash is reduced and the user experience and service quality are improved by classifying and processing abnormal requests in a targeted manner.

[0019] In a second aspect, the present invention provides an adaptive multi-dimensional flow control system, comprising: an information extraction module, used to receive and parse the client request to obtain corresponding key-value pair information; a flow control policy configuration module, used to create a flow control configuration policy based on business needs, wherein the flow control configuration policy includes defining flow control rules, configuring flow control parameters, and maintaining token bucket status information; a flow control decision module, used to match the extracted key-value pair information with the flow control policy to obtain a matching result; dynamically adjust the flow control configuration policy based on the matching result to determine the flow control decision requested by the client and perform flow control operations; a token bucket management module, used to configure parameters of the token bucket based on the flow control policy configuration module, and dynamically adjust the flow control policy configuration module based on the flow control decision module to implement flow control operations.

[0020] In a third aspect, the present invention provides an electronic device, the electronic device comprising: a processor and a memory;

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

[0022] The processor is used to execute the computer program stored in the memory so that the electronic device executes the above-mentioned adaptive multi-dimensional flow control method.

[0023] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by an electronic device, implements the above-mentioned adaptive multi-dimensional flow control method.

[0024] As described above, the adaptive multi-dimensional flow control method, system, device and medium of the present invention have the following features:

[0025] Beneficial effects:

[0026] The present invention significantly improves the efficiency of request information processing: through a unified information extraction module, key-value pair information can be accurately and efficiently extracted from the header, request parameters and post request body at the same time, avoiding the complexity and inefficiency caused by processing different request parts separately. This comprehensive processing method can reduce the time and resource consumption of information extraction and improve the server's processing speed for requests.

[0027] The present invention realizes refined flow control: the flow control strategy realized by combining the key-value pair information of the request and the token bucket algorithm can perform more refined flow control according to the content and source of the request. For example, different flow quotas can be allocated to different types of users (according to the identifier in the request header or parameter) and different types of requests (according to the specific parameters in the request body), so as to better utilize the server resources and improve the overall performance and stability of the system.

[0028] The present invention has good scalability and flexibility: new request information extraction rules can be added or flow control strategies can be adjusted based on demand to adapt to the ever-changing network environment and business needs. For example, attention to specific request headers or request body fields can be increased according to new business logic, or token bucket parameters can be modified to adapt to different traffic patterns. Through dynamic flow control strategies, the system can adjust itself according to real-time request characteristics and system status, which enables the system to respond more flexibly and effectively when facing different traffic patterns. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 Shown is an application scenario diagram of the adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0030] Figure 2 It is a step diagram of an adaptive multi-dimensional flow control method in one embodiment of the present invention;

[0031] Figure 3a Shown is a flow control strategy configuration module diagram of an adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0032] Figure 3b Shown is a schematic diagram of a flow control mode of an adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0033] Figure 3c Shown is a schematic diagram of parameter configuration of an adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0034] Figure 4 It is a diagram showing an information extraction module of an adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0035] Figure 5a Shown is a flow control decision module diagram of an adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0036] Figure 5b A diagram showing the matching process steps of the adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0037] Figure 6 It is a structural diagram of an adaptive multi-dimensional flow control method in one embodiment of the present invention;

[0038] Figure 7 It is a flow chart showing an adaptive multi-dimensional flow control system of the present invention in one embodiment;

[0039] Figure 8 Shown is a schematic diagram of the system structure of an adaptive multi-dimensional flow control method of the present invention in one embodiment;

[0040] Fig. 9 It is a schematic structural diagram of an electronic device of the present invention in one embodiment. DETAILED DESCRIPTION

[0041] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0042] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0043] like Figure 1 As shown, the HTTP of the present invention uses a client-server model, and multiple clients send requests to the server, and the request contains the URL of the resource to be accessed, the request header (for example, Accept, User-Agent) and the optional request body (for POST or PUT requests). After receiving the request, the server finds the corresponding resource according to the information in the request and performs the corresponding processing operation.

[0044] The technical solutions in the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0045] like Figure 2 As shown, in one embodiment, the adaptive multi-dimensional flow control method of the present invention includes steps S11 to S14.

[0046] Step S11: Create a flow control configuration strategy based on business needs, wherein the flow control configuration strategy includes defining flow control rules, configuring flow control parameters, and maintaining status information of token buckets;

[0047] Specifically, creating a flow control configuration strategy based on business requirements includes the following steps:

[0048] Setting flow control rules based on the business requirements of the flow control strategy, and configuring corresponding flow control parameters for the flow control rules;

[0049] Initialize the status information of the token bucket based on the flow control parameter to obtain a preset flow control strategy to guide the flow management process;

[0050] The flow control parameters include core control parameters, condition matching parameters, custom behavior parameters, and priority parameters. The core control parameters directly affect the core logic and behavior of flow control, including: rate, mode, bucketCapacity, requestedTokens; the condition matching parameters are used to define which requests should be affected by the flow control rules, including: uri, filterConditions (including fieldName, fieldValue), source; the custom behavior parameters define the specific actions that the system should take when the flow control is triggered, including: fallbackFunction, customKeyFunction; the priority parameters are used to specify the execution order or priority between different flow control rules, including: rateExpression, rateInterval, bucketCapacityExpression.

[0051] Further, the flow control rules include: static configuration rules and dynamic configuration rules;

[0052] The static configuration rules are set by annotating parameters in the code and are used for static resource configuration, fixed business logic, and system configuration with low change frequency;

[0053] The dynamic configuration rules are set by an external configuration center and are used for dynamic resource configuration, business logic with high frequency of change, and system configuration adjusted in real time;

[0054] The dynamic configuration rules are set by the nacos configuration center.

[0055] (1) Figure 3a to Figure 3c As shown in the figure, static configuration is usually suitable for scenarios where flow control rules do not change frequently, such as static resource configuration, fixed business logic, and system configuration with low change frequency.

[0056] 1) Static resource configuration

[0057] In many application scenarios, the configuration of flow control rules is relatively fixed and does not need to be changed frequently. For example, the internal management systems of some enterprises and the portal websites of government agencies have relatively stable access traffic and fixed user groups. Therefore, the flow control rules can be set to fixed parameters, such as a time window of 10 tokens per minute and a fixed token bucket capacity.

[0058] 2) Fixed business logic

[0059] For systems with relatively fixed business processes that are not easily changed, the flow control rules do not need to be adjusted frequently. For example, the payment gateway in the financial system, the order processing module of the e-commerce website, etc., the request patterns and parameters in these scenarios are relatively fixed, and the flow control strategy can be set based on these fixed patterns without frequent updates.

[0060] 3) System configuration with low frequency of change

[0061] In some systems that require flow control management but do not have high real-time requirements, flow control rules can remain unchanged for a long time. For example, internal report generation systems and data analysis platforms in enterprises usually do not frequently adjust flow control strategies due to business changes, so static configuration can be used.

[0062] When the flow control rules do not change frequently, static configuration is suitable. This method is simple, direct, easy to implement and manage. For some systems with stable traffic, fixed business logic or low frequency of change, static configuration can provide sufficient flexibility and stability.

[0063] Furthermore, static configuration is achieved by using the @RateLimit annotation in the code and setting the corresponding parameters. This configuration method is simple to configure and can be directly declared in the code, making it easy to understand and maintain. The specific static flow control parameters are as follows:

[0064] mode: This parameter defines the implementation algorithm of the flow control strategy. There are two flow control modes: TIME_WINDOW (based on the time window mode) and TOKEN_BUCKET (based on the token bucket algorithm mode). The time window mode allows a certain number of requests to be processed within a specific time window. Based on the token bucket algorithm, tokens are generated at a fixed rate, and requests need to consume tokens before they can be processed. The default setting is TOKEN_BUCKET.

[0065] rate: This parameter has different meanings depending on the mode. In TIME_WINDOW mode, it indicates the maximum number of requests allowed in each time window. In TOKEN_BUCKET mode, it indicates the number of tokens generated per second, that is, the maximum number of requests allowed per second. The default value is 1.

[0066] bucketCapacity: In TOKEN_BUCKET mode, this parameter defines the capacity of the token bucket, and its size determines the maximum concurrency of the interface under the current limiting rules.

[0067] requestedTokens: This parameter defines the number of tokens that need to be consumed for each request. It is usually 1, but can be adjusted in special cases.

[0068] keys: This parameter specifies the key value of the flow control policy object. There can be multiple keys to distinguish different request sources or types.

[0069] fallbackFunction: When a request is rejected by the flow control policy, this callback function will be executed. It can be used to record logs, return specific error information, etc.

[0070] customKeyFunction: This parameter is used to customize how to generate flow control key values, allowing more complex business logic to determine the granularity of flow control.

[0071] rateExpression: This is an expression used to define how to calculate the traffic volume within the time window, supporting complex logic.

[0072] rateInterval: For TIME_WINDOW mode, this parameter defines the size of the time window, for example 1 second. For TOKEN_BUCKET mode, this parameter can be left blank.

[0073] (2) Figure 3a to Figure 3c As shown, dynamic configuration is usually suitable for scenarios where flow control rules change frequently, such as dynamic resource configuration, business logic with high change frequency, and system configuration that needs real-time adjustment.

[0074] 1) Dynamic resource configuration

[0075] In many application scenarios, flow control rules need to be adjusted according to real-time traffic conditions. For example, social media platforms, online game servers, e-commerce websites, etc., the traffic and request patterns of these platforms may change at any time, so the flow control rules need to be updated frequently to adapt to different traffic requirements.

[0076] 2) Business logic with high frequency of changes

[0077] For systems with large business process changes and frequent updates, the flow control rules also need to be adjusted accordingly. For example, cloud service providers, content delivery networks (CDNs), etc., the business needs and user behavior patterns in these systems often change, so the flow control strategy needs to be frequently updated to ensure service quality.

[0078] 3) System configuration that requires real-time adjustment

[0079] In some systems with high real-time requirements, flow control rules need to be adjusted in real time to cope with sudden changes in traffic. For example, in financial trading systems and real-time data processing systems, request processing in these scenarios must respond quickly, so the flow control strategy needs to be able to be updated in real time to control the number of concurrent requests in a timely manner.

[0080] When the flow control rules change frequently, dynamic configuration is suitable. This method can flexibly respond to changes in flow and business, ensuring the efficient operation and stability of the system. For some systems with large flow fluctuations, complex business logic or high real-time requirements, dynamic configuration can provide sufficient flexibility and adaptability.

[0081] Furthermore, dynamic configuration is configured in nacos using JsonArray string, which supports configuring multiple groups of different flow control rules in one interface. The specific dynamic configuration parameters are as follows:

[0082] uri: This parameter specifies the request URI of the interface. It is a required field and is used to identify which interfaces need to apply the flow control policy.

[0083] desc: This parameter is optional and is used to describe the function of the interface to facilitate configuration management.

[0084] filterConditions: array type, contains specific flow control rules (supports multiple rules), including field names and field values, which are used to define when to apply the flow control strategy.

[0085] source: enumeration type, this parameter defines the source of the field value in filterConditions, which can be the request header (HEADER), request parameter (REQUEST_PARAM) or request body (REQUEST_BODY).

[0086] rate: Same as rate in static configuration, with different meanings depending on the mode.

[0087] mode: Same as the mode in the static configuration, defines the flow control mode.

[0088] bucketCapacity: Same as bucketCapacity in static configuration, defines the size of the token bucket.

[0089] requestedTokens: Same as requestedTokens in the static configuration, defines the number of tokens required for each request.

[0090] Both of the above configurations are introduced by adding the @RateLimit annotation on the interface. When static configuration and dynamic configuration exist at the same time, the system will give priority to the dynamic configuration. This means that if there is a related configuration in nacos, the static configuration will not take effect. Through these two configuration methods, the present invention provides a comprehensive flow control solution for different business needs, ensuring the stable operation of the system under high concurrency.

[0091] In one embodiment, a demand analysis is performed based on the obtained client requests to determine which interfaces require traffic control. Analyze the traffic pattern of the interface to decide whether to use static configuration or dynamic configuration. For static configuration, define the @RateLimit annotation in the code and set the corresponding parameters. For dynamic configuration, prepare the nacos configuration center and define the configuration in the JsonArray string format. Deploy the application to ensure that the application can connect to the nacos configuration center (if dynamic configuration is used). After the application is started, traffic control is implemented according to the configuration. The dynamic configuration can be updated in real time without restarting the application. Monitor the effect of traffic control and adjust the configuration parameters according to actual conditions.

[0092] Furthermore, managing the token bucket status information based on the flow control strategy includes the following steps: initializing the token bucket status information; configuring the corresponding initial capacity and generation rate of the token based on the flow control strategy; obtaining the number of tokens based on the client request, and updating the token bucket status information in real time.

[0093] In the initialization phase of the token bucket management module, the initial capacity and generation rate are first set: the system sets an initial capacity (C) and a token generation rate (R) for each token bucket according to the flow control configuration strategy. These parameters define the maximum capacity of the token bucket and the speed of token generation. Secondly, the number of tokens is initialized. During initialization, the number of tokens in the token bucket is set to the initial capacity value to ensure that there are enough tokens available when the system starts. Once again, the time of token bucket initialization is recorded for subsequent calculation of token generation. Since the system may need to dynamically adjust the parameters of the token bucket, the present invention uses nacos as a dynamic configuration platform, which can update the capacity and generation rate of the token bucket in real time without restarting the service.

[0094] Further, the token generation process is as follows:

[0095] First, calculate the number of newly generated tokens: the system will calculate the number of newly generated tokens at a preset time interval (such as every second). The calculation formula is:

[0096] Number of new tokens = (current time - last update time) × token generation rate

[0097] Secondly, update the token bucket: add the calculated number of new tokens to the token bucket, but the total amount will not exceed the capacity limit of the token bucket. This ensures that the token bucket will not exceed its maximum capacity due to the setting of the generation rate.

[0098] Finally, when a request arrives, the token consumption is processed.

[0099] Furthermore, the steps to process token consumption are as follows:

[0100] First, determine the number of tokens to be consumed: According to the flow control strategy and the characteristics of the request, determine the number of tokens (T) required to process the request.

[0101] Secondly, process the client request: if the number of tokens in the token bucket is greater than or equal to T, then T tokens are deducted from the token bucket and the request is allowed to pass. If the number of tokens is insufficient, the request is rejected.

[0102] Finally, clarify the relationship between tokens and the number of downstream interfaces: In the present invention, the number of tokens is proportional to the number of downstream services called by the interface. This means that if a request involves multiple downstream interfaces, it may need to consume more tokens. In actual projects, usually each request consumes 1 token, but this ratio can be adjusted according to actual business needs.

[0103] In this way, the token bucket management module can effectively control the request flow entering the system and ensure the stability and service quality of the system.

[0104] Step S12: Receive and parse the client request to obtain the corresponding key-value pair information.

[0105] Specifically, receiving and parsing a client request and obtaining corresponding key-value pair information includes the following steps:

[0106] Identifying request features of the client request, wherein the request features include client attribute features and behavior features;

[0107] The target field of the client request is extracted based on the request feature and converted into corresponding key-value pair information.

[0108] Information extraction is a crucial part of traffic management. Its main function is to extract key information from client requests to support subsequent traffic control decisions. Among them, client attribute features include some basic information of the client, such as IP address, user agent, string, authentication information, etc. This information can help the system understand the source and identity of the request. Behavioral features: This involves the specific behavior of the client request, such as the requested URL, HTTP method (GET, POST, etc.), request header, request body, etc. Behavioral features help understand the client's intentions and needs.

[0109] After identifying the request features, the system needs to extract the target fields related to flow control. For example, extract path parameters or query parameters from the URL, obtain specific tags (such as API keys) from the request header, or parse specific fields in JSON / XML data from the request body. The extracted information will be converted into key-value pairs, where the key is a label that uniquely identifies the information, and the value is the corresponding data content. This format facilitates subsequent processing and matching operations.

[0110] like Figure 4 As shown, obtaining the key-value pair information corresponding to the client request includes the following steps: extracting the header field of the client request and converting it into a header key-value pair; extracting the parameter field of the client request and converting it into a parameter key-value pair; extracting the request body field of the client request and converting it into a request body key-value pair.

[0111] (1) Request header information extraction

[0112] The request header contains a series of key-value pairs used to pass client configuration information, request details, and client capability descriptions. These header fields provide information about the client environment, browser type, accepted content types, etc., to help the server understand the client's request and respond accordingly.

[0113] The main function of the request header is to allow the client to pass some additional information to the server to control or explain the request method, expected response, authentication, etc. For example, the User-Agent header tells the server the client's operating system and browser version, and the Accept header specifies the type of data that the client can accept.

[0114] For incoming requests, by parsing the standard format of the request header (such as the HTTP header format), each header field is used as the key and the corresponding value is stored in a temporary data structure. For example, if the flow control rule is set to control the flow of users with tenant ID = 12345, when parsing the rule, it is necessary to extract the key of gksk_tanent_id and its corresponding value from the header request, and then compare it with the flow control rule to determine whether it is a hit. Extract relevant information in the request header, such as tenant ID, user ID, etc., which is used to identify and verify the identity and authority of the requester.

[0115] (2) Request parameter information extraction

[0116] Request parameters usually appear in the query string part of the URL and are used to pass simple key-value pairs. These parameters are separated by the & symbol. Each parameter consists of a key name and a key value, which are connected by =. Request parameters are mainly used for operations such as filtering, sorting, and paging. They are directly attached to the end of the URL and separated from the URL path part by a question mark (?). For example, example.com / api / product? sort=price&order=asc, in which sort and order are request parameters.

[0117] Parse the query parameter part in the request URL, use the parameter name as the key and the parameter value as the value. If there are multiple identical parameter names (such as "param1=value1¶m1=value2"), store the values ​​as a list.

[0118] (3) Extracting POST request body information

[0119] The POST request body is an optional part of the HTTP request and is used only when data needs to be sent and the request method supports it, such as POST, PUT, etc. It is used to transmit data sent by the client to the server and can contain various types of data, such as form data, JSON data, files, etc.

[0120] The main function of the POST request body is to pass complex data structures to the server. These data can be form data entered by the user, uploaded files, or parameters required for API calls. The specific data type is specified by the Content-Type field in the request header, such as application / json, which means data in JSON format.

[0121] If the request is of POST type and the request body is in a parseable format (such as JSON, form data, etc.), the request body content is parsed into key-value pairs. For a request body in JSON format, the object attributes are traversed, and the attribute name is used as the key and the attribute value is used as the value. Then it is matched with the flow control rules. The information extracted from the request body is usually passed through a POST request for further analysis and processing of the request content to ensure that the flow control strategy can be flexibly adjusted according to actual needs.

[0122] Step S13: Match the extracted key-value pair information with the flow control configuration strategy to obtain a matching result.

[0123] Specifically, the method includes the following steps: identifying the traffic control rules corresponding to the key-value pair information in the traffic configuration strategy; performing field matching between the key-value pair information and the traffic control parameters configured in the traffic control rules to obtain a preliminary matching result; performing condition matching between the preliminary matching result and the traffic control parameters configured in the traffic control rules to obtain a final matching result.

[0124] like Figures 5a to 5b As shown in the figure, after receiving the client request, the system will first extract all the key-value pairs in the request, and then the system will predefine a series of traffic control policy rules. These rules are set according to business needs, and may include different processing strategies for different user roles (such as ordinary users, advanced users), request types (such as read operations, write operations), and request sources (such as internal calls, external calls).

[0125] The matching process includes field matching and condition matching. The system matches the extracted key-value pairs with the specified fields in the policy rules. For example, if the rule specifies that a more relaxed flow control is applied to a specific value of the "Authorization" field (such as a token representing a premium user), the system checks the value of the "Authorization" field in the request. Once the field value is matched successfully, the system determines the flow control level of the request based on the conditions defined in the rule. If the value of the "Authorization" field indicates that the request is from a premium user, the system may allocate a higher flow quota to allow the request to be given priority even during peak traffic hours. Based on the matching results, the system will make a flow control decision. If the request meets the conditions of a premium user, it is allowed to pass; if it does not, it may be necessary to further check other rules or perform default flow control measures, such as limiting the request rate or directly rejecting the request. In this way, policy matching based on key-value pairs can not only achieve differentiated processing of different users and requests, but also ensure the reasonable allocation of system resources and improve the overall performance and user experience of the service. Based on the matching results, the system will make a flow control decision. If the request meets the advanced user's conditions, it is allowed to pass; if not, it may be necessary to further check other rules or perform default traffic control measures, such as limiting the request rate or directly rejecting the request.

[0126] In this way, key-value pair-based policy matching can not only achieve differentiated processing of different users and requests, but also ensure the rational allocation of system resources and improve the overall performance of the service and user experience.

[0127] Step S14: dynamically adjust the flow control configuration strategy based on the matching result to obtain an execution strategy, thereby performing a flow control operation based on the execution strategy.

[0128] Specifically, the matching result is combined with the status information of the token bucket to identify the adjustment requirements of the flow control configuration strategy; based on the adjustment requirements of the flow control configuration strategy, the status information of the token bucket is adjusted to obtain the execution strategy; the flow control operation is performed based on the execution strategy; wherein the status information of the token bucket includes the current number of tokens, the token generation rate, the token consumption rate and the token bucket capacity.

[0129] In one embodiment, the matching result is analyzed in combination with the status information of the token bucket to identify the following situations: the token bucket frequently reaches a state of insufficient tokens, indicating that the current policy may be too strict or the traffic demand exceeds expectations. The tokens in the token bucket are often in an excess state, which may indicate that the policy is too loose and resources are not fully utilized. Based on the token bucket status analysis, the following adjustment requirements are identified: if there are insufficient tokens, it may be necessary to increase the token generation rate or the token bucket capacity. If there are excess tokens, it may be necessary to reduce the token generation rate or the token bucket capacity. According to the identified adjustment requirements, the flow control configuration strategy is adjusted to obtain the execution strategy to perform the following operations: adjust the token generation rate: if there are insufficient tokens, increase the token generation rate; if there are excess tokens, reduce the token generation rate. Adjust the token bucket capacity: adjust the capacity of the token bucket according to the traffic demand to ensure that it can adapt to the traffic peak. Modify the flow control rules: according to the token bucket status, modify the conditions in the flow control rules, such as adjusting the flow control level that matches a specific key-value pair. The adjusted flow control configuration strategy, that is, the execution strategy, is applied to the flow control system in real time to ensure that the new token bucket configuration and rules take effect immediately.

[0130] In one embodiment, if the key-value pair information matches the flow control policy successfully, it is determined whether the current number of token buckets meets the required number of tokens; if so, the request is allowed to pass; if not, the request is denied; if the key-value pair information does not match the flow control configuration policy successfully, it is determined whether there is a default processing method; if there is a default processing method, the corresponding flow control decision is obtained based on the default processing method; if there is no default processing method, the key-value pair information is continued to be matched with the flow control policy in a loop until the corresponding flow control decision is obtained.

[0131] Furthermore, according to the flow control configuration strategy, determine the number of tokens that each request needs to consume. For example, if the rule is to consume 1 token for every 5 requests, then for the 6th request, 1 token is required. Query the current token bucket status in the token bucket management module. If the number of tokens in the token bucket is greater than or equal to the number of tokens required for the request, the request is allowed to pass, and the corresponding number of tokens is deducted from the token bucket. For example, if there are 5 tokens in the current token bucket and the request needs to consume 1 token, 1 token is deducted from the token bucket, and 4 tokens remain. If the number of tokens in the token bucket is insufficient, the request is rejected, and the corresponding prompt information can be returned to the client. For example, if there are 0 tokens in the current token bucket and the request needs to consume 1 token, the request is directly rejected and the message "flow control failed" is returned to the client. After each request is processed, the status of the token bucket needs to be updated.

[0132] In one embodiment, if Figure 5aAs shown in the figure, the system receives a request from the client. The system identifies the request type and extracts key information based on the URI or other features of the request. Based on scenario analysis, the system loads the corresponding flow control policy configuration from the configuration center (such as nacos), initializes the token bucket based on the configuration parameters, and matches the filterConditions in the configuration according to the characteristics of the request (such as request parameters, request headers, request bodies, etc.) to determine whether the flow control policy needs to be applied to the request. If the request matches the flow control rule, the system will make a flow control decision based on the configured mode (such as TIME_WINDOW or TOKEN_BUCKET) and rate parameters. In TOKEN_BUCKET mode, the system checks whether there are enough tokens in the token bucket to process the request. If so, the request is allowed to pass; if not, the request will be restricted or downgraded. For TOKEN_BUCKET mode, the system adds tokens to the token bucket at a fixed rate. If the request passes the flow control decision, the system will perform the flow control operation. If the request is rejected by the flow control policy, the system will execute the fallbackFunction, which may include logging, returning error information, etc. After the system completes the request processing, it sends the response back to the client. Through the above workflow, the present invention can flexibly adjust the flow management measures according to the real-time request characteristics and system status, thereby ensuring the stability and efficiency of the system.

[0133] like Figure 7 As shown, receive the HTTP request from the client, including the request header, request parameters and request body; log in to the nacos console, load the flow control configuration rules, ensure that the rule content is correct and save. Traverse all loaded flow control rules and check whether the current request matches these rules. If the match is successful, extract the corresponding key-value pair information. Extract the necessary information according to the rule requirements, such as tenant ID, user ID, etc. If a rule is hit, execute the Reddisson Lua script to obtain the token. Check whether the number of tokens in the current token bucket is sufficient. If not, proceed to the next step; if enough, allow the request to pass and deduct the corresponding number of tokens from the token bucket. When the number of tokens is insufficient, determine whether there is a custom processing method. If yes, call the custom processing logic, such as returning a specific error message or performing additional operations; if not, execute the default processing logic and throw out the default error message: "The request is too fast, please try again later".

[0134] Through the above process, the present invention can effectively implement refined flow control based on request information, ensuring that the system can run efficiently in various application scenarios.

[0135] Furthermore, the method is used to implement an efficient and reliable exception handling mechanism: during the traffic management process, client requests and system responses are monitored in real time to identify abnormal behaviors, including but not limited to abnormal request frequency, abnormal request size, abnormal response time, system error response, etc.;

[0136] Classify detected abnormal behaviors and distinguish whether they are temporary, recoverable or systemic, to provide a basis for subsequent exception handling; define specific handling strategies for different types of exceptions, including ignoring exceptions, retrying requests, limiting request frequency, downgrading services, notifying administrators, etc.;

[0137] According to the exception classification and handling strategy, the corresponding exception handling operations are automatically executed to ensure system stability and service continuity. After the exception handling is completed, according to the nature and impact of the exception, corresponding recovery measures are taken, such as restoring normal flow control strategies, clearing abnormal status, restarting affected services, etc.;

[0138] In one embodiment, the adaptive multi-dimensional flow control method of the present invention is applied to a large model platform to solve the concurrent demand problem of different business parties for the large model interface.

[0139] Business party A (customerId = 12345) has a concurrent demand of 10 for the OCR interface ( / ocr) and 20 for the text2pic interface. The corresponding nacos configuration can be set to:

[0140]

[0141]

[0142]

[0143] For the OCR interface ( / ocr) of business party A, a token bucket with a capacity of 10 is configured, which means that at most 10 requests from business party A can be processed at the same time. Tokens are generated at a rate of 1 per second, and each request consumes 1 token. For the text-to-picture interface ( / text2Pic) of business party A, a token bucket with a capacity of 20 is configured, allowing at most 20 requests from business party A to be processed at the same time. Other configurations are the same as the OCR interface.

[0144] Through this configuration, the big model platform can implement fine-grained flow control for different interface requirements of different business parties, ensuring that each business party's request can be processed within the specified concurrency limit, thereby avoiding excessive pressure on the big model platform and ensuring the stability and fairness of the service. At the same time, this adaptive flow control method can be adjusted according to actual operation conditions to adapt to changes in business needs.

[0145] The protection scope of the adaptive multi-dimensional flow control method described in the embodiment of the present invention is not limited to the execution order of the steps listed in this embodiment. All solutions implemented by adding, reducing or replacing steps in the prior art based on the principles of the present invention are included in the protection scope of the present invention.

[0146] An embodiment of the present invention also provides an adaptive multi-dimensional flow control system, which can implement the adaptive multi-dimensional flow control method described in the present invention. However, the implementation device of the adaptive multi-dimensional flow control system described in the present invention includes but is not limited to the structure of the adaptive multi-dimensional flow control system listed in this embodiment. All structural deformations and replacements of the prior art made according to the principles of the present invention are included in the protection scope of the present invention.

[0147] In one embodiment, if Figure 8 As shown, the adaptive multi-dimensional flow control system of the present invention includes:

[0148] The information extraction module 81 is used to receive and parse the client request and obtain the corresponding key-value pair information;

[0149] A flow control policy configuration module 82, used to create a flow control configuration policy based on business requirements, wherein the flow control configuration policy includes setting flow control rules, configuring flow control parameters, and maintaining status information of token buckets;

[0150] The flow control decision module 83 is used to match the extracted key-value pair information with the flow control strategy to obtain a matching result; dynamically adjust the flow control configuration strategy based on the matching result to obtain an execution strategy, thereby performing a flow control operation based on the execution strategy;

[0151] The token bucket management module 84 is used to configure parameters of the token bucket based on the flow control policy configuration module, and dynamically adjust the flow control policy configuration module based on the flow control decision module to implement flow control operations.

[0152] In the several embodiments provided by the present invention, it should be understood that the disclosed system, device or method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules / units is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules or units, which can be electrical, mechanical or other forms.

[0153] The modules / units described as separate components may or may not be physically separated, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules / units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention. For example, the functional modules / units in the various embodiments of the present invention may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.

[0154] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0155] The embodiment of the present invention also provides a computer-readable storage medium. A person of ordinary skill in the art can understand that all or part of the steps in the method for implementing the above embodiment can be completed by instructing the processor through a program, and the program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state hard disk, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state disk (SSD)), etc.

[0156] Fig. 9 is a schematic block diagram of a computer device provided by an embodiment of the present invention. Fig. 9As shown, the computer device includes: at least one processor 901, a memory 902, at least one network interface 903 and a user interface 905. The various components in the device are coupled together through a bus system 904. It can be understood that the bus system 904 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 904 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 904 is not used in the embodiment of the present invention. Fig. 9 In the specification, various buses are labeled as bus systems.

[0157] The user interface 905 may include a display, a keyboard, a mouse, a trackball, a click gun, keys, buttons, a touch pad or a touch screen.

[0158] It is understood that the memory 902 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM). The memory described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable categories of memory.

[0159] The memory 902 in the embodiment of the present invention is used to store various categories of data to support the operation of the electronic terminal 900. Examples of these data include: any executable program for operating on the electronic terminal 900, such as an operating system 9021 and an application 9022; the operating system 9021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application 9022 may include various applications, such as a media player (Media Player), a browser (Browser), etc., for implementing various application services. The adaptive multi-dimensional flow control method provided by the embodiment of the present invention may be included in the application 9022.

[0160] The method disclosed in the above embodiment of the present invention can be applied to the processor 901, or implemented by the processor 901. The processor 901 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 901 or the instruction in the form of software. The above processor 901 may be a general processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 901 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general processor 901 may be a microprocessor or any conventional processor, etc. In combination with the steps of the accessory optimization method provided in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0161] In an exemplary embodiment, the electronic terminal 900 may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD) to execute the aforementioned method.

[0162] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.

Claims

1. An adaptive multi-dimensional flow control method, characterized in that: The method comprises the following steps: Create a flow control configuration strategy based on business needs, wherein the flow control configuration strategy includes setting flow control rules, configuring flow control parameters, and maintaining token bucket status information; Receive and parse client requests to obtain corresponding key-value pair information; Matching the key-value pair information with the flow control configuration strategy to obtain a matching result; The flow control configuration strategy is dynamically adjusted based on the matching result to obtain an execution strategy, thereby performing a flow control operation based on the execution strategy.

2. The adaptive multi-dimensional flow control method according to claim 1, characterized in that: Receiving and parsing client requests and obtaining corresponding key-value pair information includes the following steps: Identifying request features of the client request, wherein the request features include client attribute features and behavior features; The target field of the client request is extracted based on the request feature and converted into corresponding key-value pair information.

3. The adaptive multi-dimensional flow control method according to claim 1, characterized in that: Creating a flow control configuration strategy based on business requirements includes the following steps: Set flow control rules based on business needs and configure corresponding flow control parameters for the flow control rules; Initialize the status information of the token bucket based on the flow control parameter to obtain the flow control configuration strategy; The flow control parameters include core control parameters, condition matching parameters, custom behavior parameters, and priority parameters.

4. The adaptive multi-dimensional flow control method according to claim 1, characterized in that: The flow control rules include: static configuration rules and dynamic configuration rules; The static configuration rules are set by annotating parameters in the code and are used for static resource configuration, fixed business logic, and system configuration with low change frequency; The dynamic configuration rules are set by an external configuration center and are used for dynamic resource configuration, business logic with high change frequency, and real-time adjustment of system configuration.

5. The adaptive multi-dimensional flow control method according to claim 1, characterized in that: Matching the extracted key-value pair information with the flow control configuration strategy to obtain the matching result includes the following steps: Identifying the flow control rule corresponding to the key-value pair information in the flow control configuration strategy; Performing field matching on the key-value pair information and the flow control parameters configured in the flow control rule to obtain a preliminary matching result; The preliminary matching result is conditionally matched with the flow control parameters configured in the flow control rule to obtain a final matching result.

6. The adaptive multi-dimensional flow control method according to claim 1, characterized in that: Dynamically adjusting the flow control configuration strategy based on the matching result to obtain an execution strategy, thereby performing a flow control operation based on the execution strategy, comprises the following steps: Combining the matching result with the status information of the token bucket to identify the flow control configuration strategy adjustment requirement; Based on the flow control configuration strategy adjustment requirement, adjust the status information of the token bucket and obtain the execution strategy; Execute the flow control operation based on the execution strategy; The status information of the token bucket includes the current number of tokens, the generation rate of tokens, the consumption rate of tokens and the capacity of the token bucket.

7. The adaptive multi-dimensional flow control method according to claim 1, characterized in that: The method also includes an exception handling mechanism: Classifying the detected abnormal client requests to obtain abnormal request classifications, wherein the abnormal request classifications include temporary abnormalities, recoverable abnormalities, and systemic abnormalities; Set corresponding exception handling strategies for different types of abnormal requests, where the exception handling strategies include ignoring exceptions, retrying requests, and notifying alarms; According to the abnormal request classification and the abnormal handling strategy, a corresponding abnormal flow control operation is performed.

8. An adaptive multi-dimensional flow control system, characterized in that: include: An information extraction module, used to receive and parse the client request and obtain corresponding key-value pair information; A flow control strategy configuration module, used to create a flow control configuration strategy based on business needs, wherein the flow control configuration strategy includes setting flow control rules, configuring flow control parameters, and maintaining token bucket status information; A flow control decision module, used to match the extracted key-value pair information with the flow control strategy to obtain a matching result; dynamically adjust the flow control configuration strategy based on the matching result to obtain an execution strategy, thereby performing a flow control operation based on the execution strategy; The token bucket management module is used to configure parameters of the token bucket based on the flow control strategy configuration module, and dynamically adjust the flow control strategy configuration module based on the flow control decision module to implement flow control operations.

9. An electronic device, characterized in that: include: one or more processors; and One or more memories, wherein the memories store computer readable codes, and when the computer readable codes are executed by the one or more processors, the control method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by an electronic device, the adaptive multi-dimensional flow control method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Flow-classification-based grouping flow control system and control method

    CN102387082A

  • Flow limiting method and device

    CN110611623A

  • Data transmission method and device based on speed limiting strategy

    CN113726682A

  • Flow control configuration updating method, device and equipment

    CN114489733A

  • Fine-grained flow control method and system supporting dynamic configuration

    CN115801688A

Cited By

  • Flow control method and device

    CN120980030A