Flow control method and device
By parsing the URL path step by step and querying the pre-built rule tree, and forming a set of flow control rules, the problem of inefficiency of traditional flow control solutions is solved, and efficient and flexible flow control is achieved.
Patent Information
- Application Number
- CN202510289827.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-06-20
AI Technical Summary
When traditional flow control solutions face a large number of concurrent requests and dynamic load changes, they are inefficient, the query speed is significantly reduced, and it is difficult to flexibly cope with the addition of new rules.
By parsing the URL path step by step, extracting the path prefix, querying the prebuilt rule tree with the path prefix as the key, forming a set of flow control rules, and executing flow control rules to achieve flow control.
This method improves the efficiency of flow control, reduces unnecessary calculation and resource consumption, can flexibly deal with the addition of new rules, and the query speed is not affected by the total number of flow control rules.
Smart Images

Figure CN120186068A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of large models, and particularly to the field of data processing on an artificial intelligence (AI) native application workbench for building large models. Specifically, it relates to a traffic control method and apparatus thereof. Background Art
[0002] Traffic control is a crucial part in modern application and platform development. Especially when dealing with a large number of concurrent requests, high-concurrency scenarios, and dynamic load changes, traffic control can ensure system stability, improve user experience, and achieve reasonable allocation of resources. With the wide application of technologies such as artificial intelligence and big data, traffic control faces more complex challenges. Summary of the Invention
[0003] The present disclosure provides a traffic control method, apparatus, device, and storage medium.
[0004] According to one aspect of the present disclosure, a traffic control method is provided, including: receiving an access request sent by a client, extracting request information carried in the access request, where the request information includes a Uniform Resource Locator (URL) path; hierarchically parsing the URL path to extract path prefixes at each level; querying nodes of a pre-constructed rule tree with the path prefixes as keys in the order of the levels of the path prefixes, and forming a set of traffic control rules corresponding to the access request based on the traffic control rules stored in the queried nodes; and executing the traffic control rules included in the set of traffic control rules on the access request to obtain a traffic control result.
[0005] The traffic control method provided by this application hierarchically parses the URL path and queries the pre-constructed rule tree with the path prefix as the key. Finding the required rule set only depends on the length and structure of the URL path, and is not affected by the total number of traffic control rules. This ensures that as the number of rules increases, the query speed will not decrease significantly, improving the efficiency of traffic control and reducing unnecessary calculations and resource consumption; by managing traffic control rules in the way of pre-constructing a rule tree, it can flexibly handle the addition of new rules.
[0006] According to another aspect of the present disclosure, a traffic control apparatus is provided, including: a receiving module for receiving an access request sent by a client and extracting request information carried in the access request, where the request information includes a Uniform Resource Locator (URL) path; a parsing module for hierarchically parsing the URL path to extract path prefixes at each level; a forming module for querying nodes of a pre-constructed rule tree with the path prefixes as keys in the order of the levels of the path prefixes, and forming a set of traffic control rules corresponding to the access request based on the traffic control rules stored in the queried nodes; and an executing module for executing the traffic control rules included in the set of traffic control rules on the access request to obtain a traffic control result.
[0007] According to another aspect of the present disclosure, there is provided an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the above-mentioned traffic control method.
[0008] According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the above-mentioned traffic control method.
[0009] According to another aspect of the present disclosure, there is provided a computer program product, including a computer program, where the computer program implements the above-mentioned traffic control method when executed by a processor.
[0010] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings are used to better understand the solution and do not constitute a limitation to the present disclosure. Among them:
[0012] Figure 1 is a schematic diagram of an exemplary implementation manner of a traffic control method according to an exemplary embodiment of the present disclosure.
[0013] Figure 2 is a simplified schematic diagram of a rule tree according to an exemplary embodiment of the present disclosure.
[0014] Figure 3 is a schematic diagram of an exemplary implementation manner of a traffic control method according to an exemplary embodiment of the present disclosure.
[0015] Figure 4 is a schematic diagram of an exemplary implementation manner of a traffic control method according to an exemplary embodiment of the present disclosure.
[0016] Figure 5 is a schematic diagram of a process of executing the traffic control rules included in a traffic control rule set for an access request according to an exemplary embodiment of the present disclosure.
[0017] Figure 6 is a schematic diagram of a process of executing the traffic control rules included in a traffic control rule set for an access request according to an exemplary embodiment of the present disclosure.
[0018] Figure 7It is a schematic diagram of an exemplary implementation manner of a traffic control method according to an exemplary embodiment of the present disclosure.
[0019] Figure 8 It is a schematic diagram of a traffic control device according to an exemplary embodiment of the present disclosure.
[0020] Figure 9 It is a schematic diagram of an electronic device according to an exemplary embodiment of the present disclosure. Detailed implementation manners
[0021] The following describes exemplary embodiments of the present disclosure with reference to the accompanying drawings. Various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, descriptions of well-known functions and structures are omitted below for clarity and conciseness.
[0022] In the technical solution of the present disclosure, the acquisition, storage, and application of user personal information involved all comply with the provisions of relevant laws and regulations and do not violate public order and good customs.
[0023] With the rapid development of artificial intelligence technology, AI-native applications have gradually become the core driving force for industry innovation. AI application platforms for developers and enterprises have emerged, aiming to lower the development threshold and help quickly implement application landing. The AI application platform includes various AI components and frameworks, such as document Q&A, image processing, speech recognition, etc. However, with the growth of platform business volume and the increasing number of customer scenarios, how to effectively control traffic and ensure platform stability has become an important challenge in platform operation.
[0024] In traditional traffic control solutions, for each API request, if the conditions of specific traffic control policies are not met, all traffic control policies need to be traversed for traffic management. As the number of traffic control rules increases, the forwarding performance may gradually decrease, resulting in a bottleneck in traffic control efficiency.
[0025] To solve the above problems, Figure 1 It is a schematic diagram of an exemplary implementation manner of a traffic control method shown in this application. As Figure 1 shown, the traffic control method includes the following steps:
[0026] S101, receive an access request sent by a client, and extract request information carried in the access request. The request information includes a uniform resource locator (URL) path.
[0027] Among them, the path in the Uniform Resource Locator (URL) refers to the specific location of the resource on the server, usually located after the domain name and separated by a slash ( / ).
[0028] Exemplarily, receive an access request sent by a client, parse the URL in the access request, and extract the path part therein. For example, if the URL carried by an access request is: http: / / 127.0.0.1:8080 / v1 / test / test1 / test2, then the URL path corresponding to this access request is: / v1 / test / test1 / test2.
[0029] S102, perform hierarchical parsing on the URL path and extract the path prefixes at each level.
[0030] In this application, the slash ( / ) in the URL path is used as the hierarchical standard to perform hierarchical parsing on the URL path and extract the path prefixes at each level.
[0031] Exemplarily, if the URL path is: / v1 / test / test1 / test2, after performing hierarchical parsing on it, the path prefixes obtained from the high level to the low level are the following 5: / , / v1, / v1 / test, / v1 / test / test1, / v1 / test / test1 / test2.
[0032] S103, according to the level order of the path prefixes, query the nodes of the pre-constructed rule tree with the path prefix as the key, and form a flow control rule set corresponding to the access request based on the flow control rules stored in the queried nodes.
[0033] Preferably, the rule tree in this application can be constructed by selecting a Radix Tree. Among them, Radix Tree is a space-optimized prefix tree (Trie Tree) that stores associated data in the form of key-value pairs.
[0034] In the rule tree of this application, each node is used to save the path prefix and the corresponding flow control rule. Among them, the path prefix is used as the key of the node, and the flow control rule corresponding to the path prefix is used as the value of the node. The edges between nodes represent the extension of the prefix.
[0035] Figure 2It is a simple schematic diagram of a rule tree shown in this application. Continuing with the above example where the path prefixes from high level to low level are: / , / v1, / v1 / test, / v1 / test / test1, / v1 / test / test1 / test2, in the order of the levels of the path prefixes, query the nodes of the pre-constructed rule tree with the path prefix as the key, and form a set of flow control rules corresponding to the access request based on the flow control rules stored in the queried nodes.
[0036] Taking Figure 2 as an example, first query the rule tree with the path prefix " / " as the key. Node 1 is queried, and the flow control rule stored in Node 1 is taken as Flow Control Rule 1. Then, starting from the next level of the node level where Node 1 is located, query the rule tree with the path prefix " / v1" as the key, and no corresponding node is queried. Continuing to query the rule tree with the path prefix " / v1 / test" as the key starting from the next level of the node level where Node 1 is located, Node 2.1 is queried, and the flow control rule stored in Node 2.1 is taken as Flow Control Rule 2. Then, continue to query the rule tree with the path prefix " / v1 / test / test1" as the key starting from the next level of the node level where Node 2.1 is located, Node 3.1 is queried, and the flow control rule stored in Node 3.1 is taken as Flow Control Rule 3. Then, continue to query the rule tree with the path prefix " / v1 / test / test1 / test2" as the key starting from the next level of the node level where Node 3.1 is located, and no corresponding node is queried. In summary, the finally obtained set of flow control rules is represented as: {Flow Control Rule 1, Flow Control Rule 2, Flow Control Rule 3}.
[0037] Among them, the construction process of the rule tree is as follows: Obtain the flow control rule configuration information, which records the mapping relationship between the path prefix and the corresponding flow control rule. Based on this mapping relationship, construct the nodes of the rule tree (the path prefix is used as the key of the node, and the flow control rule corresponding to the path prefix is used as the value of the node). Among them, the edges between the nodes represent the extension of the prefix, and the finally constructed and generated rule tree is obtained.
[0038] S104, execute the flow control rules included in the set of flow control rules for the access request to obtain a flow control result.
[0039] Exemplarily, the flow control rule can be: The number of requests received by the entire system cannot exceed 500,000 times every 10 seconds.
[0040] Exemplarily, the flow control rule can be: The number of requests initiated by a single user cannot exceed 10 times per second.
[0041] In this application, traffic control is performed on access requests in sequence according to the order of the traffic control rules in the traffic control rule set. Exemplarily, if the traffic control rule set is: {traffic control rule 1, traffic control rule 2, traffic control rule 3}, then traffic control is performed on the access request in sequence by traffic control rule 1, traffic control rule 2, and traffic control rule 3.
[0042] Among them, if the access request passes all the traffic control rules included in the traffic control rule set (which can also be understood as the access request is not intercepted during the traffic control process), it is determined that the access request passes the traffic control.
[0043] Among them, if the access request fails to pass any traffic control rule during the process of sequentially executing the traffic control rules included in the traffic control rule set (which can also be understood as the access request is intercepted during the traffic control process), it is determined that the access request fails to pass the traffic control.
[0044] An embodiment of this application proposes a traffic control method, including: receiving an access request sent by a client, extracting the request information carried by the access request, where the request information includes a Uniform Resource Locator (URL) path; performing hierarchical parsing on the URL path to extract the path prefixes at each level; according to the level order of the path prefixes, querying the nodes of a pre-constructed rule tree with the path prefix as the key, and forming a traffic control rule set corresponding to the access request based on the traffic control rules stored in the queried nodes; performing the traffic control rules included in the traffic control rule set on the access request to obtain a traffic control result. In this application, hierarchical parsing is performed on the URL path and the pre-constructed rule tree is queried with the path prefix as the key. Finding the required rule set only depends on the length and structure of the URL path, and is not affected by the total number of traffic control rules, ensuring that the query speed will not decrease significantly as the number of rules increases, improving the efficiency of traffic control, and reducing unnecessary calculations and resource consumption; by managing traffic control rules in the way of pre-constructing a rule tree, it can flexibly handle the addition of new rules.
[0045] Figure 3 is a schematic diagram of an exemplary implementation manner of a traffic control method shown in this application, as Figure 3 shown, the traffic control method includes the following steps:
[0046] S301, receiving an access request sent by a client, and extracting the request information carried by the access request, where the request information includes a URL path.
[0047] S302, performing hierarchical parsing on the URL path to extract the path prefixes at each level.
[0048] S303, according to the level order of the path prefixes, querying the nodes of a pre-constructed rule tree with the path prefix as the key, and forming a traffic control rule set corresponding to the access request based on the traffic control rules stored in the queried nodes.
[0049] For the specific implementation manners of steps S301 to S303, reference may be made to the specific introductions in the relevant parts of the foregoing embodiments, and details are not described herein again.
[0050] S304. Sequentially determine the current flow control rule to be executed from the flow control rule set.
[0051] In this application, traffic control is sequentially performed on access requests according to the order of the flow control rules in the flow control rule set. Exemplarily, if the flow control rule set is: {flow control rule 1, flow control rule 2, flow control rule 3}, then traffic control is performed on the access request by sequentially executing flow control rule 1, flow control rule 2, and flow control rule 3.
[0052] S305. Pre-apply a token for the access request based on the current flow control rule to be executed.
[0053] Among them, pre-applying a token means pre-applying and occupying a token from the token bucket in advance, rather than formally applying for a token. After successfully pre-applying tokens based on all the flow control rules in the flow control rule set, a formal token application is made based on the pre-applied tokens; if the pre-application of a token fails for any flow control rule, the tokens pre-applied by the flow control rules for which the pre-application of tokens is successful need to be released.
[0054] Exemplarily, assume that a certain flow control rule is: the received requests cannot exceed 10,000 times per second, then it can be understood that there are 10,000 token quotas per second. Within 1 second, if the access request is the 9,000th request, it means that a token can be pre-applied; if within 1 second, if the access request is the 20,000th request, it means that a token cannot be pre-applied.
[0055] S306. In response to successfully pre-applying tokens based on all the flow control rules after the pre-application of tokens is completed, determine that the flow control result is flow control passed.
[0056] Continuing with the flow control rule set as: {flow control rule 1, flow control rule 2, flow control rule 3} as an example, take flow control rule 1 as the first flow control rule to be executed, pre-apply a token for the access request based on flow control rule 1. After successfully pre-applying a token based on flow control rule 1, then take flow control rule 2 as the second flow control rule to be executed, pre-apply a token for the access request based on flow control rule 2. After successfully pre-applying a token based on flow control rule 2, then take flow control rule 3 as the third flow control rule to be executed, pre-apply a token for the access request based on flow control rule 3. After successfully pre-applying a token based on flow control rule 3, that is, it means that tokens have been successfully pre-applied based on all the flow control rules in the flow control rule set, then it can be determined that the flow control result of the access request is flow control passed, and a formal token application is made based on the pre-applied tokens.
[0057] S307. In response to the failure of pre-applying for a token based on any flow control rule, stop executing the subsequent flow control rules for the access request, and determine that the flow control result is that the flow control fails.
[0058] Continuing with the example where the set of flow control rules is: {Flow control rule 1, Flow control rule 2, Flow control rule 3}, taking flow control rule 1 as the first flow control rule to be executed, pre-apply for a token for the access request based on flow control rule 1. Suppose the pre-application for a token based on flow control rule 1 fails, then the subsequent flow control rules 2 and 3 will not be executed, and it can be directly determined that the flow control result of the access request is that the flow control fails.
[0059] In the embodiment of the present application, the URL path is parsed step by step, and the pre-constructed rule tree is queried with the path prefix as the key. Finding the required rule set only depends on the length and structure of the URL path, and is not affected by the total number of flow control rules. This ensures that when the number of rules increases, the query speed will not decrease significantly, improving the efficiency of traffic control and reducing unnecessary calculations and resource consumption; in the present application, by pre-applying for a token during the execution of the flow control rule, traffic control can be performed before the access request reaches the called service, thus avoiding excessive pressure on the server caused by the request; if the flow control rule fails, the access request can be immediately blocked from entering the subsequent processing flow, ensuring that requests that do not meet the requirements will not waste more resources.
[0060] Figure 4 is a schematic diagram of an exemplary implementation manner of a traffic control method shown in the present application. As Figure 4 shown, the traffic control method includes the following steps:
[0061] S401. Receive the access request sent by the client, and extract the request information carried in the access request. The request information includes the URL path.
[0062] S402. Parse the URL path step by step, and extract the path prefixes at each level.
[0063] S403. According to the level order of the path prefixes, query the nodes of the pre-constructed rule tree with the path prefix as the key, and form a set of flow control rules corresponding to the access request based on the flow control rules stored in the queried nodes.
[0064] For the specific implementation manners of steps S401 to S403, reference can be made to the specific introduction of the relevant parts in the above embodiments, and details will not be elaborated here.
[0065] S404. Execute the flow control rules included in the set of flow control rules for the access request to obtain the flow control result.
[0066] Figure 5It is a schematic diagram of the process of executing the flow control rules included in the flow control rule set shown in this application, and reference can be made to Figure 5 Understand the following text introduction.
[0067] First, sequentially determine the currently to-be-executed flow control rule from the flow control rule set (taking the flow control rule set as: {Flow control rule 1, Flow control rule 2, Flow control rule 3} as an example, execute in the order of Flow control rule 1, Flow control rule 2, and Flow control rule 3. When executing Flow control rule 1, regard Flow control rule 1 as the currently to-be-executed flow control rule; when executing Flow control rule 2, regard Flow control rule 2 as the currently to-be-executed flow control rule; when executing Flow control rule 3, regard Flow control rule 3 as the currently to-be-executed flow control rule).
[0068] After determining the currently to-be-executed flow control rule, pre-apply a token for the access request based on the currently to-be-executed flow control rule. The specific process is as follows: Obtain the Application Programming Interface (API) flow control rules included in the currently to-be-executed flow control rule (there may be 1 or multiple), and sequentially match the API flow control rules based on the path prefix to obtain the target API flow control rule that matches successfully. Then, obtain the API flow control sub-rules included in the target API flow control rule, and sequentially pre-apply tokens for the access request in the order of the API flow control sub-rules.
[0069] In this application, if a certain API flow control rule does not specifically limit any path prefix (for example, it does not specifically limit that the API flow control rule only applies to a certain path prefix or only applies to path prefixes other than a certain path prefix), it can be regarded as a successful match based on the path prefix with the API flow control rule. If the API flow control rule specifically limits the path prefix, then sequentially match the API flow control rules based on the path prefix in the order of the API flow control rules to obtain the target API flow control rule that matches successfully.
[0070] Among them, the above-mentioned sequentially pre-applying tokens for the access request in the order of the API flow control sub-rules specifically includes: determining the currently executed API flow control sub-rule, and judging whether the currently executed API flow control sub-rule is a user-dimension related sub-rule (for example, a rule that limits each user from making more than 10 requests per second in terms of the user dimension is regarded as a user-dimension related sub-rule).
[0071] In this application, the API flow control sub-rules may include API flow control sub-rules with the global request volume as the dimension, API flow control sub-rules with the user as the dimension, and API flow control sub-rules with the rule group as the dimension. Among them, the API flow control sub-rules with the user as the dimension and the API flow control sub-rules with the rule group as the dimension can both be regarded as sub-rules related to the user dimension.
[0072] Among them, a rule group divides multiple flow control rules into a group and assigns a shared flow control quota to this group. The flow control rules within the rule group can be of the user dimension or of the API dimension.
[0073] Specifically, the following situations are included:
[0074] Situation 1: If the currently executed API flow control sub-rule is a sub-rule related to other dimensions except for the sub-rules related to the user dimension, that is, it can be understood that the currently executed API flow control sub-rule is not a sub-rule related to the user dimension, then still pre-apply a token for the access request based on the currently executed API flow control sub-rule. After the pre-application of the token is successful, continue to determine the next API flow control sub-rule as the new currently executed API flow control sub-rule, and repeat the relevant process after judging whether the currently executed API flow control sub-rule is a sub-rule related to the user dimension.
[0075] Situation 2: If the currently executed API flow control sub-rule is a sub-rule related to the user dimension, judge whether there is a custom user flow control rule configured in the currently executed flow control rule (which can be understood as a flow control rule specifically customized for individual users or individual rule groups. For example, it is restricted that the user with the user ID "111" cannot submit more than 2 requests per second). If the currently executed flow control rule only includes API flow control rules, that is, the currently executed flow control rule does not include a custom user flow control rule, then pre-apply a token for the access request based on the currently executed API flow control sub-rule. After the pre-application of the token is successful, continue to determine the next API flow control sub-rule as the new currently executed API flow control sub-rule, and repeat the relevant process after judging whether the currently executed API flow control sub-rule is a sub-rule related to the user dimension.
[0076] Situation 3: If the currently executed API flow control sub-rule is a sub-rule related to the user dimension, judge whether there is a custom user flow control rule configured in the currently executed flow control rule. If the currently executed flow control rule includes a custom user flow control rule, then match the path prefix with the custom user flow control rules in sequence to obtain the target custom user flow control rule that matches successfully.
[0077] In this application, if a certain custom user flow control rule does not specifically restrict any path prefix, it can be regarded as a successful match based on the path prefix and the custom user flow control rule. If the custom user flow control rule specifically restricts the path prefix, then the custom user flow control rules are sequentially matched based on the path prefix in the order of the custom user flow control rules to obtain the target custom user flow control rule that matches successfully.
[0078] After determining the target custom user flow control rule as described above, obtain the custom user flow control sub-rules included in the target custom user flow control rule (for example, the rule for user ID "111" can be regarded as the first custom user flow control sub-rule, the rule for user ID "222" can be regarded as the second custom user flow control sub-rule, and so on). Then, match the user identifier with the custom user flow control sub-rules included in the target custom user flow control rule. If the match is successful, use the custom user flow control sub-rule obtained from the match as the target custom user flow control sub-rule, and update the parameters of the currently executed API flow control sub-rule based on the target custom user flow control sub-rule (for example, the currently executed API flow control sub-rule is: the number of requests per second for a single user cannot exceed 10 times, and the target custom user flow control sub-rule obtained from the match is: the number of requests submitted per second by the user with user ID "111" cannot exceed 2 times. Then, the current execution is no longer based on the number of requests per second for a single user not exceeding 10 times, but on the number of requests submitted per second by the user with user ID "111" not exceeding 2 times), and pre-apply a token for the access request based on the updated API flow control sub-rule. If the match fails, pre-apply a token for the access request based on the currently executed API flow control sub-rule.
[0079] Among them, in this application, the user identifier can be an identifier used to represent a single user or an identifier used to represent a single rule group, and the user identifier can be obtained from the above request information.
[0080] During the process of executing the API flow control sub-rule as described above, if any API flow control sub-rule fails to pre-apply a token, stop executing the subsequent API flow control sub-rules for the access request, and determine that the pre-application of the token fails based on the currently executed API flow control sub-rule, that is, it means that the pre-application of the token for the currently executed flow control rule fails.
[0081] If all the API flow control sub-rules included in the target API flow control rule corresponding to a certain flow control rule successfully pre-apply tokens after the pre-application of tokens, determine that the pre-application of the token based on the currently executed flow control rule is successful, and the next flow control rule can be continued to be executed.
[0082] If the pre - application of a token fails based on any flow control rule, stop executing the subsequent flow control rules for the access request, determine that the flow control result of the access request is not passed, and release all the tokens pre - applied by the rules for which the pre - application of the token is successful.
[0083] The above introduced the entire process of flow control. The introduction of custom user flow control rules allows for providing different flow control rules for specific users (such as VIP users, administrators, etc.), improving service quality and differentiated services, enhancing the user experience. For requests that fail to pre - apply a token for the flow control rules, subsequent processing can be blocked in a timely manner, effectively avoiding waste of resources and reducing the processing of unnecessary requests.
[0084] S405, in response to the flow control result being passed, apply for a valid token for the access request based on the tokens pre - applied for each flow control rule.
[0085] If tokens are successfully pre - applied for all flow control rules after the pre - application of tokens based on all flow control rules, determine that the flow control result of the access request is passed, and formally apply for tokens as valid tokens based on all the pre - applied tokens.
[0086] S406, send the request parameters to the target call service and receive the access response returned by the target call service.
[0087] Among them, the request parameters can be obtained from the above - mentioned request information.
[0088] Exemplarily, if the access request is an order query request, then send the relevant request parameters to the order query call service and receive the access response returned by the target call service.
[0089] S407, send the access response to the client.
[0090] This application embodiment introduced the entire process of flow control. By parsing step by step according to the URL path and querying the pre - constructed rule tree with the path prefix as the key, finding the required rule set only depends on the length and structure of the URL path, and is not affected by the total number of flow control rules, ensuring that as the number of rules increases, the query speed will not decrease significantly, improving the efficiency of traffic control, reducing unnecessary calculations and resource consumption. The introduction of custom user flow control rules allows for providing different flow control rules for specific users, improving service quality and differentiated services; after the flow control is passed, the access response can be returned to the client in a timely manner, enhancing the user experience.
[0091] For ease of understanding, the following introduces Figure 6 the process of executing the flow control rules included in the flow control rule set for the access request.
[0092] Figure 6It is a schematic diagram of the process of executing the traffic control rules included in the traffic control rule set shown in this application. As Figure 6 shown, continue with the URL path: / v1 / test / test1 / test2, and the traffic control rule set: {traffic control rule 1, traffic control rule 2, traffic control rule 3} as an example, and assume the user identifier is "111".
[0093] As Figure 6 shown, traffic control rule 1, traffic control rule 2, and traffic control rule 3 all include API traffic control rules. First, execute traffic control rule 1. The only API traffic control rule included in traffic control rule 1 is API traffic control rule 1.1, and API traffic control rule 1.1 has no path prefix restriction, so API traffic control rule 1.1 is used as the target API traffic control rule, and then the API traffic control sub-rules included in API traffic control rule 1.1 are obtained. As Figure 6 shown, the API traffic control sub-rules included in API traffic control rule 1.1 are API traffic control sub-rule 1.1.1 and API traffic control sub-rule 1.1.2, and then tokens are pre-applied for the access request in the order of the API traffic control sub-rules.
[0094] During the process of pre-applying tokens for the access request in the order of the API traffic control sub-rules, first pre-apply a token for the access request based on API traffic control sub-rule 1.1.1. Since API traffic control sub-rule 1.1.1 is not a user dimension related sub-rule, directly execute API traffic control sub-rule 1.1.1. After successfully pre-applying a token based on API traffic control sub-rule 1.1.1, continue to pre-apply a token based on API traffic control sub-rule 1.1.2. Since API traffic control sub-rule 1.1.2 is a user dimension related sub-rule, and traffic control rule 1 includes custom user traffic control rule 1.1, and custom user traffic control rule 1.1 has no path prefix restriction, so custom user traffic control rule 1.1 is used as the target custom user traffic control rule. Suppose a custom user traffic control sub-rule 1.1.1 with the user identifier "111" is matched from custom user traffic control rule 1.1, then the relevant parameters of API traffic control sub-rule 1.1.2 are updated and executed based on the relevant parameters in custom user traffic control sub-rule 1.1.1. After execution and successful pre-application of the token, that is, after API traffic control rule 1.1 is executed and passed, that is, traffic control rule 1 is executed and passed, then continue to execute traffic control rule 2.
[0095] As Figure 6 shown, only API traffic control rule 2.1 is included in traffic control rule 2, and there is no path prefix restriction, so API traffic control rule 2.1 is used as the target API traffic control rule, and then the API traffic control sub-rules included in API traffic control rule 2.1 are obtained. As Figure 6As shown, API flow control rule 2.1 only includes API flow control sub-rule 2.1.1, and API flow control sub-rule 2.1.1 is not a user-dimension related sub-rule. Then, directly execute the pre-application token for API flow control sub-rule 2.1.1. After the pre-application token is successful, that is, after API flow control rule 2.1 is executed and passed, that is, flow control rule 2 is passed, then continue to execute flow control rule 3.
[0096] As Figure 6 shown, flow control rule 3 includes API flow control rule 3.1 and API flow control rule 3.2. Based on the path prefix, API flow control rule 3.2 is matched as the target API flow control rule, and then obtain the API flow control sub-rules included in API flow control rule 3.2. As Figure 6 shown, API flow control rule 3.2 only includes API flow control sub-rule 3.2.1, and API flow control sub-rule 3.2.1 is a user-dimension related sub-rule. Then, based on the path prefix, match the custom user flow control rule 3.2. Assume that there is no related sub-rule with user identifier "111" in the custom user flow control rule 3.2. Then, still execute the pre-application token for API flow control sub-rule 3.2.1. After the pre-application token is successful, that is, after API flow control rule 3.2 is executed and passed, that is, flow control rule 3 is passed.
[0097] Assume that the above flow control rules 1, 2, and 3 are all passed. Then, determine that the flow control result of the access request is flow control passed.
[0098] If, during the above pre-application token process, the pre-application token of a certain sub-rule fails, then determine that the flow control result of the access request is flow control not passed.
[0099] Figure 7 is a schematic diagram of an exemplary embodiment of a traffic control method shown in this application. As Figure 7 shown, the traffic control method includes the following steps:
[0100] S701, Receive an access request sent by the client, and extract the request information carried in the access request. The request information includes the URL path.
[0101] S702, Parse the URL path step by step, and extract the path prefixes at each level.
[0102] S703, According to the level order of the path prefixes, query the nodes of the pre-constructed rule tree with the path prefix as the key, and form a flow control rule set corresponding to the access request based on the flow control rules stored in the queried nodes.
[0103] S704, Execute the flow control rules included in the flow control rule set for the access request to obtain the flow control result.
[0104] For the specific implementation manners of steps S701 to S704, reference may be made to the specific introduction of the relevant parts in the foregoing embodiments, and details are not described herein again.
[0105] S705. In response to the flow control result being that the flow control fails, obtain the flow control rule for which the token pre-application fails as the target flow control rule.
[0106] If the flow control result of the access request is that the flow control fails, release all the tokens that are successfully pre-applied during the process of pre-applying tokens based on the flow control rule, and determine the flow control rule for which the token pre-application fails as the target flow control rule.
[0107] S706. In response to a custom error feedback being set in the target flow control rule, send the custom error feedback to the client.
[0108] Among them, the custom error feedback may include a custom error code and custom error information.
[0109] S707. In response to no custom error feedback being set in the target flow control rule, send a preset error feedback to the client.
[0110] Among them, the preset error feedback may include a preset error code and preset error information.
[0111] In the embodiment of the present application, if the flow control fails, releasing the tokens that have been successfully pre-applied helps to avoid resource waste and can ensure that system resources are not unnecessarily occupied due to the invalid use of tokens; by sending a custom error feedback or a preset error feedback to the client, it is easier for the client to understand the root cause of the error, which helps to improve the user experience.
[0112] Among them, the API gateway responsible for flow control usually consists of multiple service replicas.
[0113] Furthermore, the present application can also perform flow control simulation preview. The specific steps are as follows: receive first flow control adjustment information and first simulation request data (including user simulation access requests) for flow control simulation preview; determine the first flow control service replica for performing flow control simulation preview; perform flow control simulation preview inside the first flow control service replica according to the first flow control adjustment information and the first simulation request data to obtain preview data.
[0114] Specifically, the process of performing flow control simulation preview inside the first flow control service replica based on the first flow control adjustment information and the first simulated request data includes: copying the original rule tree stored therein by the first flow control service replica to obtain a copied rule tree, and updating the copied rule tree based on the first flow control adjustment information; performing flow control simulation preview inside the first flow control service replica based on the first simulated request data and the updated copied rule tree to obtain preview data, and deleting the updated copied rule tree stored in the first flow control service replica after the simulation preview ends.
[0115] Thus, by performing flow control simulation preview, flow control simulation preview can be carried out without disturbing the actual production environment, and new flow control rules can be safely verified, enabling potential problems and optimization points to be discovered before putting them into the production environment, and reducing the risks after going live.
[0116] Furthermore, the present application can also conduct A / B testing. The specific steps are as follows: determining the second flow control service replica and the third flow control service replica for conducting A / B testing; receiving, by the second flow control service replica, the second flow control adjustment information, the second simulated request data, and the A / B testing termination condition sent by the A / B testing invoker; starting the A / B testing. During the A / B testing process, perform flow control simulation in the second flow control service replica according to the second flow control adjustment information and the second simulated request data, and send the first flow control data corresponding to the second flow control service replica to the A / B testing invoker in real time. During the A / B testing process, perform flow control on the third flow control service replica based on the online real request data, and send the second flow control data corresponding to the third flow control service replica to the A / B testing invoker in real time; in response to monitoring that the second flow control service replica meets the A / B testing termination condition, terminate the A / B testing.
[0117] Specifically, performing flow control simulation in the second flow control service replica according to the second flow control adjustment information and the second simulated request data includes: updating the original rule tree stored inside the second flow control service replica based on the second flow control adjustment information; performing flow control simulation inside the second flow control service replica based on the second simulated request data and the updated rule tree.
[0118] After terminating the A / B testing, it further includes: restoring the updated rule tree stored inside the second flow control service replica to the original rule tree and making it effective.
[0119] Among them, the Server-Sent Events (SSE) technology can be used to send the first flow control data corresponding to the second flow control service replica to the A / B testing invoker in real time.
[0120] By conducting A / B tests, it is possible to compare the flow control effects of new and old configurations without affecting the flow control of other gateway service replicas. Even in a production environment, A / B tests can ensure that new flow control configurations do not have a negative impact on existing services, thus avoiding instability in the production environment. Real-time sending of flow control data to the A / B test invoker enables real-time monitoring and data feedback of the experimental process, helping developers instantly understand the behavioral differences under different flow control configurations, quickly identify potential problems, and make corresponding adjustments.
[0121] Figure 8 is a schematic diagram of a traffic control device shown in the present application. As Figure 8 shown, the traffic control device 800 includes a receiving module 801, a parsing module 802, a building module 803, and an execution module 804, where:
[0122] The receiving module 801 is used to receive access requests sent by clients and extract the request information carried in the access requests. The request information includes the Uniform Resource Locator (URL) path.
[0123] The parsing module 802 is used to parse the URL path step by step and extract the path prefixes at each level.
[0124] The building module 803 is used to query the nodes of the pre-built rule tree with the path prefix as the key according to the level order of the path prefixes, and build a set of flow control rules corresponding to the access requests based on the flow control rules stored in the queried nodes.
[0125] The execution module 804 is used to execute the flow control rules included in the set of flow control rules for the access requests to obtain a flow control result.
[0126] The traffic control method provided by this device parses step by step according to the URL path and queries the pre-built rule tree with the path prefix as the key. Finding the required rule set only depends on the length and structure of the URL path, and is not affected by the total number of flow control rules. This ensures that when the number of rules increases, the query speed will not decrease significantly, improving the efficiency of traffic control and reducing unnecessary calculations and resource consumption. By managing flow control rules in the way of pre-building a rule tree, it can flexibly handle the addition of new rules.
[0127] Furthermore, the execution module 804 is further used to: sequentially determine the currently to-be-executed flow control rule from the set of flow control rules; pre-apply tokens for the access requests based on the currently to-be-executed flow control rule; in response to successfully pre-applying tokens for all flow control rules, determine the flow control result as flow control passed; in response to failing to pre-apply tokens for any flow control rule, stop executing the subsequent flow control rules for the access requests and determine the flow control result as flow control not passed.
[0128] Further, the execution module 804 is further configured to: obtain the API flow control rules included in the current flow control rule to be executed, and sequentially match the API flow control rules based on the path prefix to obtain the target API flow control rules that match successfully; obtain the API flow control sub-rules included in the target API flow control rules, and sequentially pre-apply tokens for the access request according to the order of the API flow control sub-rules; in response to successfully pre-applying tokens for all API flow control sub-rules, determine that the pre-application of tokens based on the currently executed flow control rule is successful; in response to the failure of pre-applying tokens for any one API flow control sub-rule, stop executing the subsequent API flow control sub-rules for the access request, and determine that the pre-application of tokens based on the currently executed flow control rule fails.
[0129] Further, the request information further includes a user identifier, and the execution module 804 is further configured to: determine the currently executed API flow control sub-rule, and determine whether the currently executed API flow control sub-rule is a user dimension related sub-rule; in response to the currently executed API flow control sub-rule being a user dimension related sub-rule and the currently executed flow control rule including a custom user flow control rule, sequentially match the custom user flow control rules based on the path prefix to obtain the target custom user flow control rules that match successfully; match the target custom user flow control sub-rules related to the access request from the target custom user flow control rules based on the user identifier; update the parameters of the currently executed API flow control sub-rule based on the target custom user flow control sub-rule, and pre-apply tokens for the access request based on the updated API flow control sub-rule.
[0130] Further, the execution module 804 is further configured to: in response to the failure of the user identifier to match the target custom user flow control rule, pre-apply tokens for the access request based on the currently executed API flow control sub-rule.
[0131] Further, the execution module 804 is further configured to: in response to the currently executed flow control rule only including API flow control rules, pre-apply tokens for the access request based on the currently executed API flow control sub-rule.
[0132] Further, the execution module 804 is further configured to: in response to the currently executed API flow control sub-rule being other dimension related sub-rules except user dimension related sub-rules, pre-apply tokens for the access request based on the currently executed API flow control sub-rule.
[0133] Further, the execution module 804 is further configured to: apply for a valid token for the access request based on the tokens pre-applied for each flow control rule; send the request parameters to the target call service, and receive the access reply returned by the target call service; send the access reply to the client.
[0134] Further, the execution module 804 is further configured to: obtain the flow control rule for which the token pre-application fails as the target flow control rule; and in response to a custom error feedback being set in the target flow control rule, send the custom error feedback to the client.
[0135] Further, the execution module 804 is further configured to: release all the tokens that are pre-applied successfully during the process of pre-applying tokens based on the flow control rule.
[0136] Further, the traffic control device 800 further includes a preview module, which is configured to: receive the first flow control adjustment information and the first simulation request data for flow control simulation preview; determine the first flow control service replica for performing flow control simulation preview; and perform flow control simulation preview inside the first flow control service replica according to the first flow control adjustment information and the first simulation request data to obtain preview data.
[0137] Further, the preview module is further configured to: copy the original rule tree stored therein based on the first flow control service replica to obtain a copied rule tree, and update the copied rule tree based on the first flow control adjustment information; perform flow control simulation preview inside the first flow control service replica based on the first simulation request data and the updated copied rule tree, and delete the updated copied rule tree stored in the first flow control service replica after the simulation preview ends.
[0138] Further, the traffic control device 800 further includes an AB experiment module, which is configured to: determine the second flow control service replica and the third flow control service replica for performing the AB experiment; receive, based on the second flow control service replica, the second flow control adjustment information, the second simulation request data, and the AB experiment termination condition sent by the AB experiment invoker; start the AB experiment, and during the AB experiment, perform flow control simulation in the second flow control service replica according to the second flow control adjustment information and the second simulation request data, and send the first flow control data corresponding to the second flow control service replica to the AB experiment invoker in real time; during the AB experiment, perform flow control on the third flow control service replica based on the online real request data, and send the second flow control data corresponding to the third flow control service replica to the AB experiment invoker in real time; and in response to monitoring that the second flow control service replica satisfies the AB experiment termination condition, terminate the AB experiment.
[0139] Further, the AB experiment module is further configured to: update the original rule tree stored inside the second flow control service replica based on the second flow control adjustment information; and perform flow control simulation in the second flow control service replica based on the second simulation request data and the updated rule tree.
[0140] Further, the AB experiment module is further configured to: restore the updated rule tree stored inside the second flow control service replica to the original rule tree and make it effective.
[0141] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0142] Figure 9 A schematic block diagram of an exemplary electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as, for example, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, for example, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0143] As Figure 9 shown, the device 900 includes a computing unit 901 that can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0144] A plurality of components in the device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a magnetic disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0145] The computing unit 901 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 executes the various methods and processes described above, such as the flow control method. For example, in some embodiments, the flow control method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the flow control method described above can be executed. Alternatively, in other embodiments, the computing unit 901 can be configured to execute the flow control method by any other suitable means (e.g., by means of firmware).
[0146] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a dedicated or general-purpose programmable processor, and can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0147] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program code is executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code can be executed entirely on the machine, partially on the machine, as an independent software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0148] In the context of this disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0149] To provide for interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can also be used to provide for interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic, speech, or tactile input).
[0150] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of a communication network include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0151] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is generated by computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
[0152] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitations are imposed herein.
[0153] The above specific embodiments do not constitute a limitation on the protection scope of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub - combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the protection scope of this disclosure.
Claims
1. A flow control method, comprising: Receive an access request sent by a client, and extract request information carried in the access request, wherein the request information includes a uniform resource locator URL path; Parse the URL path level by level to extract the path prefixes at each level; According to the level order of the path prefix, the nodes of the pre-constructed rule tree are queried with the path prefix as the key, and a flow control rule set corresponding to the access request is formed based on the flow control rules stored in the queried nodes; Execute the flow control rules included in the flow control rule set on the access request to obtain a flow control result.
2. The method according to claim 1, wherein: The executing the flow control rules included in the flow control rule set on the access request to obtain a flow control result includes: Determining the current flow control rule to be executed in order from the flow control rule set; Pre-applying for a token for the access request based on the current flow control rule to be executed; In response to successfully pre-applying for a token after pre-applying for a token based on all the flow control rules is completed, determining that the flow control result is a flow control pass; In response to a failure in pre-applying for a token based on any of the flow control rules, stopping execution of subsequent flow control rules on the access request, and determining that the flow control result is flow control failure.
3. The method according to claim 2, wherein: The pre-applying for a token for the access request based on the current flow control rule to be executed includes: Acquire the application programming interface API flow control rule included in the current flow control rule to be executed, and match the API flow control rules in sequence based on the path prefix to obtain a successfully matched target API flow control rule; Acquire the API flow control sub-rules included in the target API flow control rule, and pre-apply for a token for the access request in sequence according to the order of the API flow control sub-rules; In response to the token being successfully pre-applied for after all the API flow control sub-rules have pre-applied for the token, determining that the token pre-application based on the currently executed flow control rule is successful; In response to a failure in pre-applying for a token based on any of the API flow control sub-rules, stopping execution of subsequent API flow control sub-rules on the access request, and determining that a pre-applying for a token based on the currently executed flow control rule has failed.
4. The method according to claim 3, wherein: The request information also includes a user identifier, and the pre-application for a token for the access request in the order of the API flow control sub-rules includes: Determine the currently executed API flow control sub-rule, and judge whether the currently executed API flow control sub-rule is a user dimension related sub-rule; In response to the currently executed API flow control sub-rule being a user dimension related sub-rule, and the currently executed flow control rule including a custom user flow control rule, matching the custom user flow control rules in sequence based on the path prefix to obtain a successfully matched target custom user flow control rule; Based on the user identifier, matching the target user flow control rule to obtain a target user flow control sub-rule related to the access request; The parameters of the currently executed API flow control sub-rule are updated based on the target customized user flow control sub-rule, and a token is pre-applied for the access request based on the updated API flow control sub-rule.
5. The method according to claim 4, wherein: After obtaining the successfully matched target customized user flow control rule, the method further includes: In response to a failure in matching the user identifier with the target customized user flow control rule, pre-applying for a token for the access request based on the currently executed API flow control sub-rule.
6. The method according to claim 4, wherein: After the currently executed API flow control sub-rule is a user dimension related sub-rule, the method further includes: In response to the currently executed flow control rule only including the API flow control rule, a token is pre-applied for the access request based on the currently executed API flow control sub-rule.
7. The method according to claim 4, wherein: After determining whether the currently executed API flow control sub-rule is a user dimension related sub-rule, the method further includes: In response to the currently executed API flow control sub-rule being a sub-rule related to other dimensions except the sub-rule related to the user dimension, a token is pre-applied for the access request based on the currently executed API flow control sub-rule.
8. The method according to any one of claims 2 to 7, wherein: The request information also includes a request parameter. After determining that the flow control result is a flow control pass, the method further includes: Applying for a valid token for the access request based on the token pre-applied for each flow control rule; Sending the request parameters to the target invocation service, and receiving an access response returned by the target invocation service; The access response is sent to the client.
9. The method according to any one of claims 2 to 7, wherein: After determining that the flow control result is that the flow control fails, the method further includes: Get the flow control rule for token pre-application failure as the target flow control rule; In response to custom error feedback being set in the target flow control rule, the custom error feedback is sent to the client.
10. The method according to any one of claims 2 to 7, wherein: After determining that the flow control result is that the flow control fails, the method further includes: Release all tokens that are successfully pre-applied for in the process of pre-applying for tokens based on the flow control rule.
11. The method according to claim 1, wherein: The method further comprises: Receiving first flow control adjustment information and first simulation request data for flow control simulation preview; Determine a first flow control service copy for performing flow control simulation preview; A flow control simulation preview is performed inside the first flow control service copy according to the first flow control adjustment information and the first simulation request data to obtain preview data.
12. The method according to claim 11, wherein: The performing flow control simulation preview inside the first flow control service copy according to the first flow control adjustment information and the first simulation request data includes: Based on the first flow control service copy, the original rule tree stored therein is copied to obtain a copied rule tree, and the copied rule tree is updated based on the first flow control adjustment information; A flow control simulation preview is performed within the first flow control service replica based on the first simulation request data and the updated replication rule tree, and the updated replication rule tree stored in the first flow control service replica is deleted after the simulation preview is completed.
13. The method according to claim 1, wherein: The method further comprises: Determine the second flow control service replica and the third flow control service replica for conducting the AB experiment; Receive the second flow control adjustment information, the second simulation request data and the AB experiment termination condition sent by the AB experiment caller based on the second flow control service copy; Start the AB experiment. During the AB experiment, perform flow control simulation on the second flow control service copy according to the second flow control adjustment information and the second simulation request data, and send the first flow control data corresponding to the second flow control service copy to the AB experiment caller in real time; During the AB experiment, the third flow control service copy performs flow control based on the real online request data, and sends the second flow control data corresponding to the third flow control service copy to the AB experiment caller in real time; In response to monitoring that the second flow control service copy meets the AB experiment termination condition, the AB experiment is terminated.
14. The method according to claim 13, wherein: The performing flow control simulation on the second flow control service copy according to the second flow control adjustment information and the second simulation request data includes: Updating the original rule tree stored in the second flow control service copy based on the second flow control adjustment information; Flow control simulation is performed within the second flow control service copy based on the second simulation request data and the updated rule tree.
15. The method according to claim 14, wherein: After the AB experiment is terminated, the method further includes: The updated rule tree stored in the second flow control service copy is restored to the original rule tree and takes effect.
16. A flow control device, comprising: A receiving module, configured to receive an access request sent by a client, and extract request information carried in the access request, wherein the request information includes a uniform resource locator URL path; A parsing module, used to parse the URL path level by level and extract the path prefixes at each level; A building module, used to query the nodes of the pre-built rule tree according to the level order of the path prefix and use the path prefix as a key, and build a flow control rule set corresponding to the access request based on the flow control rules stored in the queried nodes; An execution module is used to execute the flow control rules included in the flow control rule set on the access request to obtain a flow control result.
17. An electronic device comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 15.
18. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-15.
19. A computer program product comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 15.