Flow control processing method and device

By obtaining and executing an array of flow control rules in the gateway, the problem of inability to accurately filter and multi-dimensionally restrict abnormal traffic in the existing technology is solved, and fine-grained precise control of business traffic is achieved to avoid accidental killing of normal traffic and meet the needs of complex scenarios. .

CN118714079APending Publication Date: 2024-09-27BEIJING JINGDONG YUANSHENG TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410907159.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

Existing technology cannot support users to independently and accurately filter abnormal business traffic, and cannot accurately restrict abnormal business traffic in multiple dimensions and levels, making it easy to mistakenly restrict normal business traffic.

Method used

By receiving the gateway call request, obtain the flow control rule array, determine the current flow control rule according to the configuration sequence, perform logical operations and verify the data length, count the number of requests, and perform flow control processing if it exceeds the threshold, supporting multi-condition relationships and multi-dimensionality Combination rules.

Benefits of technology

It achieves finer-grained and precise control of business traffic, avoids accidental killing of normal traffic, meets the needs of complex business scenarios, and enhances the security and maintainability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118714079A
    Figure CN118714079A
Patent Text Reader

Abstract

The invention discloses a flow control processing method and device, and relates to the technical field of computers. A specific embodiment of the method comprises the following steps: receiving a calling request for a gateway, and obtaining a flow control rule array; under the condition that the previous flow control rule does not trigger flow control, a data source is determined according to the current flow control rule, and logic operation in the current flow control rule is executed on data under the data source; checking whether the length of the data is smaller than or equal to the pre-configured length in the current flow control rule in response to the fact that the logical operation result meets the preset requirement, splicing the data with the checking result being smaller than or equal to obtain a flow control key name, and determining a time period for setting a flow control threshold value in the current flow control rule; and counting the number of requests which call the gateway in the current time period and of which the processing results are the flow control key names, and performing flow control processing on the call requests when the number of the requests is greater than or equal to the flow control threshold value corresponding to the flow control key names. According to the implementation mode, accurate flow control can be realized for the service dimension with finer granularity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a flow control processing method and device. Background Art

[0002] In the process of building IT systems for large Internet companies, in order to ensure the security and stability of backend services, traffic control rules are often added at the gateway level to protect upstream services. Currently, most API (Application Programming Interface) gateways on the market can limit the flow of a certain request attribute of an API, such as the parameter attribute of a selected dimension. After that, the API gateway can set the threshold control of the flow limit for this dimension, such as limiting the flow at intervals of seconds, minutes, hours, etc.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: although the prior art can perform flow control in a very coarse-grained manner in a single dimension, it cannot support users to independently perform precise filtering to screen abnormal business traffic, and further cannot perform multi-dimensional and precise restrictions on abnormal business traffic, which has the disadvantage of easily restricting normal business traffic. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a flow control processing method and device, which can at least solve the problem that the prior art cannot support users to independently and accurately filter and screen abnormal business traffic, and cannot accurately limit abnormal business traffic in multiple dimensions and levels.

[0005] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a flow control processing method is provided, comprising: receiving a call request to a gateway, and obtaining a flow control rule array corresponding to the gateway; wherein the flow control rule array is obtained by arranging the flow control rules in a configuration order; determining the current flow control rule in the flow control rule array in order, and when the previous flow control rule does not trigger flow control, determining the data source according to the current flow control rule, performing the logical operation in the current flow control rule on the data under the data source, and obtaining the logical operation result; in response to the logical operation result meeting the preset requirements, verifying whether the length of the data is less than or equal to the pre-configured length in the current flow control rule, performing splicing processing on the data with the verification result being less than or equal to, obtaining the flow control key name, and determining the time period for setting the flow control threshold in the current flow control rule; counting the number of requests that call the gateway in the current time period and whose processing result is the flow control key name, and when the number of requests is greater than the flow control threshold corresponding to the flow control key name, performing flow control processing on the call request.

[0006] Optionally, the current flow control rule includes one or more judgment expressions and multi-conditional relationships; the data source is determined according to the current flow control rule, and the logical operation in the current flow control rule is performed on the data under the data source to obtain the logical operation result, including: according to the data source in each judgment expression, the data to be compared is obtained, and then the logical operation is performed on the data to be compared according to the judgment expression to obtain the operation result; according to the multi-conditional relationship, the operation results of one or more judgment expressions are subjected to AND or OR operations to obtain the logical operation result of the current flow control rule.

[0007] Optionally, the flow control rules include multi-dimensional combination rules of flow control fields, and the multi-dimensional combination rules of flow control fields include data source, field name, and pre-configured maximum length; in response to the logical operation result meeting the preset requirements, verifying whether the length of the data is less than or equal to the pre-configured length in the current flow control rules, including: when the logical operation result is true, obtaining the corresponding data according to the data source and field name; determining the maximum length corresponding to the data source and field name, verifying whether the length of each data obtained is less than or equal to the maximum length, and intercepting the data whose verification result is greater than.

[0008] Optionally, the method also includes: receiving a gateway interface group selected in the flow control rule maintenance interface; in response to a selection operation on the flow control rule configuration in the flow control rule maintenance interface, displaying the flow control rule configuration interface, receiving one or more judgment expressions and multi-conditional relationships configured in the flow control rule configuration interface; in response to a selection operation on the flow control field configuration in the flow control rule configuration interface, displaying the flow control field configuration interface, receiving one or more data sources selected in the flow control field configuration interface, and the field name, data source, and maximum length configured for each data source, and generating a multi-dimensional combination rule for the flow control field; receiving the flow control threshold configured in the flow control rule configuration interface; generating flow control rules based on one or more judgment expressions and multi-conditional relationships, multi-dimensional combination rules for flow control fields, and flow control thresholds, and then generating a flow control rule array corresponding to the gateway interface group in the order in which the flow control rules are generated.

[0009] Optionally, the determination expression consists of one or more of a data type, a data source, a data field, a calling method, a business type, a basic data source, and a field name.

[0010] Optionally, the method also includes: in response to the operation of adding a new business type name in the business type attribute maintenance interface, assigning a primary key to the newly added business type name to establish a correspondence between the primary key and the business type name, and storing the correspondence in the storage structure of the business type attribute; in response to the business type primary key selected in the business type data maintenance interface, receiving the data code input for the selected business type primary key to assign basic data corresponding to the data code to the selected business type primary key; in response to the selection operation of one or more basic data under one or more business type primary keys in the basic data management interface, performing batch enable or disable operations on the selected basic data, and storing the business type primary key, data code, enable or disable in the storage structure of the business type data.

[0011] Optionally, the method further includes: in response to the existence of a business type in the judgment expression, determining the corresponding business type primary key according to the name of the business type, and querying the data encoding corresponding to the business type primary key and marked as enabled; in response to the existence of data corresponding to the data encoding in the cache, returning the data to the gateway; in response to the absence of data corresponding to the data encoding in the cache, if there is data corresponding to the data encoding in the database, returning the data to the cache, so as to return the data to the gateway through the cache, and if there is no data corresponding to the data encoding in the database, returning a null value to the cache, so as to return the null value to the gateway through the cache.

[0012] Optionally, obtaining the flow control rule array corresponding to the gateway includes: in response to monitoring that the gateway is called, querying from the memory of the local process whether there is a flow control rule array corresponding to the gateway, and if the query is that it exists, returning the flow control rule array to the gateway; if the query result is that it does not exist, it is determined that this is the first call, and querying from the server-level cache service whether there is a flow control rule array corresponding to the gateway, and obtaining the flow control rule array using a processing method corresponding to the query result and returning it to the gateway.

