A high-concurrency flow limiting method, device and computer storage medium

By using the hourglass model's token bucket rolling relationship and timer triggering, a traffic closed loop is formed, solving the problem of insufficient traffic relationship closed loop in traditional rate limiting algorithms, and achieving precise control and efficient rate limiting of token traffic.

CN115665045BActive Publication Date: 2026-02-06ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211081754.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-06
Publication Date
2026-02-06
Estimated Expiration
2042-09-06

AI Technical Summary

Technical Problem

Traditional rate limiting algorithms lack a closed loop of traffic relationships, resulting in inaccurate rate limiting effects.

Method used

The token bucket rolling relationship using the hourglass model forms a closed loop of traffic relationship through the distribution and recycling of tokens. Combined with timer-triggered rate limiting cycle iteration, precise control of token traffic is achieved.

Benefits of technology

It achieves precise rate limiting of token traffic, supports burst traffic, and improves the accuracy and efficiency of rate limiting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115665045B_ABST
    Figure CN115665045B_ABST
Patent Text Reader

Abstract

The application provides a high-concurrency flow limiting method, device and computer storage medium. The high-concurrency flow limiting method is applied to a client, and the high-concurrency flow limiting method comprises the following steps: in response to an application token event trigger, a token is obtained from a first token bucket of a token issuing period, wherein the token issuing period value is updated to the first token issuing period; based on the token, a business request of the application token event is executed, and generated business data is uploaded to a server; whether the current flow limiting period when the business request corresponding to the token is completed is the first flow limiting period is detected; if yes, the token is returned to a recycling token bucket of the first flow limiting period; wherein the total number of tokens of each flow limiting period is a fixed value. The above-mentioned high-concurrency flow limiting method can form a token flow relationship closed loop through the distribution of tokens and the recycling of tokens, simultaneously investigate the inflow and outflow of token flow, and truly reflect the precise flow limiting effect of flow limiting.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, in particular to a high-concurrency flow limiting method and device and computer storage medium. BACKGROUND

[0002] At present, network-based service systems provide various services. Generally, according to the specific services provided, the access volume that the service system can bear is limited. When the access volume exceeds the range that the service system can bear, the flow needs to be limited to prevent the service system from crashing. A common flow limiting method is to estimate the access volume of the overall service according to the single-service response time and other values at the beginning of system design, so as to estimate the access volume that the service system should bear, and set the access flow limit and access speed of the service according to the estimation. For example, a token bucket is used to implement flow limiting.

[0003] The token bucket algorithm is the most commonly used algorithm in network traffic shaping and rate limiting. The token bucket algorithm originates from computer networks. When transmitting data in a network, in order to prevent network congestion, the flow out of the network needs to be limited, so that the flow is sent out at a relatively uniform speed. The token bucket algorithm realizes this function, and can control the number of data sent to the network, and allow the transmission of burst data.

[0004] However, in the process of implementing the present application, the inventors found that at least the following problems exist in the prior art: the traditional flow limiting algorithm lacks a flow relationship closed loop, only considers inflow and does not consider outflow, resulting in inaccurate flow limiting effect. SUMMARY

[0005] The present application provides a high-concurrency flow limiting method, device and computer storage medium, which mainly solves the technical problem of how to realize accurate flow limiting of the flow limiting effect.

[0006] To solve the above technical problems, the present application provides a high-concurrency flow limiting method, which is applied to a client, and the high-concurrency flow limiting method comprises:

[0007] In response to an application token event trigger, a token is obtained from a first flow limiting period token bucket, wherein the publication period value of the token is updated to the first flow limiting period;

[0008] Based on the token, a business request of the application token event is executed, and generated business data is uploaded to a server;

[0009] Detect whether the current flow limiting period when the business request corresponding to the token is completed is the first flow limiting period;

[0010] If yes, the token is put back into a recycle token bucket of the first throttling period;

[0011] wherein a total number of tokens of each throttling period is a fixed value.

[0012] wherein after uploading the generated service data to the server, the high-concurrency throttling method further comprises:

