Flow control method and device

By receiving business requests from the financial transaction system, determining the business name and selecting the corresponding current limit configuration information, the flow control problem of diversified business scenarios in the financial transaction system is solved, and flexible current limit expansion and adaptability enhancement is achieved.

CN115632993BActive Publication Date: 2025-08-15PINGAN YIQIANBAO E COMMERCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211130956.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-16
Publication Date
2025-08-15
Estimated Expiration
2042-09-16

AI Technical Summary

Technical Problem

The existing technology is difficult to meet the flow control needs of diversified business scenarios in financial transaction systems, and a single flow control method is difficult to expand to adapt to changes in business development.

Method used

By receiving service requests, the service name of the target service request is determined, and the matching target service configuration information is selected from the preset current limit configuration information, including the service type and the corresponding flow control algorithm, so as to realize appropriate current limit processing for different types of service requests.

Benefits of technology

It realizes the flow restriction of business requests in diversified business scenarios, and can flexibly expand the original flow restriction method according to business development, and is suitable for various business types in the financial transaction system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115632993B_ABST
    Figure CN115632993B_ABST
Patent Text Reader

Abstract

The present invention relates to a flow control method and device, wherein the flow control method includes: receiving a service request and determining a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of a file processing result; obtaining a service name corresponding to the target service request; selecting target flow limiting configuration information that matches the service name from preset flow limiting configuration information; wherein the preset flow limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type; and performing flow limiting processing on an interface corresponding to the target service request according to the target flow limiting configuration information. Based on this, it is possible to implement flow limiting for service requests in diversified service scenarios, and the original flow limiting method can be flexibly expanded according to the development of the service.
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 method and device. Background Art

[0002] Financial transaction systems often involve regular transactions, file processing, and notification of transaction results. These notifications require communicating transaction results and file processing instructions to related systems via message queues or API calls. To ensure smooth transactions and system availability, traffic control is essential in these scenarios. However, due to the growth of business scale and the emergence of diverse demands, a single traffic control approach is difficult to meet.

[0003] Therefore, how to limit the flow of business requests in diversified business scenarios and flexibly expand the original flow limiting method according to business development is currently an important research direction. Summary of the Invention

[0004] The present invention provides a flow control method and device to address the defect in the existing technology that a single flow control method is difficult to meet the business scale and diversified needs, realize flow limiting of business requests in diversified business scenarios, and flexibly expand the original flow limiting method according to the development of the business.

[0005] A flow control method, the method comprising: receiving a service request and determining a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of a file processing result; obtaining a service name corresponding to the target service request; selecting target flow limiting configuration information that matches the service name from preset flow limiting configuration information; wherein the preset flow limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type; and performing flow limiting processing on an interface corresponding to the target service request according to the target flow limiting configuration information.

[0006] In one embodiment, selecting target current limiting configuration information that matches the service name from preset current limiting configuration information includes: determining the service type corresponding to the service name based on the preset current limiting configuration information; and determining the flow control algorithm corresponding to the service type based on the service type corresponding to the service name.

[0007] In one embodiment, the determining of the flow control algorithm corresponding to the service type based on the service type corresponding to the service name includes: if the service type corresponding to the service name is the first service type, determining whether the target service request is a concurrent request, and determining the flow control algorithm of the target service request based on the preset flow limiting configuration information; or, if the service type corresponding to the service name is the second service type, determining the flow control algorithm corresponding to the target service request based on the request frequency corresponding to the target service request and the preset flow limiting configuration information; or, if the service type corresponding to the service name is the third service type, determining whether the target service request is batch processed, and determining the flow control algorithm corresponding to the target service request based on the preset flow limiting configuration information corresponding to batch processing and non-batch processing, respectively; or, if the service type corresponding to the service name is the fourth service type, performing asynchronous flow limiting processing on the target service request.

[0008] In one embodiment, the flow control algorithm of the target business request is determined based on the preset flow limiting configuration information, including: if the target business request is determined to be a concurrent request, the first algorithm is determined as the flow control algorithm of the target business request; or, if the target business request is determined to be a non-concurrent request, the second algorithm is determined as the flow control algorithm of the target business request.