[0013] Optionally, the processing method corresponding to the query result is adopted to obtain the flow control rule array and return it to the gateway, including: if the query result is existence, the flow control rule array is synchronized to the memory, so as to return the flow control rule array to the gateway through the memory; if the query result is not existence, the server-level lock is obtained, and whether there is a flow control rule array corresponding to the gateway from the remote cache; if the query result is existence, the flow control rule array is synchronized to the server-level cache service, and the server-level lock is released, so as to synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory; if the query result is not existence, the flow control rule array corresponding to the gateway is queried from the remote database, the flow control rule array is synchronized to the remote cache, so as to synchronize the flow control rule array to the cache service through the remote cache, and the server-level lock is released, and then the flow control rule array is synchronized to the memory through the cache service, and the flow control rule array is returned to the gateway through the memory.

[0014] Optionally, when multiple call requests are received at the same time, the server-level lock is obtained and the remote cache is queried to see whether there is a flow control rule array corresponding to the gateway, including: for the first call request that preferentially obtains the server-level lock among the multiple call requests, if the cache service does not have a cache code of the flow control rule array corresponding to the gateway, the flow control rule array corresponding to the gateway is queried from the remote cache; after the first call request releases the server-level lock, for the second call request that obtains the server-level lock second among the multiple call requests, if the cache service has a cache code of the flow control rule array corresponding to the gateway, the server-level lock is released.

[0015] Optionally, the method also includes: after synchronizing the flow control rule array from the first position to the second position, in response to the flow control rule array being set with a cache code at the first position, using the cache code of the flow control rule array at the first position as the cache code of the flow control rule array at the second position; wherein the first position is one of a remote database, a remote cache and a server-level cache, the second position is one of a remote cache, a server-level cache and a memory, the level of the first position is smaller than the level of the second position, and the levels of the first position and the second position are adjacent; in response to the flow control rule array not being set with a cache code at the first position, setting a cache code for the flow control rule array at the second position based on the cache code setting rule at the second position; and setting the expiration time of the flow control rule array at the second position to the expiration time pre-configured at the second position.

[0016] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a flow control processing device is provided, comprising: a receiving module, used to receive a call request to a gateway, and obtain a flow control rule array corresponding to the gateway; wherein the flow control rule array is obtained by arranging the flow control rules in a configuration order; a flow control processing module, used to sequentially determine the current flow control rule in the flow control rule array, and when the previous flow control rule does not trigger flow control, determine the data source according to the current flow control rule, perform the logical operation in the current flow control rule on the data under the data source, and obtain the logical operation result; in response to the logical operation result meeting the preset requirements, verify whether the length of the data is less than or equal to the pre-configured length in the current flow control rule, perform splicing processing on the data with the verification result being less than or equal to, obtain the flow control key name, and determine the time period for setting the flow control threshold in the current flow control rule; count the number of requests that call the gateway in the current time period and whose processing result is the flow control key name, and when the number of requests is greater than the flow control threshold corresponding to the flow control key name, perform flow control processing on the call request.

[0017] Optionally, the current flow control rule includes one or more judgment expressions and multiple conditional relationships; the flow control processing module is used to: obtain the data to be compared according to the data source in each judgment expression, and then perform logical operations on the data to be compared according to the judgment expression to obtain the operation result; according to the multiple conditional relationships, perform AND or OR operations on the operation results of one or more judgment expressions to obtain the logical operation result of the current flow control rule.

[0018] Optionally, the flow control rules include multi-dimensional combination rules of flow control fields, and the multi-dimensional combination rules of flow control fields include data source, field name, and pre-configured maximum length; the flow control processing module is used to: when the result of the logical operation is true, obtain the corresponding data according to the data source and field name; determine the maximum length corresponding to the data source and field name, check whether the length of each data obtained is less than or equal to the maximum length, and intercept the data whose verification result is greater than.

[0019] Optionally, the flow control processing module is also used to: receive a gateway interface group selected in the flow control rule maintenance interface; in response to a selection operation on the flow control rule configuration in the flow control rule maintenance interface, display the flow control rule configuration interface, and receive one or more judgment expressions and multi-conditional relationships configured in the flow control rule configuration interface; in response to a selection operation on the flow control field configuration in the flow control rule configuration interface, display the flow control field configuration interface, receive one or more data sources selected in the flow control field configuration interface, and the field name, data source, and maximum length configured for each data source, and generate a multi-dimensional combination rule for the flow control field; receive the flow control threshold configured in the flow control rule configuration interface; generate flow control rules based on one or more judgment expressions and multi-conditional relationships, multi-dimensional combination rules for flow control fields, and flow control thresholds, and then generate a flow control rule array corresponding to the gateway interface group in the order in which the flow control rules are generated.

[0020] Optionally, the determination expression consists of one or more of a data type, a data source, a data field, a calling method, a business type, a basic data source, and a field name.

[0021] Optionally, the device also includes a type and data maintenance module, which is used to: in response to the operation of adding a new business type name in the business type attribute maintenance interface, assign a primary key to the newly added business type name to establish a correspondence between the primary key and the business type name, and store the correspondence in the storage structure of the business type attribute; in response to the business type primary key selected in the business type data maintenance interface, receive the data code input for the selected business type primary key to assign basic data corresponding to the data code to the selected business type primary key; in response to the selection operation of one or more basic data under one or more business type primary keys in the basic data management interface, perform batch enable or disable operations on the selected basic data, and store the business type primary key, data code, enable or disable in the storage structure of the business type data.

[0022] Optionally, the flow control processing module is also used to: in response to the existence of a business type in the judgment expression, determine the corresponding business type primary key according to the name of the business type, and query the data encoding corresponding to the business type primary key and marked as enabled; in response to the existence of data corresponding to the data encoding in the cache, return the data to the gateway; in response to the absence of data corresponding to the data encoding in the cache, if there is data corresponding to the data encoding in the database, return the data to the cache, so as to return the data to the gateway through the cache, and if there is no data corresponding to the data encoding in the database, return a null value to the cache, so as to return the null value to the gateway through the cache.

[0023] Optionally, the device also includes a flow control rule loading and parsing module, which is used to: in response to monitoring that the gateway is called, query whether there is a flow control rule array corresponding to the gateway from the memory of the local process; if the query is that it exists, return the flow control rule array to the gateway; if the query result is that it does not exist, it is determined that this is the first call, and query whether there is a flow control rule array corresponding to the gateway from the server-level cache service, and obtain the flow control rule array using a processing method corresponding to the query result and return it to the gateway.

[0024] Optionally, the flow control rule loading and parsing module is used to: if the query result is existence, synchronize the flow control rule array to the memory, and return the flow control rule array to the gateway through the memory; if the query result is non-existence, obtain the server-level lock, and query whether there is a flow control rule array corresponding to the gateway from the remote cache; if the query result is existence, synchronize the flow control rule array to the server-level cache service, and release the server-level lock, so as to synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory; if the query result is non-existence, query the flow control rule array corresponding to the gateway from the remote database, synchronize the flow control rule array to the remote cache, so as to synchronize the flow control rule array to the cache service through the remote cache, release the server-level lock, and then synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory.

[0025] Optionally, when multiple call requests are received at the same time, the flow control rule loading and parsing module is used to: for the first call request that preferentially obtains the server-level lock among the multiple call requests, if the cache service does not have a flow control rule array cache code corresponding to the gateway, query the flow control rule array corresponding to the gateway from the remote cache; after the first call request releases the server-level lock, for the second call request that obtains the server-level lock second among the multiple call requests, if the cache service has a flow control rule array cache code corresponding to the gateway, release the server-level lock.

[0026] Optionally, the flow control rule loading and parsing module is also used to: after synchronizing the flow control rule array from the first position to the second position, in response to the flow control rule array being set with a cache code at the first position, use the cache code of the flow control rule array at the first position as the cache code of the flow control rule array at the second position; wherein the first position is one of a remote database, a remote cache and a server-level cache, the second position is one of a remote cache, a server-level cache and a memory, the level of the first position is smaller than the level of the second position, and the levels of the first position and the second position are adjacent; in response to the flow control rule array not being set with a cache code at the first position, based on the cache code setting rule at the second position, set a cache code for the flow control rule array at the second position; and set the expiration time of the flow control rule array at the second position to the expiration time pre-configured at the second position.