[0013] when the current throttling period in which the business request corresponding to the token is completed is a second throttling period, the token is put into a token issuing bucket of the second throttling period.

[0014] wherein after uploading the generated service data to the server, the high-concurrency throttling method further comprises:

[0015] when the current throttling period in which the business request corresponding to the token is completed is a second throttling period, a business request queue is acquired.

[0016] whether there is a valid historical request in the business request queue is detected.

[0017] If yes, a first valid request in the business request queue is acquired, a token issuing period value of the token is updated to the second throttling period, and the first valid request is executed based on the token.

[0018] wherein after acquiring the business request queue, the high-concurrency throttling method further comprises:

[0019] when there is no valid historical request in the business request queue, the token is put back into the token issuing bucket of the second throttling period.

[0020] wherein the second throttling period and the first throttling period are adjacent throttling periods.

[0021] the high-concurrency throttling method further comprises:

[0022] when the current throttling period in which the business request corresponding to the token is completed is a second throttling period, the token in the token issuing bucket in the first throttling period is put into a recycle token bucket in the second throttling period, and the token in the recycle token bucket in the first throttling period is put into the token issuing bucket in the second throttling period.

[0023] wherein a period iteration between the first throttling period and the adjacent second throttling period is triggered by a pre-registered timer.

[0024] wherein the high-concurrency throttling method further comprises:

[0025] In response to the application token event trigger, when the token bucket of the first flow limiting period cannot obtain a token, the service request of the application token event is put into a fixed-length service request queue.

[0026] To solve the above technical problems, the application further provides a high-concurrency flow limiting device, comprising an acquisition module, an execution module and a recycling module, wherein,

[0027] The acquisition module is configured to acquire a token from a token bucket of a first flow limiting period in response to an application token event trigger, wherein the issue period value of the token is updated to the first flow limiting period.

[0028] The execution module is configured to execute a service request of the application token event based on the token, and upload generated service data to a server.

[0029] The recycling module is configured to detect whether the current flow limiting period when the service request corresponding to the token is completed is the first flow limiting period, and if so, put the token back into a recycling token bucket of the first flow limiting period.

[0030] The total number of tokens of each flow limiting period is a fixed value.

[0031] To solve the above technical problems, the application further provides a high-concurrency flow limiting device, comprising a processor and a memory coupled to the processor.

[0032] The memory is configured to store program data, and the processor is configured to execute the program data to implement the high-concurrency flow limiting method as described above.

[0033] To solve the above technical problems, the application further provides a computer storage medium for storing program data, which, when executed by a processor, is used to implement the high-concurrency flow limiting method as described above.

[0034] Compared with the prior art, the application has the following beneficial effects: the high-concurrency flow limiting device acquires a token from a token bucket of a first flow limiting period in response to an application token event trigger, wherein the issue period value of the token is updated to the first flow limiting period; executes a service request of the application token event based on the token, and uploads generated service data to a server; detects whether the current flow limiting period when the service request corresponding to the token is completed is the first flow limiting period, and if so, puts the token back into a recycling token bucket of the first flow limiting period; wherein the total number of tokens of each flow limiting period is a fixed value. The above high-concurrency flow limiting method can form a token flow relationship closed loop by distributing tokens and recycling tokens, simultaneously consider the inflow and outflow of token flow, and truly reflect the precise flow limiting of flow limiting effect. BRIEF DESCRIPTION OF DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and all other drawings obtained by those of ordinary skill in the art without creative effort based on these drawings are within the scope of the present application.

[0036] Figure 1 is a schematic diagram of a sandglass model of period n provided by the present application;

[0037] Figure 2 is a schematic diagram of a sandglass model of period n+1 provided by the present application;

[0038] Figure 3 is a flowchart of an embodiment of the high-concurrency flow limiting method provided by the present application;

[0039] Figure 4 is a flowchart of the sandglass model token acquisition and recycling provided by the present application;

[0040] Figure 5 is a flowchart of another embodiment of the high-concurrency flow limiting method provided by the present application;