[0009] In one of the embodiments, the flow control algorithm corresponding to the target business request is determined based on the request frequency corresponding to the target business request and the preset flow limiting configuration information, including: if it is determined that the request frequency of the target business request is greater than a preset threshold, then the third algorithm is determined as the flow control algorithm of the target business request; or, if it is determined that the request frequency of the target business request is less than or equal to the preset threshold, then the fourth algorithm is determined as the flow control algorithm of the target business request.

[0010] In one embodiment, the determination of whether the target business request is to be batch processed and the determination of the flow control algorithm corresponding to the target business request based on the preset flow limiting configuration information corresponding to batch processing and non-batch processing respectively include: if it is determined that the target business request requires batch processing, then determining the flow control algorithm corresponding to each subtask in the subtasks that require batch processing; or, if it is determined that the target business request does not require batch processing, then determining whether asynchronous flow limiting processing is to be performed, and determining the flow control algorithm of the target request business.

[0011] In one embodiment, the selecting target current limiting configuration information that matches the service name from the preset current limiting configuration information includes: if it is determined to perform asynchronous current limiting processing, determining the current limiting rate based on the number of requests of the target service request within a predetermined time and the preset current limiting configuration corresponding to the target service request; and determining the flow control algorithm of the target service request based on the preset current limiting configuration information; wherein the current limiting rate and the flow control algorithm of the target service request are used to perform current limiting processing on the target service request; if it is determined not to perform asynchronous current limiting processing, determining the flow control algorithm corresponding to each file in the target service request based on the preset current limiting configuration information.

[0012] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the above-mentioned flow control method.

[0013] A storage medium storing computer-readable instructions, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the above-mentioned flow control method.

[0014] The aforementioned flow control method and apparatus, by identifying a target service request and determining the flow control algorithm corresponding to the target service request based on preset flow limiting configuration information, can thereby implement appropriate flow control algorithms for different types of service requests, making the flow control method provided by the present invention applicable to diverse service scenarios. Furthermore, since the flow control algorithm corresponding to the target service request is determined based on the preset flow limiting configuration information, if additional flow limiting methods are desired, they can be directly expanded within the preset flow limiting configuration information, thereby enabling flexible expansion of existing flow limiting methods based on service development. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 Schematic diagram of the flow of the RateLimiter token bucket algorithm in the prior art;

[0016] Figure 2 This is a flow chart of the Redis token bucket algorithm in the prior art;

[0017] Figure 3 A diagram illustrating an implementation environment of a flow control method provided in one embodiment;

[0018] Figure 4 is a block diagram of the internal structure of a computer device in one embodiment;

[0019] Figure 5 FIG1 is a flow chart of a flow control method according to an embodiment;

[0020] Figure 6 FIG2 is a second flow chart of a flow control method according to an embodiment;

[0021] Figure 7 is one of the schematic block diagrams of a flow control method in one embodiment;

[0022] Figure 8 This is a second schematic block diagram of a flow control method in one embodiment;

[0023] Figure 9 A schematic diagram of a current limiting decision configuration table in one embodiment;

[0024] Figure 10 FIG. 1 is a structural block diagram of a flow control device in one embodiment. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0026] It should be noted that, unless otherwise defined, the technical or scientific terms used in the present invention should have the usual meanings understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0027] In order to facilitate understanding, the technical terms involved in the present invention are first explained.

[0028] (1) RateLimiter component

[0029] The token bucket algorithm is used to limit the access rate to some physical or logical resources. Figure 1 As shown. Figure 1As shown in the figure, after receiving a request, if the request is full, the current limit is triggered and the current request is discarded; if the request is not full, the request is added to the queue and waits in line for processing. When a request starts to be processed, a token is taken out from the token bucket, the token in the token bucket is reduced by one, and tokens are continuously placed in the token bucket.

[0030] RateLimiter is based on the token bucket algorithm, which places tokens into the token bucket at a constant rate set by the user. When a user comes to perform a task, they can only execute it if they get a token.