[0027] To achieve the above objective, according to another aspect of an embodiment of the present invention, a flow control processing electronic device is provided.

[0028] The electronic device of an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement any of the above-mentioned flow control processing methods.

[0029] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned flow control processing methods is implemented.

[0030] To achieve the above object, according to another aspect of an embodiment of the present invention, a computer program product is provided. A computer program product of an embodiment of the present invention includes a computer program, and when the program is executed by a processor, the flow control processing method provided by the embodiment of the present invention is implemented.

[0031] According to the scheme provided by the present invention, one embodiment of the above invention has the following advantages or beneficial effects: after the gateway receives the call request, it filters and identifies the traffic through the flow control rule array. The traffic that does not comply with the rules can be directly forwarded to the upstream service, and the traffic that complies with the rules continues to be filtered using the flow control field in the flow control rules. The traffic that does not exceed the set flow control threshold will also be forwarded to the upstream service, thereby achieving accurate flow control of finer-grained business dimensions, solving the problem that the existing method easily limits normal traffic, and can meet the needs of various complex business scenarios.

[0032] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0034] Figure 1 This is a schematic diagram of the existing single-dimensional flow control;

[0035] Figure 2 A schematic diagram of the main flow of a flow control processing method according to an embodiment of the present invention;

[0036] Figure 3 is a flow chart of an optional flow control processing method according to an embodiment of the present invention;

[0037] Figure 4 (a) is a schematic diagram of the flow control rule maintenance interface;

[0038] Figure 4 (b) is a schematic diagram of the flow control rule configuration interface;

[0039] Figure 4 (c) is a schematic diagram of the judgment expression configuration interface;

[0040] Figure 4 (d) is a schematic diagram of the flow control field configuration interface;

[0041] Figure 5 is a flow chart of another optional flow control processing method according to an embodiment of the present invention;

[0042] Figure 6 This is a schematic diagram of flow control rule loading and parsing;

[0043] Figure 7 is a flow chart of another optional flow control processing method according to an embodiment of the present invention;

[0044] Figure 8 (a) is a schematic diagram of the type attribute maintenance interface;

[0045] Figure 8 (b) is a schematic diagram of the type data maintenance interface;

[0046] FIG9 (a) is a flow chart of a specific flow control processing method according to an embodiment of the present invention;

[0047] Figure 9 (b) is a schematic diagram of the specific process of executing the rules;

[0048] Fig.10 is a schematic diagram of main modules of a flow control processing device according to an embodiment of the present invention;

[0049] Fig.11 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0050] Fig.12 It is a schematic diagram of the structure of a computer system of a mobile device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0051] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0052] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.

[0053] The API gateway can be placed between two systems, or between the client and the server. As the only entrance to the system, all requests entering the system must pass through the API gateway. Currently, most API gateways on the market can limit the flow of a certain request attribute of a certain API. The gateway can select parameter attributes of the following dimensions for flow control:

[0054] Client IP: The IP address of the requesting party (full name: Internet Protocol Address);

[0055] Remote Host: Host Header of the requesting end;

[0056] Header: Parse according to the specified HTTP Header and match the corresponding Header Key. After selecting Header, you can configure the matching strategy of the request attribute value. Only the request attribute values ​​that match the pattern will be included in the statistics and flow control;

[0057] URL (Uniform Resource Locator) parameter: Parse according to the specified HTTP URL parameter, and fill in the corresponding parameter name. After selecting the URL parameter, you can configure the matching strategy of the request attribute value. Only the request attribute values ​​that match the pattern will be included in the statistics and flow control;

[0058] After selecting the above parameter dimensions, the API gateway can set the current limiting threshold control for this dimension, such as current limiting at intervals of seconds, minutes, hours, etc.

[0059] Existing technologies can perform flow control on single dimensions such as client IP, request host, request header, and request parameters. Most of them are as follows: Figure 1 The problems with this method are as follows:

[0060] 1) The granularity of flow control is relatively coarse. For example, flow control can only be performed based on a single dimension, which can easily lead to accidental damage to normal traffic. For example, when flow control is performed based on the client IP dimension, all IPs will be controlled according to the same threshold. However, it is normal for some IPs to have large traffic, while it is abnormal for some IPs to have large traffic. For example, it is normal for some large customers' calling IPs to have large business volumes and large traffic. However, for some small and medium-sized customers whose business volumes are not large, it may not be normal for their calling IPs to have large traffic. In this way, it is very difficult to set a reasonable flow control threshold in the IP dimension;

[0061] 2) The flow control dimension does not support the business message dimension. It can only match based on dimensions such as client IP or request header, and cannot match on more fine-grained business message attribute dimensions, making it difficult to accurately control according to business scenarios. For example, in the request message of the same API, a certain field A represents a certain type of business. The traffic that the downstream service can withstand for this type of business is different from that for other businesses. It cannot support flow control for only this type of business;

[0062] 3) It does not support accurate identification of business traffic and differentiated flow control. The above traditional flow control technology only sets the flow limit threshold based on a single dimension each time it limits the flow. In daily operations, problematic traffic often requires a multi-dimensional combination to distinguish abnormal traffic, and it is necessary to combine multi-dimensional business elements at the same time before limiting the flow. For example, there are similar scenarios in daily operations: it is necessary to identify the traffic of a specific user and limit the flow only for this user; in addition, there is also a need to perform level-by-level flow control on the calling user, such as for the same interface, the traffic limit QPS for large merchants is 10,000, and the traffic limit QPS for small and medium-sized merchants is set to 1,000, etc.; and these numerous actual scenarios will have great difficulties using the above traditional flow control technology.

[0063] See also Figure 2 , which shows a main flow chart of a flow control processing method provided by an embodiment of the present invention, includes the following steps:

[0064] S201: receiving a call request to a gateway, and obtaining a flow control rule array corresponding to the gateway; wherein the flow control rule array is obtained by arranging the flow control rules in a configuration order;

[0065] S202: Determine the current flow control rule in the flow control rule array in order, and if the previous flow control rule does not trigger flow control, determine the data source according to the current flow control rule, and perform the logical operation in the current flow control rule on the data under the data source to obtain the logical operation result;

[0066] S203: In response to the logic operation result meeting the preset requirement, verify whether the length of the data is less than or equal to the length pre-configured in the current flow control rule, perform splicing processing on the data whose verification result is less than or equal to, obtain the flow control key name, and determine the time period for setting the flow control threshold in the current flow control rule;

[0067] S204: Count the number of requests that call the gateway in the current time period and whose processing results are the flow control key name. If the number of requests is greater than the flow control threshold corresponding to the flow control key name, perform flow control processing on the call request.

[0068] In the above implementation, for steps S201 to S204, when the API gateway is running, it is mainly used to process the client's call request in real time. After receiving the call request, the gateway screens and identifies the traffic. Traffic that does not meet the rule characteristics can be directly forwarded upstream, and traffic that meets the rules enters the combined flow control of multiple business dimensions. Traffic that does not exceed the set flow control threshold will also be forwarded to the upstream service. The execution process is as follows:

[0069] 1. The API gateway receives multiple call requests, obtains the flow control rule array corresponding to the API gateway from the local cache, and takes out the first flow control rule from the flow control rule array, assuming it is rule 1. That is, it is executed in the order stored in the flow control rule array (that is, the order in which the user configures the flow control rules). If the previous rule triggers flow control, the subsequent rules do not need to be executed.