[0041] Figure 6 is a structural diagram of an embodiment of the high-concurrency flow limiting device provided by the present application;

[0042] Figure 7 is a structural diagram of another embodiment of the high-concurrency flow limiting device provided by the present application;

[0043] Figure 8 is a structural diagram of an embodiment of the computer storage medium provided by the present application. DETAILED DESCRIPTION

[0044] The technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of the present application.

[0045] Token bucket is a kind of algorithm system service most commonly used in network traffic shaping and rate limiting. As a producer, tokens are added to the bucket (container) at a specified frequency, such as QPS (Queries-per-second) 2, one token is added to the bucket every 500 ms, and if the number of tokens in the bucket reaches the threshold, no more tokens will be added.

[0046] As a consumer, each request needs to take a token from the bucket, and if the token is obtained, the execution will continue; if there is no token in the bucket, the rejection strategy will be triggered, which can be a timeout waiting or directly rejecting the request, thereby achieving the purpose of flow limiting.

[0047] A token is a request pass in a certain flow limiting environment, and the request will be provided with corresponding business services by the service issuing the token, otherwise it will be delayed or returned with a specified error code.

[0048] Before describing the high-concurrency flow limiting method of the present application, two new concepts are proposed: token full life cycle state and token number conservation.

[0049] Token full life cycle state: any token in the life cycle has only the following 3 states (not issued, issued, and recycled). The 3 states correspond to: "not issued" in the current token bucket of the flow limiting period, "issued" not in any token bucket, held by the request in the service, and "recycled" indicating that the held request has been completed or terminated, and the token is recycled to the specified recycle token bucket.

[0050] Token number conservation: when there is no external business adjustment of the number of tokens in the token bucket, the total number of all inventory tokens remains unchanged, and the only change is the state of each token.

[0051] In the above introduction of the token full life cycle state, the current flow limiting period token bucket and the recycle token bucket are mentioned. The high-concurrency flow limiting method of the present application is based on a sandglass model, which is a combination of rolling relationship of time period dimension sending and receiving token buckets.

[0052] For details, please refer to Figure 1 and Figure 2 , Figure 1 is a schematic diagram of the sandglass model of period n provided by the present application, Figure 2 is a schematic diagram of the sandglass model of period n+1 provided by the present application.

[0053] In Figure 1 and Figure 2In the sandglass model, the entire sandglass model is composed of two token buckets. For example, at initialization, i.e., at cycle n, token bucket 1 is a token issuing bucket (all tokens in the token bucket are in the "not issued" state), and no tokens are issued when the flow control has not started. Token bucket 2 is a token recycling bucket (all tokens in the token bucket are in the "recycled" state).

[0054] In the first cycle after the flow control starts, which is temporarily named cycle 1, a request obtains a token from the token issuing bucket (currently, token bucket 1). The request that can obtain the token is served, and the token state is "issued". The token is recycled when the request holding the token is completed or terminated.

[0055] It should be noted that, because the life cycle of the request does not match the flow control cycle, the token records the flow control cycle value when the token is issued. The token is recycled into the token recycling bucket in the current flow control cycle, or the token is recycled into the token issuing bucket in a different flow control cycle.

[0056] In this way, it can be effectively ensured that the token is used at most once in the same cycle, thereby achieving the flow control effect.

[0057] The registered timer triggers the flow control cycle iteration. The roles of the two buckets are simply exchanged, i.e., the token issuing bucket and the token recycling bucket. For example, Figure 1 and Figure 2 In cycle n, token bucket 1 is the token issuing bucket, and token bucket 2 is the token recycling bucket. In cycle n+1, token bucket 1 is the token recycling bucket, and token bucket 2 is the token issuing bucket.

[0058] When the request is flow controlled, the request enters a fixed-length FIFO queue (i.e., the flow control rejection strategy) to cope with the situation that the number of tokens in the token issuing bucket in cycle N-1 is too small (there are probably many tokens in the token issuing bucket in cycle N+1) due to a large decrease in the number of requests in cycle N-1, thereby causing flow control in cycle N. The request in the FIFO queue is processed preferentially when the flow control cycle is iterated, but the request validity verification (to prevent invalid requests caused by disconnection of the request side) needs to be performed.