[0031] Understandably, since RateLimiter doesn't generate tokens via a scheduled task, but rather uses a delayed calculation method to continuously generate tokens. That is, when obtaining a token, it calculates the difference between the last time and the current time, and then calculates how many tokens can be produced within that time at the user-set rate. Therefore, it consumes too many resources and is not suitable for high-concurrency requests.

[0032] (2) Redis-based token bucket

[0033] Redis is a non-relational, in-memory database with fast performance. Redis operations naturally support atomicity, making atomic additions ideal for current-limiting business scenarios. You can use Redis's List data structure to acquire and consume tokens.

[0034] The process is similar to RateLimiter, such as Figure 2 As shown in the figure, the Redis-based token bucket stores tokens in the token bucket at a constant rate. In response to a user's request, a token is obtained from the token bucket. If no token is obtained, the current request is discarded; if a token is obtained, the request is processed.

[0035] (3) Aspect-oriented programming (AOP)

[0036] Aspect-Oriented Programming (AOP) is a technology that uses precompilation and runtime dynamic proxies to achieve unified maintenance of program functionality. AOP is a hot topic in software development and a key component of the Spring Framework. It is a derivative of functional programming. AOP can be used to isolate various parts of business logic, reducing coupling between them, improving program reusability, and increasing development efficiency.

[0037] Understandably, the advantage of RateLimiter token bucket limiting is its simplicity, pre-packaged tools, and out-of-the-box functionality. However, it cannot guarantee globally unique tokens in distributed scenarios. The advantage of Redis token bucket limiting lies in Redis's inherent performance advantages (due to the constant rate at which tokens are added to the token bucket) and can also be applied in distributed scenarios, but it requires custom development and is not available out-of-the-box.

[0038] It's also understandable that financial transaction systems often involve regular transactions, file processing, and notification of transaction results. These scenarios require communicating transaction results and file processing instructions to related systems via message queues or interface calls. To ensure the smooth progress of transactions and the availability of business systems, flow control is necessary in these scenarios. Currently, mature flow control technologies include the RateLimiter token bucket flow control tool in Google's Guava package and the token bucket algorithm implemented in Redis. These tools can meet most requirements in relatively simple business scenarios. However, as transaction systems continue to grow, requirements for file processing rates and interface performance are increasingly diversified. Relying solely on a single flow control component to address the growing scale and diverse requirements of business, coupled with the need to constantly adjust the number of flow control tokens as business development evolves, makes scalability difficult from a technical perspective. Therefore, to enable flow control for diverse business requests and flexibly expand existing flow control methods based on business development, the flow control method of the present invention is proposed.

[0039] The following combination Figure 3-10 The flow control method and device of the present invention are described.

[0040] Figure 3 This is a diagram of an implementation environment of a flow control method provided in one embodiment, including a computer device 310 and a terminal device 320.

[0041] The computer device 310 is a device for flow control, which can receive service requests from the terminal device 320 and perform flow control based on the service requests from the terminal device 320. The service requests can be, for example, transaction requests, file processing requests, and transaction result notification requests in a financial transaction system.

[0042] It should be noted that the terminal device 320 and the computer device 310 may be, but are not limited to, a smartphone, a tablet computer, a laptop computer, a desktop computer, etc. The computer device 310 and the terminal device 320 may be connected via Bluetooth, a Universal Serial Bus (USB), or other communication connection methods, and the present invention does not impose any limitation thereto.

[0043] Figure 4 FIG. 1 is a schematic diagram of the internal structure of a computer device in one embodiment. Figure 4 As shown, the computer device includes a processor, a non-volatile storage medium, a memory and a network interface connected via a system bus. The non-volatile storage medium of the computer device stores an operating system, a database and computer-readable instructions. The database may store a control information sequence. When the computer-readable instructions are executed by the processor, the processor may implement a gesture testing method. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor may execute a flow control method. The network interface of the computer device is used to connect and communicate with the terminal. Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0044] like Figure 5 As shown, in one embodiment, a flow control method is proposed, which can be executed by the above-mentioned computer device 310. Specifically, as Figure 5 As shown, the flow control method provided by the present invention may include the following steps:

[0045] Step 510: Receive a service request and determine a target service request from the service request.

[0046] A business request is a request for processing a business. The target business request can be a network service request, a file processing request, or a request for feedback on file processing results. A network service request can be, for example, a regular transaction request. A request for feedback on file processing results can be, for example, a transaction result notification.

[0047] It can be understood that since the business request also includes other requests in addition to network service requests, file processing requests or requests for feedback of file processing results, in order to adopt corresponding current limiting strategies only for network service requests, file processing requests or requests for feedback of file processing results, the AOP aspect management can be used to intercept the network service requests, file processing requests or requests for feedback of file processing results in the business request, and perform current limiting management on these requests.

[0048] Step 520: Obtain the service name corresponding to the target service request.

[0049] It is understood that the service name can be pre-defined. Specifically, the developer can configure the service names corresponding to various service requests in the current limiting decision configuration table. Then, the flow control device can directly obtain the service name corresponding to the service request from the current limiting decision configuration table.

[0050] Step 530: Select target current limiting configuration information that matches the service name from the preset current limiting configuration information.

[0051] The preset current limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type. Each service name corresponds to a service type, and the corresponding flow control algorithm can be determined according to the service type. The service type is the type corresponding to the service request, for example, it can be the first service type, the second service type, the third service type, or the fourth service type. The first service type can be a dubbo service type, the second service type can be a timed scheduling type, the third service type can be a file processing type, and the fourth service type can be an asynchronous processing type.

[0052] Step 540: Perform current limiting processing on the interface corresponding to the target service request according to the target current limiting configuration information.

[0053] It can be understood that, since the target current limiting configuration information includes the flow control algorithm of the target service request, the interface corresponding to the target service request can be current limited according to the target current limiting configuration information.

[0054] The flow control method provided by the present invention determines a target service request and, based on preset flow control configuration information, determines the flow control algorithm corresponding to the target service request. This allows for the use of appropriate flow control algorithms for different types of service requests, making the flow control method provided by the present invention applicable to diverse service scenarios. Furthermore, because the flow control algorithm corresponding to the target service request is determined based on the preset flow control configuration information, if additional flow control methods are desired, they can be directly expanded within the preset flow control configuration information, thereby enabling flexible expansion of existing flow control methods based on service development.

[0055] In one embodiment, Figure 6 As shown, selecting target current limiting configuration information that matches the service name from the preset current limiting configuration information may include the following steps:

[0056] Step 610: Determine the service type corresponding to the service name based on the preset current limiting configuration information.

[0057] As mentioned above, in the preset current limiting configuration information, each service name corresponds to a service type. Therefore, the service type corresponding to the service name can be determined according to the preset current limiting configuration information.

[0058] Step 620: Determine a flow control algorithm corresponding to the service type based on the service type corresponding to the service name.

[0059] As mentioned above, the service type may be one of the first service type, the second service type, the third service type, or the fourth service type. Therefore, accordingly, this step may include:

[0060] If the service type corresponding to the service name is the first service type, determine whether the target service request is a concurrent request, and determine the flow control algorithm of the target service request based on the preset flow limiting configuration information; or, if the service type corresponding to the service name is the second service type, determine the flow control algorithm corresponding to the target service request based on the request frequency corresponding to the target service request and the preset flow limiting configuration information; or, if the service type corresponding to the service name is the third service type, determine whether the target service request is batch processed, and determine the flow control algorithm corresponding to the target service request based on the preset flow limiting configuration information corresponding to batch processing and non-batch processing respectively; or, if the service type corresponding to the service name is the fourth service type, perform asynchronous flow limiting processing on the target service request.

[0061] Among them, the first service type can be a dubbo service type, the second service type can be a timed scheduling type, the third service type can be a file processing type, and the fourth service type can be an asynchronous processing type.

[0062] It is understandable that different flow control methods are applicable to different scenarios. For example, the Redis-based token bucket algorithm is more suitable for high-concurrency requests. Therefore, it is preferred to use the Redis token bucket algorithm to limit the flow of requests with high request frequency and concurrent requests, and use the RateLimiter token bucket algorithm to limit the flow of requests with low request frequency and non-concurrent requests. Therefore, the flow control algorithm corresponding to different business types can be configured in the preset flow limiting configuration information.