[0070] 2. See follow-up Figure 3 As shown in the description, each flow control rule includes a judgment expression, a multi-dimensional combination rule of flow control fields, and a flow control threshold. First, execute each expression in the IF condition in rule 1 in turn: obtain the two comparison data sources of the expression, obtain the data to be compared based on the data source, perform logical operations such as > and <, and obtain the calculated true / false value.

[0071] The data source can be obtained from the request header, parameters, etc., or from the fields in the request message, or from the remote API; when obtaining data from the remote API, local cache processing can be performed as needed to improve performance. Some data may need to be obtained from a certain business type, such as the business type shown in the subsequent Figure 4 (c), which can be obtained through the public BaseInfoDTOfindByTypeCode(Long typeId,String code) method.

[0072] Specifically, a call query request for data under a certain business type is received, and the data code marked as enabled under the business type is queried. The data query uses Redis cache: query whether there is data corresponding to these data codes from Redis. If so, return these data to the gateway API. Otherwise, query the database. If the database exists, the database returns the data to Redis and sets an expiration time (or valid time, which can be customized) to return the data from Redis. If it does not exist, a null value is returned through Redis. At the same time, to avoid cache breakdown, null values ​​are cached for a short period of time, and the null value expiration time is short.

[0073] 3. Calculate the operation result of each judgment expression based on step 2, perform AND or OR operations on the operation result of each judgment expression, and obtain the overall true or false result of the expression, that is, the logical operation result. Multi-conditional relationships are usually set to AND or OR, so the operation result of each judgment expression is ANDed or ORed. If the logical operation result is true, execute the THEN multi-business dimension combined flow control step 4; if it is a false value, jump to step 2 to execute the next rule, such as Rule 2 after Rule 1.

[0074] 4. When the result of the logical operation is true, determine the multi-dimensional combination rule of the flow control field in the flow control rule, obtain data according to the data source and field name set in the rule, such as ABC, and then use the maximum length set for each field name to verify whether the length of the corresponding data meets the rule requirements. Assume that it is set to 20, but the length of data A is 21, then data A is intercepted; for data that meets the requirements, no interception is performed.

[0075] 5. For the data that meets the requirements, perform splicing processing, such as BC above, to obtain the flow control key name Key. The method of obtaining the source of each segment data in Key is consistent with step 2. Determine the time period for setting the flow control threshold in the current flow control rule, assuming it is per second, and count the number of requests that call the API gateway and the processing result is BC in the current time period. Assuming that the number of requests with the same flow control key name Key-BC within 1 second is 5 times, the statistical method can be accumulated using local memory or remote redis.

[0076] 6. Find the flow control threshold corresponding to the flow control key-BC from the remote Redis. Assume it is 10 times. Since 5<10, it means that the flow control is not triggered. Then add 5 to the counter of the remote Redis flow control key and repeat step 2 to execute the next flow control rule 2. If all flow control rules do not trigger flow control, the call request traffic will be transferred to the upstream service.

[0077] However, if the threshold is exceeded, flow control is performed, such as directly intercepting the flow or marking the flow. It should be noted that the number of requests is counted in real time. Taking the above 10 times as an example, if the flow control Key of the 11th call request is BC, it will be automatically intercepted. At this time, the value of the remote Redis counter remains unchanged and no accumulation is performed.

[0078] The method provided in the above embodiment sets a flow control rule array to determine the current flow control rule, filters data according to logical operations and data length checks, and dynamically adjusts the flow control capability by comparing the number of requests in the time period for setting the flow control threshold with the flow control threshold. This method can achieve accurate flow control for more fine-grained business dimensions, provide overload protection, enhance the security and maintainability of the system, and solve the problem that the existing method easily limits normal traffic.

[0079] See also Figure 3 , shows a schematic flow chart of an optional flow control processing method according to an embodiment of the present invention, comprising the following steps:

[0080] S301: receiving a gateway interface group selected in the flow control rule maintenance interface;

[0081] S302: In response to a selection operation on a flow control rule configuration in a flow control rule maintenance interface, a flow control rule configuration interface is displayed, and one or more determination expressions and multi-conditional relationships configured in the flow control rule configuration interface are received;

[0082] S303: In response to the selection operation of the flow control field configuration in the flow control rule configuration interface, the flow control field configuration interface is displayed, one or more data sources selected in the flow control field configuration interface are received, and the field name, data source, and maximum length configured for each data source are received, and a multi-dimensional combination rule of the flow control field is generated;

[0083] S304: receiving the flow control threshold configured in the flow control rule configuration interface;

[0084] S305: Generate flow control rules based on one or more judgment expressions and multi-condition relationships, multi-dimensional combination rules of flow control fields, and flow control thresholds, and then generate a flow control rule array corresponding to the gateway interface grouping according to the generation order of the flow control rules.

[0085] In the above implementation, for step S301, before the implementation of the entire solution, it is necessary to configure traffic control rules (i.e., flow control rules), which is implemented by the flow control rule maintenance module. The flow control rule maintenance module is used to maintain flow control-related rules for API or API grouping dimensions.

[0086] See Figure 4 (a), which is a schematic diagram of the flow control rule maintenance interface. Flow control rules can be configured for API or service domain (API group) dimensions. The service domain option is set in the interface. Users can click the box to select a specific service domain. One service domain corresponds to one API group, which is selected through the API option in the interface. The interface also sets the "Enable" option. If this option is not checked, it means that the flow control rule array set for the service domain is not enabled. If this option is checked, it means that the flow control rule array needs to be enabled.

[0087] Multiple flow control rules can be set in the interface, and the default rule can also be set. You can also not configure it. The default rule will be executed when no rule is matched. When maintaining rules, it supports maintaining multiple rules at the same time. Each rule can set different flow control thresholds. The system will match the rules in the configuration order. Click the flow control rule configuration option in the flow control rule maintenance interface of Figure 4 (a) to display the interface shown in Figure 4 (b).

[0088] For step S302, see FIG4 (b), which is a schematic diagram of the flow control rule configuration interface. One or more flow control rules can be set in the interface. Each flow control rule includes three parts: judgment expression and multi-condition relationship, flow control field configuration, and threshold configuration. For judgment expression and multi-condition relationship, you can click the new condition after the multi-condition relationship in the interface to display the judgment expression configuration interface shown in FIG4 (c), so as to receive the user to set a multi-condition and or relationship compound expression in the interface to achieve accurate filtering of traffic. Among them, the data type preferably supports three types: string, number, and Boolean. Expressions support: greater than, less than, not equal to, interval value, existence, non-existence, etc. Expression calculations, and complex logical calculations of and or relationships are supported between multiple expressions.

[0089] The comparison data source of the judgment expression supports the following acquisition methods: 1) HTTP request header: obtained from the client request header; 2) HTTP request parameters: obtained from the client request parameters; 3) HTTP request cookies: obtained from the client request cookies; 4) Fixed constants: support configuration of fixed values, such as strings, numbers, Boolean values, etc.; 5) System variables: system built-in variables, implemented by the system internal coding; when the configuration needs to use the variable, it will be parsed in real time and temporarily stored in the thread context for user use. Such as client IP, a field in the request message, etc.; 6) Function call: support calling remote API for data acquisition, such as calling pre-configured type data API (see the subsequent Figure 7 As shown in the description), the parameter value source of the API call can be obtained from the above HTTP request header, parameters, etc. and passed to the remote API.

[0090] Taking the example in the judgment expression configuration interface shown in Figure 4 (c) as an example, it means that only traffic that meets three conditions at the same time can be filtered out, namely: 1) traffic with the system variable name clientIp (referring to the client IP) equal to 192.168.0.111; 2) traffic with the bizType (i.e. business type) field value of the HTTP request header being 1; 3) getting the source value from the source (i.e. source) field of the HTTP request header (assuming the value is "Xicheng Site"), calling the business type query function, and searching for "Xicheng Site" from the "Weighing Reporting High Frequency Site" type. If not found (is null), it means that this condition is met.