[0059] For the sandglass model described above, the application provides a high-concurrency flow control method applied to a client. For details, see Figure 3 and Figure 4 , Figure 3 is a flowchart of an embodiment of the high-concurrency flow control method provided in the application, Figure 4 is a flowchart of token obtaining and recycling of the sandglass model provided in the application.

[0060] The high-concurrency flow limiting method provided in the application is applied to a client, such as a disk-oriented, network IO flow limiting, and the like data autonomous producer role, or as a server proxy role. For example, when a network crawler captures data that needs to be uploaded to a server for aggregation, the flow limiting function is more suitable in front of the crawler, and through the above hourglass model flow limiting, the effect of peak clipping can be achieved, that is, a certain batch of delay processing can be tolerated in the business scenario. In the following, taking a high-concurrency flow limiting device as an execution subject of an embodiment, the specific process of the high-concurrency flow limiting method is further described.

[0061] As shown in Figure 3 , the high-concurrency flow limiting method provided in the embodiment of the application specifically includes the following steps:

[0062] Step S11: in response to the trigger of the token application event, a token is obtained from the token bucket of the first flow limiting period, wherein the token release period value is updated to the first flow limiting period.

[0063] In the embodiment of the application, when the high-concurrency flow limiting device enters the flow limiting state, the high-concurrency flow limiting strategy is started. Specifically, after the high-concurrency flow limiting device receives the trigger instruction of the token application event, a token is taken out from the token bucket of the current flow limiting period, that is, the first flow limiting period. After the token is obtained, the business request of the token application event can obtain the permission to execute the business request.

[0064] Wherein, the total number of tokens of each flow limiting period is a fixed value.

[0065] Further, the high-concurrency flow limiting device needs to update the token release period value to the first flow limiting period, so as to record the flow limiting period when the token is taken out.

[0066] Wherein, when the tokens of the token bucket of the first flow limiting period have been extracted by other business requests, that is, there is no token that can be taken out, it means that in the first flow limiting period, the current business processing amount has reached the threshold of flow limiting, and in the same period, the token cannot be allocated to execute the business request. At this time, the high-concurrency flow limiting device can execute the flow limiting rejection strategy, such as Figure 4 As shown, the business request is put into a fixed-length FIFO queue for queuing, and the business requests in the FIFO queue can be sorted according to the time of entering the queue, that is, the earlier the time, the higher the sorting.

[0067] The flow limiting rejection strategy of the FIFO queue is further described in the following embodiment of the high-concurrency flow limiting method.

[0068] Step S12: based on the token, the business request of the token application event is executed, and the generated business data is uploaded to the server.

[0069] In the embodiment of the present application, after the business request corresponding to the application token event obtains the token, the permission for executing the business request is obtained, that is, the related business request can be executed. In the client, that is, the edge side terminal of the distributed RPC system, as the autonomous producer of data, the process of executing the business request by the client can be regarded as generating the related data of the business request, and the related data of the business request is uploaded to the center side of the distributed RPC system, that is, the server.

[0070] When the business request execution is completed, the token is released, that is, the token needs to be put back into the recycled token bucket of the original flow limiting period and cannot be taken out again in the original flow limiting period, so as to realize the flow relationship closed loop monitoring; or the token is put into the token issuing bucket of the subsequent flow limiting period and can be taken out and used in the subsequent flow limiting period. Therefore, the high-concurrency flow limiting device needs to compare the token issuing period value with the current flow limiting period, and decide the destination of the token according to whether the results are consistent. Please continue to refer to steps S13 to S15.

[0071] Step S13: detecting whether the current flow limiting period when the business request corresponding to the token is completed is the first flow limiting period.