[0063] It can also be understood that the service type corresponding to the service request is the third service type, and multiple files in the file processing can be batch processed or each file can be processed individually. Therefore, the preset current limiting configuration information can be used to configure whether the service request of the third service type is batch processed. In addition, because some service requests have their own requirements for timeliness, they can be set to the fourth service type in the preset current limiting configuration information, so that the service request can determine the corresponding asynchronous current limiting solution according to its own needs. The process of asynchronous current limiting can be referred to the relevant description below. For the sake of brevity, it will not be described in detail here.

[0064] In one embodiment, the flow control algorithm of the target business request is determined based on the preset flow limiting configuration information, including: if the target business request is determined to be a concurrent request, the first algorithm is determined as the flow control algorithm of the target business request; or, if the target business request is determined to be a non-concurrent request, the second algorithm is determined as the flow control algorithm of the target business request.

[0065] The first algorithm may be a RateLimiter token bucket algorithm, and the second algorithm may be a Redis token bucket algorithm.

[0066] In one of the embodiments, the flow control algorithm corresponding to the target business request is determined based on the request frequency corresponding to the target business request and the preset flow limiting configuration information, including: if it is determined that the request frequency of the target business request is greater than a preset threshold, then the third algorithm is determined as the flow control algorithm of the target business request; or, if it is determined that the request frequency of the target business request is less than or equal to the preset threshold, then the fourth algorithm is determined as the flow control algorithm of the target business request.

[0067] Among them, the third algorithm can be a Redis token bucket algorithm, and the fourth algorithm can be a RateLimiter token bucket algorithm.

[0068] In one embodiment, determining whether to batch process the target service request and determining the flow control algorithm corresponding to the target service request based on preset flow limiting configuration information corresponding to batch processing and non-batch processing, respectively, includes:

[0069] If it is determined that the target business request requires batch processing, the flow control algorithm corresponding to each subtask in the subtask that requires batch processing is determined; or, if it is determined that the target business request does not require batch processing, it is determined whether asynchronous flow limiting processing is performed and the flow control algorithm of the target request business is determined.

[0070] The subtask may be one file processing request or multiple file processing requests in the target business request of the third service type.

[0071] It is understandable that multiple files in a batch of files can use the same flow control method or different flow control methods. Therefore, a batch of files can be divided into multiple subtasks for processing, and the flow control algorithms corresponding to each subtask can be the same or different. It is also understandable that it is possible to choose whether to perform asynchronous flow control on the target business request based on demand. Among them, asynchronous flow control is used to hand over the time-consuming sub-steps to the asynchronous thread for execution. In addition, the flow control rate of the asynchronous thread processing request can be controlled by itself. After the target business request is processed by the asynchronous thread, the processing result can be fed back to the main process.

[0072] In one embodiment, selecting target current limiting configuration information that matches the service name from preset current limiting configuration information includes:

[0073] If it is determined to perform asynchronous current limiting processing, the current limiting rate is determined based on the number of requests of the target business request within the predetermined time and the preset current limiting configuration corresponding to the target business request; and the flow control algorithm of the target business request is determined based on the preset current limiting configuration information; wherein, the current limiting rate and the flow control algorithm of the target business request are used to perform current limiting processing on the target business request; if it is determined not to perform asynchronous current limiting processing, the flow control algorithm corresponding to each file in the target business request is determined based on the preset current limiting configuration information.

[0074] The current limiting rate may be determined based on a ratio of the number of target service request requests within a predetermined time period to a preset current limiting configuration corresponding to the target service request. If the ratio of the number of target service request requests within a predetermined time period to the preset current limiting configuration corresponding to the target service request is greater than a preset threshold, the current limiting rate is determined to be a first preset rate; if the ratio of the number of target service request requests within a predetermined time period to the preset current limiting configuration corresponding to the target service request is less than or equal to the preset threshold, the current limiting rate is determined to be a second preset rate.