[0091] For step S303, for the judgment expression and multi-condition relationship, you can click the flow control field configuration option in the flow control rule configuration interface shown in Figure 4 (b) to display the flow control field configuration interface shown in Figure 4 (d). The user can set one or more data sources (i.e., input parameter sources), field names, data types, and maximum lengths in the flow control field configuration interface.

[0092] The flow control field supports user self-configuration and combination. The system will obtain data according to the configured data acquisition rules and splice it into a combined flow control Key to determine whether the number of the Key within a certain period of time reaches the flow control threshold, thereby supporting users to perform multi-dimensional fine-grained business flow control. Taking the fields clientIp, bizType, and source shown in the figure as an example, the flow control Key is controlled through multiple dimensions: clientIp+bizType+source, which controls the flow control for the same IP, the same business type, and the same business channel, and sets the flow control threshold.

[0093] For steps S304 and S305, according to the schematic diagram of the flow control rule configuration interface shown in Figure 4 (b), it can be seen that each flow control rule needs to configure a threshold, which can be a threshold in four dimensions: per second threshold, per minute threshold, per hour threshold, and per day threshold, or just one of the dimensions. There is no restriction here, and the user can adaptively select the setting according to their needs.

[0094] According to the judgment expression and multi-conditional relationship generated above, the multi-dimensional combination rules of the flow control field, and the flow control threshold, a flow control rule is generated by combining, as shown in Rule 1 in Figure 4 (a). In fact, multiple flow control rules can be set in the same way as described above, as shown in Rule 2 in Figure 4 (a). Finally, the flow control rules are combined in order according to the generation order to generate a flow control rule array corresponding to the API group. In fact, a whitelist for the API group can also be set. This is a prior art and is not described in detail in this solution.

[0095] The flow control rule array generated for the API group through the above process will be stored in a remote database, such as MySQL, in JSON format. When the API call is run, the flow control rule array can be loaded from the remote database to the local cache and parsed and executed. However, when a rule in the monitoring changes, the rule in the local cache needs to be deleted in real time. When the traffic is triggered, the cache is reloaded and takes effect. Among them, the API gateway is generally divided into management state and runtime state. The runtime is generally an application that resists traffic.

[0096] In the method provided in the above embodiment, the flow control rule maintenance module is used to maintain flow control-related rules for API or API grouping dimensions, so as to realize the customization of flow control rules, data sources, fields, etc., so as to facilitate the subsequent realization of precise business flow control for complex business dimensions.

[0097] See also Figure 5 , shows a schematic flow chart of another optional flow control processing method according to an embodiment of the present invention, comprising the following steps:

[0098] S501: In response to monitoring that a gateway is called, querying from the memory of the local process whether there is a flow control rule array corresponding to the gateway;

[0099] S502: If the query is true, return the flow control rule array to the gateway;

[0100] S503: If the query result is that it does not exist, it is determined that this is the first call, and whether there is a flow control rule array corresponding to the gateway from the server-level cache service;

[0101] S504: If the query result is that it exists, the flow control rule array is synchronized to the memory, so as to return the flow control rule array to the gateway through the memory;

[0102] S505: If the query result is that it does not exist, obtain the server-level lock and query from the remote cache whether there is a flow control rule array corresponding to the gateway;

[0103] S506: If the query result is that the flow control rule array exists, synchronize the flow control rule array to the server-level cache service, and release the server-level lock, so as to synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory;

[0104] S507: When the query result is non-existent, query the flow control rule array corresponding to the gateway from the remote database, synchronize the flow control rule array to the remote cache, synchronize the flow control rule array to the cache service through the remote cache, release the server-level lock, and then synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory.

[0105] In the above implementation, for steps S501 to S507, this implementation mainly describes how to obtain the corresponding flow control rule array and load it into the local cache when the API is called. The API gateway in this solution is implemented using the industry-popular OpenResty (i.e., open source software) + Lua (a lightweight scripting language) technology stack. The rule cache is implemented in a multi-level cache manner. The rule content is loaded into the process memory step by step in each level of storage, ensuring high performance and high availability. The loading process is described in detail in the following sections. Figure 6 As shown, among them: 4 levels - local process memory level, 3 levels - server machine level, 2 levels - remote cache level such as Redis, 1 level - remote database level:

[0106] 1. When listening to the API being called, first query whether there is a flow control rule array corresponding to the API gateway from the memory LocalObjCache of the level 4 local process. If the query exists, the flow control rule array is directly returned to the API.

[0107] 2. If it does not exist, it means that this is the first call. Check whether there is a flow control rule array corresponding to the API gateway from the cache service ngx.shared.DICT at the level 3 server. If it exists, transfer the flow control rule array to the level 4 memory for caching, and then return the flow control rule array to the API gateway through the level 4 memory.

[0108] It should be noted that each level of cache is set with a cache coding key, but only one cache coding key is set for the flow control rule array of the same API. Therefore, when storing the flow control rule array in level 3 in level 4 memory, the cache coding key of the flow control rule array in level 3 needs to be used as its cache coding in level 4 memory. Each level of cache can also be set with an expiration time (or called valid time, the size can be customized), and the expiration time of different levels can be different. Therefore, when storing the flow control rule array in level 3 in level 4 memory, it is necessary to update the expiration time of the flow control rule array based on the expiration time pre-set in level 4 memory. The same is true for setting expiration times for levels 3 and 2, and will not be repeated later.

[0109] 3. If the query does not exist in the flow control rule array corresponding to the API gateway in the 3rd-level server-level cache service ngx.shared.DICT, a server-level lock is required. The 3rd-level cache is a server-level shared cache, shared by multiple processes on the server; if there is no server-level lock, a large amount of concurrent traffic may directly penetrate the 2nd-level remote Redis and the 1st-level remote database when the concurrency is large, which may cause the database to crash. Therefore, when the query result does not exist, a server-level lock is required.

[0110] Assume that 8 call requests are received at the same time. For one of the requests, such as the first call request, assuming that the server-level lock is obtained first, then when the local query does not contain the flow control rule array key corresponding to the API gateway, it is necessary to obtain the flow control rule array from the 2nd-level remote cache. If the flow control rule array exists in the 2nd-level remote Redis, when synchronizing the flow control rule array from the 2nd-level remote Redis to the 3rd-level server-level cache service, it is necessary to set the cache encoding key of the flow control rule array in the 2nd-level remote Redis to its cache encoding key at the 3rd level. After that, the server-level lock is released, and the flow control rule array is synchronized to the 4th-level memory through the 3rd-level cache service, and then the flow control rule data is returned to the API gateway through the 4th-level memory.

[0111] For the second call request after the first call request, since it is the second one to obtain the server-level lock, the first call request before it has obtained the flow control rule array through the above operation, and synchronized it to the 3rd-level server-level cache for storage, and set the key, validity period, etc. Therefore, for the second call request, the flow control rule array cache encoding key corresponding to the API gateway can be queried in the 3rd-level cache service, so there is no need to obtain the flow control rule array from the 2nd-level remote Redis, and the server-level lock can be released directly. However, it should be noted that these 8 call requests here are concurrent calls to the API, and initially the flow control rule array corresponding to the API gateway was not queried in the 3rd-level cache service.

[0112] 4. Step 3 describes the situation where the flow control rule array corresponding to the API gateway exists in the level 2 remote Redis. Here, the situation where it does not exist is described. For the situation where it does not exist, the level 2 cache needs to search from the level 1 remote database. If the flow control rule array corresponding to the API gateway exists in the level 1 remote database, the flow control rule array is synchronized from the level 1 remote database to the level 2 remote Redis. Since the level 1 remote database does not set the cache coding key for the flow control rule array, it is necessary to set it according to the setting rules at level 2, and then synchronize it to levels 3 and 4 through the cache coding key set at level 2. Finally, the flow control rule array is returned to the API gateway by the level 4 memory. Similarly, at levels 2, 3, and 4, the expiration time of the flow control rule array needs to be updated according to the pre-configured expiration time at each level. The expiration times of different levels can be different or the same, and there is no restriction here. Each level of cache needs to set an expiration time, not just the higher level. The level 1 remote database does not need to set an expiration time.