[0072] In the embodiment of the present application, the high-concurrency flow limiting device obtains the token issuing period value, that is, the first flow limiting period, and obtains the current flow limiting period when the business request corresponding to the token is completed. Then, it is judged whether the current flow limiting period when the business request corresponding to the token is completed is the same flow limiting period as the first flow limiting period. If yes, step S14 is entered; if no, step S15 is entered.

[0073] Step S14: putting the token back into the recycled token bucket of the first flow limiting period.

[0074] In the embodiment of the present application, when the current flow limiting period when the token needs to be put back is the same flow limiting period as the flow limiting period when the token is taken out, it is indicated that the token cannot be taken again in the flow limiting period. Therefore, the high-concurrency flow limiting device needs to put the token back into the recycled token bucket of the first flow limiting period.

[0075] Step S15: putting the token into the token issuing bucket of the second flow limiting period.

[0076] In the embodiment of the present application, when the current flow limiting period when the token needs to be put back is not the same flow limiting period as the flow limiting period when the token is taken out, it is indicated that the token can still be taken in the current flow limiting period. Therefore, the high-concurrency flow limiting device needs to put the token back into the token issuing bucket of the second flow limiting period. At this time, the time sequence relationship between the first flow limiting period and the second flow limiting period is not limited.

[0077] Further, it needs to be explained that, in the adjacent flow limiting periods, i.e. the first flow limiting period and the second flow limiting period are adjacent two flow limiting periods, when entering the second flow limiting period, the high concurrency flow limiting device exchanges the roles of the two token buckets in the first flow limiting period (the token issuing bucket role and the token recycling bucket role). As shown in Figure 1 and Figure 2 , the first flow limiting period is the hourglass model in Figure 1 , the token bucket 1 is the token issuing bucket, and the token bucket 2 is the token recycling bucket; and the second flow limiting period is the hourglass model in Figure 2 , the token bucket 2 is the token issuing bucket, and the token bucket 1 is the token recycling bucket.

[0078] The above token bucket role exchange can trigger the flow limiting period iteration through the registered timer, which is similar to flipping the hourglass according to the preset period, and keeping the upper token bucket of the hourglass as the token issuing bucket and the lower token bucket of the hourglass as the token recycling bucket.

[0079] Specifically, when the current flow limiting period at the time of completing the business request corresponding to the token is the second flow limiting period, the high concurrency flow limiting device puts the tokens in the token issuing bucket in the first flow limiting period into the token recycling bucket in the second flow limiting period, and puts the tokens in the token recycling bucket in the first flow limiting period into the token issuing bucket in the second flow limiting period, so as to realize the hourglass flipping and role exchange.

[0080] In the embodiment of the present application, the high concurrency flow limiting device responds to the token application event trigger to obtain tokens from the token issuing bucket in the first flow limiting period, wherein the issue period value of the token is updated to the first flow limiting period; based on the token, the business request of the token application event is executed, and the generated business data is uploaded to the server; it is detected whether the current flow limiting period at the time of completing the business request corresponding to the token is the first flow limiting period; if yes, the token is put back into the token recycling bucket in the first flow limiting period; wherein the total number of tokens in each flow limiting period is a fixed value. The above high concurrency flow limiting method can form a token flow relationship closed loop through the distribution of tokens and the recycling of tokens, simultaneously consider the inflow and outflow of token flow, and truly reflect the precise flow limiting effect of flow limiting.

[0081] In order to improve the precise flow limiting and efficient flow limiting, the present application further provides a method for quickly obtaining tokens, i.e. preferentially allocating tokens of the historical flow limiting period to the valid historical requests in the business request queue, so as to efficiently utilize the available tokens. Please continue to refer to Figure 5 , Figure 5 which is a flow diagram of another embodiment of the high concurrency flow limiting method provided by the present application.

[0082] As shown in Figure 5 , the high concurrency flow limiting method of the embodiment of the present application specifically includes the following steps:

[0083] Step S21: When the current flow limiting period of the service request corresponding to the token is completed is the second flow limiting period, obtaining the service request queue.