[0075] Specifically, the asynchronous framework of Akka is introduced. The bottom layer of Akka encapsulates the built-in thread pool of Actor. After calculating the corresponding current limiting rate, the flow of target business requests can be controlled through the Throttle current limiting component.

[0076] In one embodiment, Figure 7 A schematic block diagram of the flow control method provided by the present invention. Figure 7 As shown in the figure, the AOP aspect is used to manage and intercept network service requests, file processing requests, or requests for feedback on file processing results, and the flow control algorithms corresponding to requests of various business types are obtained from the flow limiting decision configuration table.

[0077] Specifically, Figure 8The present invention provides a schematic block diagram of a flow control method for various types of services. Figure 8 As shown, for Dubbo service requests, the system determines whether concurrent requests exist. If so, it uses the Redis token bucket algorithm for flow control; if not, it uses either the RateLimiter token bucket algorithm or the Redis token bucket algorithm. For timed scheduling requests, the system determines the flow control algorithm by determining the frequency of scheduling. If the frequency is greater than a preset threshold, it uses the Redis token bucket algorithm for flow control; if the frequency is less than or equal to the preset threshold, it uses the RateLimiter token bucket algorithm for flow control. For file processing requests, it determines whether batch processing is required. If batch processing is required, it obtains the preset flow control algorithm for each subtask by obtaining the corresponding component configuration in each batch processing subtask. Flow control is then performed for each subtask according to the preset flow control algorithm. If batch processing is not required, it determines whether asynchronous processing is required. If asynchronous processing is required, it uses the Akka asynchronous framework and the Throttle throttling component to control the flow of the target service request based on the calculated flow limit rate. If asynchronous processing is not required, flow control is performed for each file according to the preset flow control algorithm.

[0078] In one embodiment, Figure 9 A schematic diagram of the current limiting decision configuration table provided by the present invention. Figure 9 As shown, the flow limiting decision configuration table includes: the business name corresponding to the business request, the business type, the component selection configuration item for selecting the flow control algorithm, whether it is a batch processing identifier, the batch processing subtask name, the subtask component configuration item, and the asynchronous processing component configuration item.

[0079] The flow control device provided by the present invention is described below. The flow control device described below corresponds to the flow control method described above.

[0080] Figure 10 Schematic block diagram of the flow control device provided by the present invention. Figure 10 As shown, the flow control device provided by the present invention includes:

[0081] The receiving module 1010 is configured to receive a service request and determine a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of a file processing result;

[0082] An acquisition module 1020 is configured to acquire a service name corresponding to the target service request;

[0083] A selection module 1030 is configured to select target current limiting configuration information that matches the service name from preset current limiting configuration information; wherein the preset current limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type;

[0084] The current limiting module 1040 is configured to perform current limiting on the interface corresponding to the target service request according to the target current limiting configuration information.

[0085] The flow control device provided by the present invention determines a target service request and, based on preset flow-limiting configuration information, determines the flow control algorithm corresponding to the target service request. This allows for the use of appropriate flow control algorithms for different types of service requests, making the flow control method provided by the present invention applicable to diverse service scenarios. Furthermore, because the flow control algorithm corresponding to the target service request is determined based on the preset flow-limiting configuration information, if additional flow-limiting methods are desired, they can be directly expanded within the preset flow-limiting configuration information, thereby enabling flexible expansion of existing flow-limiting methods based on service development.

[0086] In one embodiment, the selection module 1030 includes:

[0087] A first determining unit, configured to determine a service type corresponding to the service name based on the preset current limiting configuration information;

[0088] The second determining unit is configured to determine, based on the service type corresponding to the service name, a flow control algorithm corresponding to the service type.

[0089] In one embodiment, the second determining unit includes:

[0090] a third determining unit, configured to determine whether the target service request is a concurrent request if the service type corresponding to the service name is the first service type, and determine a flow control algorithm for the target service request based on preset flow limiting configuration information; or

[0091] a fourth determining unit, configured to determine, if the service type corresponding to the service name is the second service type, a flow control algorithm corresponding to the target service request based on the request frequency corresponding to the target service request and preset flow limiting configuration information; or