[0113] However, if the flow control rule array corresponding to the API gateway does not exist in the level 1 remote database, in order to avoid cache breakdown, a null value needs to be returned, and then returned to the API gateway one by one through levels 2, 3, and 4. In this process, the cache encoding key can be set for the null value without setting it, or NULL can be set to indicate that the flow control rule array does not exist for the API. Similarly, the null value can be cached for a short period of time, so its validity period is shorter.

[0114] Through the above steps, the flow control rules corresponding to the API gateway are loaded through caches at all levels to generate process-level objects, and the JSON configuration string is serialized into a Lua Table data structure in memory for storage. The composition of the rules is as follows: Multiple rules are stored in array form.

[0115] The method provided in the above embodiment sets up a multi-level cache mechanism. The rule cache is returned to the gateway one by one using a multi-level cache. The rule content is loaded into the process memory step by step in each level of storage, and the cache encoding and validity period are set to ensure high performance and high availability.

[0116] See also Figure 7 , shows a schematic flow chart of another optional flow control processing method according to an embodiment of the present invention, comprising the following steps:

[0117] S701: In response to the operation of adding a new business type name in the business type attribute maintenance interface, a primary key is allocated to the newly added business type name to establish a corresponding relationship between the primary key and the business type name, and the corresponding relationship is stored in the storage structure of the business type attribute;

[0118] S702: In response to a business type primary key selected in the business type data maintenance interface, receiving a data code input for the selected business type primary key, so as to allocate basic data corresponding to the data code to the selected business type primary key;

[0119] S703: In response to the selection operation of one or more basic data under one or more business type primary keys in the basic data management interface, batch enable or disable operations are performed on the selected basic data, and the business type primary key, data code, enable or disable are stored in the storage structure of the business type data.

[0120] In the above implementation, for steps S701~S703, before the implementation of the entire solution, it is necessary to configure the business type and basic data. This part is mainly maintained through the type and data maintenance module. The type and data maintenance module is used for rule matching data maintenance, such as batch maintenance of business data such as sites, customer IPs, business sources, etc. used for matching, and maintenance of type matching data, such as supporting list-type matching modes. It mainly includes two sub-modules: type attribute maintenance module and type data maintenance module.

[0121] See Figure 8 (a), which is the type attribute maintenance interface. By selecting a business group and entering a business name, a business type is added to maintain the business type name and its primary key. The type attribute maintenance module is mainly used to maintain the type of business. For example, if some businesses are matched based on the client IP, an IP type can be maintained; if some businesses are matched using the client's application appKey, the application type can be maintained. Other auxiliary fields such as permission management that are not closely related to the main function are not involved in this solution and are not described in detail here.

[0122] The type data maintenance module is mainly used to maintain specific business data for a specified business type, which will be used for specific list rule matching. See Figure 8 (b) for the business type data maintenance interface. The staff clicks on the business type in the interface to select a business ID and enters the data code in the value position to assign the data corresponding to the data code to the business type primary key.

[0123] For the "Enable" option above, you can select data under multiple business types in batches on the basic data management interface to implement batch deletion, batch activation, and batch disabling operations. After the operation is completed, the cache is deleted, and the cache data is reloaded to take effect when it is actually matched. For disabled data, it means that there is no such data under the business type, or the data is unavailable; for enabled data, it means that the data is available under the business type.

[0124] The method provided in the above embodiment sets a maintenance mechanism for business types and basic data, so as to facilitate subsequent business personnel to control the basic data and business types.

[0125] 9( a ) shows a flow chart of a specific flow control processing method according to an embodiment of the present invention, which includes the following steps.

[0126] 1. First, set the business type and basic data under the business type. This operation is implemented through the type and data maintenance module. Through the flow control rule maintenance module, set the flow control rule array corresponding to the API group. Each flow control rule includes one or more judgment expressions and multi-conditional relationships, multi-dimensional combination rules of flow control fields, and flow control thresholds. The multi-dimensional combination rules of flow control fields include data sources, field names, and pre-configured maximum lengths. Store these rules and business type data, usually in remote databases and remote caches.

[0127] 2. The API gateway receives the call request transmitted by the client. If there is no corresponding flow control rule array in the memory of the local process, it determines that this is the first call after the flow control rules are set. First, the first rule in the flow control rule array is determined, assuming it is rule 1.

[0128] 3. Perform logical processing according to one or more judgment expressions and multi-conditional relationships set in flow control rule 1. For the OR situation, the diagram of AND+OR situation is more complicated, so only the AND situation is shown in the figure.

[0129] 4. When the logical operation results of the judgment expression are all true, the overall operation result is also true. If one of them is false, the overall result is also false, and it is necessary to jump to step 3 to execute the next rule, such as Rule 2 after Rule 1.

[0130] 5. If the overall operation result is true, continue to execute the multi-flow control field multi-dimensional combination rule in rule 1 to verify whether the length of the data is less than or equal to the pre-configured length in the multi-flow control field multi-dimensional combination rule. For the data that meets the verification requirements, splicing is performed to obtain the flow control key.

[0131] 6. Count the number of requests that call the API gateway in the current time period and whose processing results are the flow control key. If the number of requests is greater than the flow control threshold corresponding to the flow control key, perform flow control on the call request.

[0132] 7. When the number of requests is less than or equal to the flow control threshold corresponding to the flow control key, that is, it does not meet the rule, the flow control operation is not triggered, and jump to step 3 to execute the next rule, such as rule 2 after rule 1, as shown in Figure 9 (b).

[0133] 8. Execute each rule through the above steps. If none of the rules triggers flow control, the call request is forwarded to the upstream system for processing.

[0134] The embodiment of the present invention provides a precise flow control method, which establishes a flow filtering and identification mechanism for highly complex scenarios for API flow, and can achieve the purpose of precise business flow control for complex business dimensions, solving the problem that normal flow is easily killed by mistake in the existing method:

[0135] 1) Supports multiple data sources, including acquisition from HTTP request headers, parameters, remote APIs, and system built-in variables, including matching control by maintaining type business data;

[0136] 2) Set judgment expressions to perform complex logical operations on data from multiple data sources to achieve accurate traffic filtering; at the same time, it supports users to customize multi-condition compound logical calculations to meet the needs of various complex business scenarios;

[0137] 3) Supports customized splicing and assembly of flow control statistics keys, and each spliced ​​segment allows users to obtain it from different business data sources, so that users can perform precise flow control for more fine-grained business dimensions.

[0138] See also Fig.10 , shows a schematic diagram of the main modules of a flow control processing device 1000 provided by an embodiment of the present invention, including: a receiving module 1001, used to receive a call request to a gateway, and obtain a flow control rule array corresponding to the gateway; wherein the flow control rule array is obtained by arranging the flow control rules in a configuration order; a flow control processing module 1002, used to sequentially determine the current flow control rule in the flow control rule array, and when the previous flow control rule does not trigger flow control, determine the data source according to the current flow control rule, perform the logical operation in the current flow control rule on the data under the data source, and obtain the logical operation result; in response to the logical operation result meeting the preset requirement, verify whether the length of the data is less than or equal to the pre-configured length in the current flow control rule, perform splicing processing on the data with the verification result being less than or equal to, obtain the flow control key name, and determine the time period for setting the flow control threshold in the current flow control rule; count the number of requests that call the gateway in the current time period and whose processing result is the flow control key name, and when the number of requests is greater than the flow control threshold corresponding to the flow control key name, perform flow control processing on the call request.