[0084] In the embodiment of the present application, when the current flow limiting period of the service request corresponding to the token is completed, i.e. the second flow limiting period, is not the same as the token issuing period value, i.e. the first flow limiting period, the high-concurrency flow limiting device further obtains a fixed-length FIFO queue.

[0085] Step S22: Detecting whether there is a valid historical request in the service request queue.

[0086] In the embodiment of the present application, as shown in Figure 4 The high-concurrency flow limiting device searches the service request from the service request queue and detects the validity of the service request. When a valid historical request is successfully searched, step S23 is entered; when there is no valid historical request in the service request queue, step S24 is entered.

[0087] Step S23: Obtaining the first valid request in the service request queue, updating the token issuing period value to the second flow limiting period, and executing the first valid request based on the token.

[0088] In the embodiment of the present application, the FIFO queue pops the head, i.e. the first valid request, assigns the token to the first valid request, executes the service of the first valid request, and updates the token issuing period value to the second flow limiting period.

[0089] In this way, the high-concurrency flow limiting device can not need to return the token to the token bucket of the current flow limiting period, but directly assign the token to the valid request of the FIFO queue, improving the token distribution efficiency.

[0090] Step S24: Putting the token back to the token bucket of the second flow limiting period.

[0091] In the embodiment of the present application, the high-concurrency flow limiting device returns the token to the token bucket of the current flow limiting period, i.e. the second flow limiting period, and waits to be taken out.

[0092] In the embodiment of the present application, the high-concurrency flow limiting device realizes closed-loop flow in-flow and out-flow monitoring through a sandglass model, and truly reflects the precise flow limiting effect of the flow limiting effect; the sandglass model of the present application has no period critical problem in the traditional flow limiting algorithm, and supports burst flow; the high-concurrency flow limiting method of the embodiment of the present application directly uses the flow out-flow index, which is relatively simple in overall implementation and directly obvious in effect compared with indirectly converting the period token threshold value.

[0093] The above examples are only one common case of the present application, and do not limit the technical scope of the present application. Therefore, any slight modification, equivalent change or modification of the above content according to the essence of the present application still belongs to the scope of the technical scheme of the present application.

[0094] Based on the above embodiment of the collision detection method, the present application further provides a high-concurrency flow limiting device, please refer to Figure 6 , Figure 6 is a structural schematic diagram of an embodiment of the high-concurrency flow limiting device provided by the present application.

[0095] The high-concurrency flow limiting device 300 of the embodiment includes an acquisition module 31, an execution module 32 and a recycling module 33.

[0096] The acquisition module 31 is configured to acquire a token from a first token bucket in response to an application token event trigger, wherein the publishing period value of the token is updated to the first flow limiting period.

[0097] The execution module 32 is configured to execute a business request of the application token event based on the token, and upload generated business data to a server.

[0098] The recycling module 33 is configured to detect whether the current flow limiting period when the business request corresponding to the token is completed is the first flow limiting period, and if so, put the token back to a recycling token bucket of the first flow limiting period, wherein the total number of tokens of each flow limiting period is a fixed value.

[0099] Based on the above embodiment of the high-concurrency flow limiting method, the present application further provides a high-concurrency flow limiting device, please refer to Figure 7 , Figure 7 is a structural schematic diagram of another embodiment of the high-concurrency flow limiting device provided by the present application.

[0100] The robot 400 of the embodiment includes a processor 41, a memory 42, an input / output device 43 and a bus 44.

[0101] The processor 41, the memory 42 and the input / output device 43 are respectively connected to the bus 44, the memory 42 stores program data, and the processor 41 is configured to execute the program data to realize the high-concurrency flow limiting method described in the above embodiments.

[0102] In the embodiments of the present application, the processor 41 can also be referred to as a CPU (Central Processing Unit). The processor 41 can be an integrated circuit chip having a processing capability of signals. The processor 41 can also be a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor 41 can also be any conventional processor or the like.