[0092] a fifth determining unit, configured to determine whether the target service request is to be batch processed if the service type corresponding to the service name is the third service type, and determine a flow control algorithm corresponding to the target service request based on preset flow limiting configuration information corresponding to batch processing and non-batch processing, respectively; or

[0093] The current limiting unit is used to perform asynchronous current limiting processing on the target service request if the service type corresponding to the service name is the fourth service type.

[0094] In one embodiment, the second determining unit includes:

[0095] a sixth determining unit, configured to determine the first algorithm as the flow control algorithm for the target service request if it is determined that the target service request is a concurrent request; or

[0096] The seventh determining unit is configured to determine the second algorithm as the flow control algorithm for the target service request if it is determined that the target service request is a non-concurrent request.

[0097] In one embodiment, the fourth determining unit includes:

[0098] an eighth determining unit, configured to determine the third algorithm as the flow control algorithm for the target service request if it is determined that the request frequency of the target service request is greater than a preset threshold; or

[0099] The ninth determining unit is configured to determine the fourth algorithm as the flow control algorithm for the target service request if it is determined that the request frequency of the target service request is less than or equal to a preset threshold.

[0100] In one embodiment, the fifth determining unit includes:

[0101] a tenth determining unit, configured to determine a flow control algorithm corresponding to each subtask in the subtasks requiring batch processing if it is determined that the target service request requires batch processing; or

[0102] The eleventh determining unit is configured to determine whether to perform asynchronous current limiting processing if it is determined that the target service request does not require batch processing, and determine a flow control algorithm for the target request service.

[0103] In one embodiment, the selection module 1030 includes:

[0104] A processing unit, configured to, if it is determined that asynchronous current limiting processing is to be performed, determine a current limiting rate based on the number of requests of the target service request within a predetermined time and a preset current limiting configuration corresponding to the target service request; and determine a flow control algorithm for the target service request based on the preset current limiting configuration information; wherein the current limiting rate and the flow control algorithm for the target service request are used to perform current limiting processing on the target service request;

[0105] The twelfth determining unit is configured to determine, if it is determined that asynchronous current limiting processing is not to be performed, a flow control algorithm corresponding to each file in the target service request based on preset current limiting configuration information.

[0106] In one embodiment, a computer device is proposed, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: receiving a service request and determining a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of a file processing result; obtaining a service name corresponding to the target service request; selecting target flow limiting configuration information that matches the service name from preset flow limiting configuration information; wherein the preset flow limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type; and performing flow limiting processing on the interface corresponding to the target service request according to the target flow limiting configuration information.

[0107] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the flow control method provided by the present invention, wherein the flow control method includes: receiving a service request and determining a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of file processing results; obtaining a service name corresponding to the target service request; selecting target flow limiting configuration information that matches the service name from the preset flow limiting configuration information; wherein the preset flow limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type; and performing flow limiting processing on the interface corresponding to the target service request according to the target flow limiting configuration information.

[0108] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the flow control method provided by the present invention, wherein the flow control method includes: receiving a service request, and determining a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of file processing results; obtaining a service name corresponding to the target service request; selecting target flow limiting configuration information matching the service name from the preset flow limiting configuration information; wherein the preset flow limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type; and performing flow limiting processing on the interface corresponding to the target service request according to the target flow limiting configuration information.

[0109] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0110] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A flow control method, characterized in that: The method comprises: Receive a service request and determine a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of a file processing result; Obtaining a service name corresponding to the target service request; Selecting target current limiting configuration information that matches the service name from preset current limiting configuration information; wherein the preset current limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type; Performing current limiting processing on the interface corresponding to the target service request according to the target current limiting configuration information; The selecting target current limiting configuration information that matches the service name from the preset current limiting configuration information includes: Determining the service type corresponding to the service name based on the preset current limiting configuration information; Determining, based on the service type corresponding to the service name, a flow control algorithm corresponding to the service type; The service type includes a first service type, and determining a flow control algorithm corresponding to the service type based on the service type corresponding to the service name includes: If the service type corresponding to the service name is the first service type, determine whether the target service request is a concurrent request; if it is determined that the target service request is a concurrent request, determine the first algorithm as the flow control algorithm of the target service request; or, if it is determined that the target service request is a non-concurrent request, determine the second algorithm as the flow control algorithm of the target service request.