[0139] In the implementation device of the present invention, the current flow control rule includes one or more judgment expressions and multi-conditional relationships; the flow control processing module 1002 is used to: obtain the data to be compared according to the data source in each judgment expression, and then perform logical operations on the data to be compared according to the judgment expression to obtain the operation result; according to the multi-conditional relationship, perform AND or OR operations on the operation results of one or more judgment expressions to obtain the logical operation result of the current flow control rule.

[0140] In the implementation device of the present invention, the flow control rules include multi-dimensional combination rules of flow control fields, and the multi-dimensional combination rules of flow control fields include data source, field name, and pre-configured maximum length; the flow control processing module 1002 is used to: when the result of the logical operation is true, obtain the corresponding data according to the data source and field name; determine the maximum length corresponding to the data source and field name, check whether the length of each data obtained is less than or equal to the maximum length, and intercept the data whose verification result is greater than.

[0141] In the implementation device of the present invention, the flow control processing module 1002 is also used to: receive a gateway interface group selected in the flow control rule maintenance interface; in response to the selection operation of the flow control rule configuration in the flow control rule maintenance interface, display the flow control rule configuration interface, and receive one or more judgment expressions and multi-conditional relationships configured in the flow control rule configuration interface; in response to the selection operation of the flow control field configuration in the flow control rule configuration interface, display the flow control field configuration interface, receive one or more data sources selected in the flow control field configuration interface, and the field name, data source, and maximum length configured for each data source, and generate a multi-dimensional combination rule for the flow control field; receive the flow control threshold configured in the flow control rule configuration interface; generate flow control rules based on one or more judgment expressions and multi-conditional relationships, multi-dimensional combination rules for flow control fields, and flow control thresholds, and then generate a flow control rule array corresponding to the gateway interface group in the order in which the flow control rules are generated.

[0142] In the implementation device of the present invention, the determination expression is composed of one or more of the data type, data source, data field, calling method, business type, basic data source, and field name.

[0143] The implementation device of the present invention also includes a type and data maintenance module, which is used to: in response to the operation of adding a new business type name in the business type attribute maintenance interface, assign a primary key to the newly added business type name to establish a correspondence between the primary key and the business type name, and store the correspondence in the storage structure of the business type attribute; in response to the business type primary key selected in the business type data maintenance interface, receive the data code input for the selected business type primary key to assign the basic data corresponding to the data code to the selected business type primary key; in response to the selection operation of one or more basic data under one or more business type primary keys in the basic data management interface, perform batch enable or disable operations on the selected basic data, and store the business type primary key, data code, enable or disable in the storage structure of the business type data.

[0144] In the implementation device of the present invention, the flow control processing module 1002 is also used for: in response to the existence of a business type in the judgment expression, determining the corresponding business type primary key according to the name of the business type, and querying the data encoding corresponding to the business type primary key and marked as enabled; in response to the existence of data corresponding to the data encoding in the cache, returning the data to the gateway; in response to the absence of data corresponding to the data encoding in the cache, if there is data corresponding to the data encoding in the database, returning the data to the cache, so as to return the data to the gateway through the cache, and if there is no data corresponding to the data encoding in the database, returning a null value to the cache, so as to return the null value to the gateway through the cache.

[0145] The implementation device of the present invention also includes a flow control rule loading and parsing module, which is used to: in response to monitoring the gateway being called, query whether there is a flow control rule array corresponding to the gateway from the memory of the local process; if the query is that it exists, return the flow control rule array to the gateway; if the query result is that it does not exist, it is determined that this is the first call, and query whether there is a flow control rule array corresponding to the gateway from the server-level cache service, and obtain the flow control rule array using a processing method corresponding to the query result and return it to the gateway.

[0146] In the implementation device of the present invention, the flow control rule loading and parsing module is used to: if the query result is existence, synchronize the flow control rule array to the memory, so as to return the flow control rule array to the gateway through the memory; if the query result is non-existence, obtain the server-level lock, and query from the remote cache whether there is a flow control rule array corresponding to the gateway; if the query result is existence, synchronize the flow control rule array to the server-level cache service, and release the server-level lock, so as to synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory; if the query result is non-existence, query the flow control rule array corresponding to the gateway from the remote database, synchronize the flow control rule array to the remote cache, so as to synchronize the flow control rule array to the cache service through the remote cache, release the server-level lock, and then synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory.

[0147] In the implementation device of the present invention, when multiple call requests are received at the same time, the flow control rule loading and parsing module is used to: for the first call request that preferentially obtains the server-level lock among the multiple call requests, if the cache service does not have a flow control rule array cache code corresponding to the gateway, query the flow control rule array corresponding to the gateway from the remote cache; after the first call request releases the server-level lock, for the second call request that obtains the server-level lock second among the multiple call requests, if the cache service has a flow control rule array cache code corresponding to the gateway, release the server-level lock.

[0148] In the implementation device of the present invention, the flow control rule loading and parsing module is also used for: after synchronizing the flow control rule array from the first position to the second position, in response to the flow control rule array being set with a cache code at the first position, using the cache code of the flow control rule array at the first position as the cache code of the flow control rule array at the second position; wherein the first position is one of a remote database, a remote cache and a server-level cache, the second position is one of a remote cache, a server-level cache and a memory, the level of the first position is smaller than the level of the second position, and the levels of the first position and the second position are adjacent; in response to the flow control rule array not being set with a cache code at the first position, setting a cache code for the flow control rule array at the second position based on the cache code setting rule at the second position; and setting the expiration time of the flow control rule array at the second position to the expiration time pre-configured at the second position.

[0149] In addition, the specific implementation content of the device described in the embodiment of the present invention has been described in detail in the method described above, so the repeated content will not be described again here.

[0150] Fig.11 An exemplary system architecture 1100 to which embodiments of the present invention may be applied is shown, including terminal devices 1101 , 1102 , 1103 , a network 1104 , and a server 1105 (only an example).

[0151] Terminal devices 1101, 1102, 1103 can be various electronic devices with display screens and supporting web browsing, and various communication client applications are installed. Users can use terminal devices 1101, 1102, 1103 to interact with server 1105 through network 1104 to receive or send messages, etc.

[0152] The network 1104 is used to provide a medium for communication links between the terminal devices 1101, 1102, 1103 and the server 1105. The network 1104 may include various connection types, such as wired, wireless communication links or optical fiber cables.

[0153] The server 1105 may be a server that provides various services. It should be noted that the method provided in the embodiment of the present invention is generally executed by the server 1105 , and accordingly, the device is generally set in the server 1105 .

[0154] It should be understood that Fig.11 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0155] Reference below Fig.12 , which shows a schematic diagram of the structure of a computer system 1200 of a terminal device suitable for implementing an embodiment of the present invention. Fig.12 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0156] like Fig.12 As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1202 or a program loaded from a storage part 1208 into a random access memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the system 1200 are also stored. The CPU 1201, the ROM 1202, and the RAM 1203 are connected to each other through a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0157] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed, so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0158] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1209, and / or installed from the removable medium 1211. When the computer program is executed by the central processing unit (CPU) 1201, the above-mentioned functions defined in the system of the present invention are executed.

[0159] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0160] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0161] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a receiving module and a flow control processing module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the flow control processing module may also be described as a "current limiting processing module".

[0162] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device executes any of the above flow control processing methods.

[0163] The computer program product of the present invention comprises a computer program, and when the computer program is executed by a processor, the flow control processing method in the embodiment of the present invention is implemented.