[0103] The present application also provides a computer storage medium, please continue to refer to Figure 8 , Figure 8 is a structural schematic diagram of an embodiment of the computer storage medium provided by the present application. The computer storage medium 500 stores program data 51, which, when executed by a processor, is used to implement the high-concurrency flow limiting method of the above-mentioned embodiments.

[0104] When the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the whole or part of the technical solutions that make essential contributions to the prior art can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0105] The above only describes the embodiments of the present application, and does not limit the patent scope of the present application. The equivalent structure or equivalent flow transformation made by the content of the present application specification and drawings, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A high concurrency flow limiting method, characterized in that, The high-concurrency throttling method is applied to a client, and the high-concurrency throttling method comprises: In response to an application token event trigger, a token is obtained from a token issuing bucket of a first throttling period, wherein a token issuing period value is updated to the first throttling period; Based on the token, a business request of the application token event is executed, and generated business data is uploaded to a server; It is detected whether the current throttling period when the business request corresponding to the token is completed is the first throttling period; If yes, the token is put back into a token recycling bucket of the first throttling period; The total number of tokens of each throttling period is a fixed value; After the generated business data is uploaded to the server, the high-concurrency throttling method further comprises: When the current throttling period when the business request corresponding to the token is completed is a second throttling period, the token is put into a token issuing bucket of the second throttling period.

2. The high-concurrency throttling method according to claim 1, wherein After the generated business data is uploaded to the server, the high-concurrency throttling method further comprises: When the current throttling period when the business request corresponding to the token is completed is a second throttling period, a business request queue is obtained; It is detected whether there is a valid historical request in the business request queue; If yes, a first valid request in the business request queue is obtained, the token issuing period value is updated to the second throttling period, and the first valid request is executed based on the token.

3. The high-concurrency throttling method according to claim 2, wherein After the business request queue is obtained, the high-concurrency throttling method further comprises: When there is no valid historical request in the business request queue, the token is put back into the token issuing bucket of the second throttling period.

4. The high-concurrency throttling method according to claim 2 or 3, wherein The second throttling period and the first throttling period are adjacent throttling periods; The high-concurrency throttling method further comprises: When the current throttling period when the business request corresponding to the token is completed is a second throttling period, the token in the token issuing bucket of the first throttling period is put into a recycling token bucket of the second throttling period, and the token in the recycling token bucket of the first throttling period is put into the token issuing bucket of the second throttling period.

5. The high-concurrency throttling method according to claim 4, wherein Period iteration between the first throttling period and the adjacent second throttling period is triggered by a pre-registered timer.

6. The high-concurrency throttling method according to claim 2, wherein The high-concurrency throttling method further comprises: In response to an application token event trigger, when a token cannot be obtained from a token issuing bucket of a first throttling period, a business request of the application token event is put into a fixed-length business request queue.

7. A high-concurrency current-limiting device, characterized in that, The high-concurrency throttling device comprises an obtaining module, an executing module, and a recycling module, wherein The obtaining module is configured to obtain a token from a token issuing bucket of a first throttling period in response to an application token event trigger, wherein a token issuing period value is updated to the first throttling period. The execution module is configured to execute a service request of the application token event based on the token, and upload generated service data to a server; The recovery module is configured to detect whether a current flow limiting period when the service request corresponding to the token is completed is the first flow limiting period; if yes, the token is put back into a recovery token bucket of the first flow limiting period; The total number of tokens in each flow limiting period is a fixed value; The execution module is further configured to, when the current flow limiting period when the service request corresponding to the token is completed is a second flow limiting period, put the token into a token issuing bucket of the second flow limiting period.

8. A high-concurrency current-limiting device, characterized in that, The high-concurrency flow limiting device comprises a processor and a memory coupled to the processor; The memory is configured to store program data, and the processor is configured to execute the program data to implement the high-concurrency flow limiting method according to any one of claims 1-6.

9. A computer storage medium, characterized in that The computer storage medium is configured to store program data, and the program data, when executed by a processor, is used to implement the high-concurrency flow limiting method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Token processing method and device

    CN106453127A

  • Intelligent token pre-collection method based on time series prediction

    CN109104378A