2. The flow control method according to claim 1, wherein: The service type further includes a second service type, a third service type, and a fourth service type. The determining, based on the service type corresponding to the service name, a flow control algorithm corresponding to the service type further includes: If the service type corresponding to the service name is the second service type, determining a flow control algorithm corresponding to the target service request based on the request frequency corresponding to the target service request and preset flow limiting configuration information; or, If the service type corresponding to the service name is the third service type, determining whether the target service request is batch processed, and determining a flow control algorithm corresponding to the target service request based on preset flow limiting configuration information corresponding to batch processing and non-batch processing respectively; or, If the service type corresponding to the service name is the fourth service type, asynchronous current limiting processing is performed on the target service request.

3. The flow control method according to claim 2, wherein: The determining of a flow control algorithm corresponding to the target service request based on the request frequency corresponding to the target service request and preset flow limiting configuration information includes: If it is determined that the request frequency of the target service request is greater than the preset threshold, the third algorithm is determined as the flow control algorithm for the target service request; or, If it is determined that the request frequency of the target service request is less than or equal to the preset threshold, the fourth algorithm is determined as the flow control algorithm for the target service request.

4. The flow control method according to claim 2, wherein: The determining whether the target service request is to be batch processed and determining the flow control algorithm corresponding to the target service request based on preset flow limiting configuration information corresponding to batch processing and non-batch processing, respectively, includes: If it is determined that the target business request requires batch processing, then determine the flow control algorithm corresponding to each subtask in the subtask that requires batch processing; or, If it is determined that the target service request does not require batch processing, it is determined whether to perform asynchronous current limiting processing and a flow control algorithm for the target service request is determined.

5. The flow control method according to claim 4, wherein: The selecting target current limiting configuration information that matches the service name from the preset current limiting configuration information includes: If it is determined to perform asynchronous current limiting processing, the current limiting rate is determined according to the number of requests of the target service request within the predetermined time and the preset current limiting configuration corresponding to the target service request; Determining a flow control algorithm for the target service request based on preset flow limiting configuration information; The flow limiting rate and the flow control algorithm of the target service request are used to perform flow limiting processing on the target service request; If it is determined that asynchronous current limiting processing is not performed, a flow control algorithm corresponding to each file in the target service request is determined based on preset current limiting configuration information.

6. A flow control device, characterized in that: The device comprises: A receiving module, configured to receive a service request and determine a target service request from the service request; wherein the target service request is a network service request, a file processing request, or a request for feedback of a file processing result; An acquisition module, configured to acquire a service name corresponding to the target service request; a selection module, configured to select target current limiting configuration information matching the service name from preset current limiting configuration information; wherein the preset current limiting configuration information includes a pre-configured service name, service type, and a flow control algorithm corresponding to the service type; A current limiting module, configured to limit the current of the interface corresponding to the target service request according to the target current limiting configuration information; The selection module includes: A first determining unit, configured to determine a service type corresponding to the service name based on the preset current limiting configuration information; A second determining unit is configured to determine, based on the service type corresponding to the service name, a flow control algorithm corresponding to the service type; The service type includes a first service type, and the second determining unit includes: a third determining unit, configured to determine whether the target service request is a concurrent request if the service type corresponding to the service name is the first service type; a sixth determining unit, configured to determine the first algorithm as the flow control algorithm for the target service request if it is determined that the target service request is a concurrent request; or The seventh determining unit is configured to determine the second algorithm as the flow control algorithm for the target service request if it is determined that the target service request is a non-concurrent request.

7. A computer device comprising a memory and a processor, wherein the memory stores computer-readable instructions, characterized in that: When the computer-readable instructions are executed by the processor, the processor is caused to perform the steps of the flow control method according to any one of claims 1 to 5.

8. A storage medium storing computer-readable instructions, characterized in that: When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to perform the steps of the flow control method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Interface current limiting method and device, computer equipment and storage medium

    CN112612618A