[0164] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A flow control processing method, characterized in that: include: Receive a call request to a gateway, and obtain a flow control rule array corresponding to the gateway; wherein the flow control rule array is obtained by arranging the flow control rules in a configuration order; Determine the current flow control rule in the flow control rule array in order, and if the previous flow control rule does not trigger flow control, determine the data source according to the current flow control rule, perform the logical operation in the current flow control rule on the data under the data source, and obtain the logical operation result; In response to the result of the logical operation meeting the preset requirements, whether the length of the data is less than or equal to the pre-configured length in the current flow control rule is verified, and the data whose verification result is less than or equal to is spliced ​​to obtain the flow control key name, and determine the time period for setting the flow control threshold in the current flow control rule; Count the number of requests that call the gateway and whose processing results are the flow control key name in the current time period. If the number of requests is greater than the flow control threshold corresponding to the flow control key name, perform flow control processing on the calling request.

2. The method according to claim 1, characterized in that The current flow control rules include one or more judgment expressions and multiple conditional relationships; The step of determining the data source according to the current flow control rule, performing the logic operation in the current flow control rule on the data under the data source, and obtaining the logic operation result includes: According to the data source in each determination expression, the data to be compared is obtained, and then a logical operation is performed on the data to be compared according to the determination expression to obtain an operation result; According to the multi-condition relationship, an AND or OR operation is performed on the operation results of the one or more determination expressions to obtain the logical operation result of the current flow control rule.

3. The method according to claim 1 or 2, characterized in that: The flow control rules include the multi-dimensional combination rules of the flow control fields, which include the data source, field name, and pre-configured maximum length; In response to the logical operation result meeting the preset requirement, checking whether the length of the data is less than or equal to the length pre-configured in the current flow control rule includes: When the result of the logical operation is true, the corresponding data is obtained according to the data source and field name; Determine the maximum length corresponding to the data source and field name, check whether the length of each acquired data is less than or equal to the maximum length, and intercept the data whose verification result is greater than the maximum length.

4. The method according to claim 3, characterized in that The method further comprises: Receive a gateway interface group selected in the flow control rule maintenance interface; In response to a selection operation on a flow control rule configuration in a flow control rule maintenance interface, a flow control rule configuration interface is displayed, and one or more determination expressions and multi-conditional relationships configured in the flow control rule configuration interface are received; In response to the selection operation of the flow control field configuration in the flow control rule configuration interface, the flow control field configuration interface is displayed, one or more data sources selected in the flow control field configuration interface are received, and the field name, data source, and maximum length configured for each data source are received, and a multi-dimensional combination rule of the flow control field is generated; Receive the flow control threshold configured in the flow control rule configuration interface; Based on one or more judgment expressions and multi-conditional relationships, multi-dimensional combination rules of flow control fields, and flow control thresholds, flow control rules are generated, and then a flow control rule array corresponding to the gateway interface grouping is generated in the order in which the flow control rules are generated.

5. The method according to claim 2, characterized in that: The judgment expression consists of one or more of the data type, data source, data field, calling method, business type, basic data source, and field name.

6. The method according to claim 5, characterized in that The method further comprises: In response to the operation of adding a new business type name in the business type attribute maintenance interface, a primary key is allocated to the newly added business type name to establish a corresponding relationship between the primary key and the business type name, and the corresponding relationship is stored in the storage structure of the business type attribute; In response to a business type primary key selected in the business type data maintenance interface, receiving a data code input for the selected business type primary key to allocate basic data corresponding to the data code to the selected business type primary key; In response to the selection operation of one or more basic data under one or more business type primary keys in the basic data management interface, batch enable or disable operations are performed on the selected basic data, and the business type primary key, data code, enable or disable are stored in the storage structure of the business type data.

7. The method according to claim 6, characterized in that The method further comprises: In response to the existence of a business type in the judgment expression, determining a corresponding business type primary key according to the name of the business type, and querying a data code corresponding to the business type primary key and marked as enabled; In response to the presence of data corresponding to the data encoding in the cache, returning the data to the gateway; In response to the absence of data corresponding to the data encoding in the cache, if data corresponding to the data encoding exists in the database, the data is returned to the cache, so that the data is returned to the gateway through the cache; if data corresponding to the data encoding does not exist in the database, a null value is returned to the cache, so that the null value is returned to the gateway through the cache.

8. The method according to claim 1, characterized in that The obtaining of the flow control rule array corresponding to the gateway includes: In response to monitoring that the gateway is called, querying from the memory of the local process whether there is a flow control rule array corresponding to the gateway, and if the query shows that it exists, returning the flow control rule array to the gateway; If the query result is non-existent, it is determined that this is the first call, and a query is made from the server-level cache service to determine whether there is a flow control rule array corresponding to the gateway. The flow control rule array is obtained using a processing method corresponding to the query result and returned to the gateway.

9. The method according to claim 8, characterized in that The method of obtaining the flow control rule array in a processing manner corresponding to the query result and returning the array to the gateway includes: If the query result is that it exists, the flow control rule array is synchronized to the memory, so as to return the flow control rule array to the gateway through the memory; If the query result is that it does not exist, obtain the server-level lock and query from the remote cache whether there is a flow control rule array corresponding to the gateway; If the query result is that the array of flow control rules exists, the array of flow control rules is synchronized to the server-level cache service, and the server-level lock is released to synchronize the array of flow control rules to the memory through the cache service, and the array of flow control rules is returned to the gateway through the memory; When the query result is non-existent, the flow control rule array corresponding to the gateway is queried from the remote database, and the flow control rule array is synchronized to the remote cache, so as to synchronize the flow control rule array to the cache service through the remote cache, and release the server-level lock, and then synchronize the flow control rule array to the memory through the cache service, and return the flow control rule array to the gateway through the memory.

10. The method according to claim 9, characterized in that In the case where multiple call requests are received at the same time, the acquisition of the server-level lock and querying from the remote cache whether there is a flow control rule array corresponding to the gateway include: For a first call request that preferentially obtains a server-level lock among the multiple call requests, if the cache service does not have a flow control rule array cache code corresponding to the gateway, query the flow control rule array corresponding to the gateway from the remote cache; After the first call request releases the server-level lock, for the second call request that obtains the server-level lock secondly among the multiple call requests, if the cache service has a flow control rule array cache code corresponding to the gateway, the server-level lock is released.

11. The method according to claim 9, characterized in that The method further comprises: After synchronizing the flow control rule array from the first position to the second position, in response to the flow control rule array being provided with a cache code at the first position, the cache code at the first position of the flow control rule array is used as the cache code at the second position of the flow control rule array; wherein the first position is one of a remote database, a remote cache, and a server-level cache, the second position is one of a remote cache, a server-level cache, and a memory, the level of the first position is lower than the level of the second position, and the levels of the first position and the second position are adjacent; In response to the flow control rule array not setting a cache code at the first position, based on the cache code setting rule at the second position, setting a cache code for the flow control rule array at the second position; and The expiration time of the flow control rule array at the second position is set to the pre-configured expiration time at the second position.

12. A flow control processing device, characterized in that: include: A receiving module, used to receive a call request to a gateway, and obtain a flow control rule array corresponding to the gateway; wherein the flow control rule array is obtained by arranging the flow control rules in a configuration order; The flow control processing module is used to determine the current flow control rule in the flow control rule array in order, and when the previous flow control rule does not trigger flow control, determine the data source according to the current flow control rule, perform the logical operation in the current flow control rule on the data under the data source, and obtain the logical operation result; In response to the result of the logical operation meeting the preset requirements, whether the length of the data is less than or equal to the pre-configured length in the current flow control rule is verified, and the data whose verification result is less than or equal to is spliced ​​to obtain the flow control key name, and determine the time period for setting the flow control threshold in the current flow control rule; Count the number of requests that call the gateway and whose processing results are the flow control key name in the current time period. If the number of requests is greater than the flow control threshold corresponding to the flow control key name, perform flow control processing on the calling request.

13. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 11.

14. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.

Citation Information

Cited By

  • API gateway service management method and system and medium

    CN120751000A