Method, device, equipment and medium for requesting speed limit

By judging the request queue status and specific requests and prioritizing the processing of specific requests, the problem of poor user experience in the current limiting solution under large traffic is solved, and the priority response of specific users is achieved.

CN115883481BActive Publication Date: 2025-08-29HANGZHOU DBAPPSECURITY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211557891.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-06
Publication Date
2025-08-29
Estimated Expiration
2042-12-06

AI Technical Summary

Technical Problem

When the existing flow restriction solution bursts with large traffic, all users' requests are affected, extending business processing time and poor user experience.

Method used

By obtaining the target request and determining whether the waiting queue is empty, if it is empty, it will be sent directly to the source station. If it is not empty, it will be judged whether the request is a specific request. If it is a specific request, it will be stored in the waiting queue and sent to the source station. Otherwise, it will return to the waiting page or discard the request.

Benefits of technology

When there are many requests, priority is given to the specific request response of specific clients to improve the user experience of specific users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115883481B_ABST
    Figure CN115883481B_ABST
Patent Text Reader

Abstract

The present application discloses a request rate limiting method, apparatus, device and medium, which are applied to a rate limiting module and relate to the field of computer technology. The method includes: obtaining a target request sent by a target client and determining whether a waiting queue is empty; if it is empty, sending the target request to a source station so that the source station returns a request response based on the target request; if it is not empty, determining whether the target request is a specific request sent by a specific client; if it is not a specific request, returning a waiting page to the target client; if it is a specific request, storing the target request in a waiting queue, and when the waiting queue releases the target request, sending the target request to the source station so that the source station returns a request response based on the target request. When there are many requests, the present application gives priority to ensuring the normal response of a specific request sent by a specific client, so as to ensure a better user experience for users using the specific client.
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 method, device, equipment and medium for requesting speed limit. Background Art

[0002] Currently, when reaching the system's QPS (Queries Per Second) performance limit, the existing throttling solution may affect all user requests in the event of a sudden surge in traffic, and will extend user business processing time, resulting in a poor user experience for all users.

[0003] To sum up, how to ensure a better user experience is an urgent issue that needs to be addressed. Summary of the Invention

[0004] In view of this, the present invention aims to provide a method, apparatus, device, and medium for requesting rate limiting, which can ensure a better user experience. The specific solution is as follows:

[0005] In a first aspect, the present application discloses a method for requesting speed limit, which is applied to a speed limit module, comprising:

[0006] Get the target request sent by the target client and determine whether the waiting queue is empty;

[0007] If it is empty, the target request is sent to the source station so that the source station returns a request response based on the target request; if it is not empty, it is determined whether the target request is a specific request sent by a specific client;

[0008] If it is not a specific request, the waiting page is returned to the target client; if it is a specific request, the target request is stored in the waiting queue, and when the waiting queue releases the target request, the target request is sent to the source station so that the source station returns a request response based on the target request.

[0009] Optionally, sending the target request to the source station so that the source station returns a request response based on the target request includes:

[0010] A new token is allocated to the target request from a token bucket, and the target request carrying the new token is sent to the source station, so that the source station returns a request response carrying the new token based on the target request.

[0011] Optionally, before obtaining the target request sent by the target client, the method further includes:

[0012] Obtain the speed limit configuration issued by the service end; the speed limit configuration includes the token bucket size, waiting queue size and preset token addition speed;

[0013] The token bucket and the waiting queue are set based on the rate limit configuration, and tokens are created and added to the token bucket according to the preset token addition speed.

[0014] Optionally, determining whether the target request is a specific request sent by a specific client includes:

[0015] It is determined whether the target request is a request that has been sent by an online client and carries the original token. If so, the target request is a specific request; otherwise, the target request is not a specific request.

[0016] Optionally, determining whether the target request is a specific request sent by a specific client includes:

[0017] It is determined whether the target request is a request sent by a newly online client without carrying the original token. If so, the target request is a specific request; otherwise, the target request is not a specific request.

[0018] Optionally, allocating a new token for the target request from a token bucket and sending the target request carrying the new token to the source station, so that the source station returns a request response carrying the new token based on the target request, includes:

[0019] Allocate a new token for the target request from a token bucket, and send the target request carrying the new token to the source station, so that the source station returns a request response carrying the new token based on the target request;

[0020] The request response carrying the new token is sent together to the target client, so that the target client sends a new request carrying the new token to the rate limiting module.

[0021] Optionally, sending the request response carrying the new token together to the target client, so that the target client sends a new request carrying the new token to the rate limiting module, includes:

[0022] The new token is stored in a cookie, and the request response carrying the cookie is sent to the target client, so that the target client sends a new request carrying the cookie to the rate limiting module.

[0023] In a second aspect, the present application discloses a speed limit request device, which is applied to a speed limit module and includes:

[0024] The request acquisition module is used to obtain the target request sent by the target client;

[0025] A judgment module is used to judge whether the waiting queue is empty;

[0026] A first processing module is configured to, if the value is empty, send the target request to the source station so that the source station returns a request response based on the target request; and if the value is not empty, determine whether the target request is a specific request sent by a specific client;

[0027] The second processing module is used to return the waiting page to the target client if it is not a specific request, and if it is a specific request, store the target request in the waiting queue, and when the waiting queue releases the target request, send the target request to the source station so that the source station returns a request response based on the target request.

[0028] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein, when the processor executes a computer program stored in the memory, the aforementioned disclosed method for requesting speed limiting is implemented.

[0029] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed method for requesting speed limiting is implemented.

[0030] It can be seen that the present application obtains the target request sent by the target client and determines whether the waiting queue is empty; if it is empty, the target request is sent to the source station so that the source station returns a request response based on the target request; if it is not empty, it determines whether the target request is a specific request sent by a specific client; if it is not a specific request, the waiting page is returned to the target client; if it is a specific request, the target request is stored in the waiting queue, and when the waiting queue releases the target request, the target request is sent to the source station so that the source station returns a request response based on the target request. It can be seen that when there are many requests, the present application gives priority to ensuring the normal response of the specific request sent by the specific client to ensure a better user experience for users using the specific client. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0032] Figure 1 A flow chart of a method for requesting speed limit provided by this application;

[0033] Figure 2 A specific flow chart of the request rate limit method provided for this application;

[0034] Figure 3 A schematic diagram of the structure of a request speed limit device provided in this application;

[0035] Figure 4 This is a structural diagram of an electronic device provided in this application. DETAILED DESCRIPTION

[0036] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0037] Currently, when the system QPS performance reaches the upper limit, the existing flow limiting solution may affect all user requests when there is a sudden surge in traffic, and will extend the user business processing time, resulting in a poor experience for all users.

[0038] In order to overcome the above problems, this application provides a request rate limiting solution that can ensure a better user experience.

[0039] See also Figure 1 As shown, the embodiment of the present application discloses a method for requesting speed limit, which is applied to the speed limit module. The method includes:

[0040] Step S11: Obtain the target request sent by the target client and determine whether the waiting queue is empty.

[0041] In an embodiment of the present application, it is determined whether the waiting queue is empty, that is, whether the pressure of request transmission and response is large. If the pressure is large, the target request will be stored in the waiting queue first for subsequent processing of the target request.

[0042] In an embodiment of the present application, a target client may send a static resource request. If the rate limiting module stores the static resource, the static resource can be directly returned to the target client. If the rate limiting module does not store the static resource, the static resource must be directly obtained from the source station and then returned to the target client. It should be noted that in the process of directly obtaining static resources from the source station, the static resource can be obtained directly from the source station regardless of whether the waiting queue is empty, and the static resource request does not need to be stored in the waiting queue.

[0043] Step S12: If it is empty, the target request is sent to the source station so that the source station returns a request response based on the target request. If it is not empty, it is determined whether the target request is a specific request sent by a specific client.

[0044] In an embodiment of the present application, if the waiting queue is empty, it means that the number of requests has not reached the point where a speed limit is necessary. Therefore, there is no need to determine whether the target request is a specific request sent by a specific client, and the target request can be processed directly.

[0045] In an embodiment of the present application, if the waiting queue is not empty, it indicates that there are a large number of requests and that the process of returning the response to the request needs to be speed-limited. In addition, due to the large number of requests, if all requests enter the waiting queue, the speed of returning the response to all requests will be affected. Therefore, the present application selects a specific request sent by a specific client, and guarantees the limited response to the specific request, thereby ensuring the user experience of the user using the specific client. It should be noted that if there are requests in the waiting queue, the requests in the waiting queue will be processed first.

[0046] Step S13: If it is not a specific request, the waiting page is returned to the target client; if it is a specific request, the target request is stored in the waiting queue, and when the waiting queue releases the target request, the target request is sent to the source station so that the source station returns a request response based on the target request.

[0047] In an embodiment of the present application, a specific request sent by a specific client is stored in a waiting queue so that the target request can be sent to the source station later and a request response returned by the source station based on the target request can be obtained.

[0048] In an embodiment of the present application, if it is not a specific request, the waiting page is returned to the target client. After the requests in the waiting queue are processed, the target request that is not a specific request is processed, or the target request that is not a specific request is directly discarded and the request failure page is returned.

[0049] It can be seen that the present application obtains the target request sent by the target client and determines whether the waiting queue is empty; if it is empty, the target request is sent to the source station so that the source station returns a request response based on the target request; if it is not empty, it determines whether the target request is a specific request sent by a specific client; if it is not a specific request, the waiting page is returned to the target client; if it is a specific request, the target request is stored in the waiting queue, and when the waiting queue releases the target request, the target request is sent to the source station so that the source station returns a request response based on the target request. It can be seen that when there are many requests, the present application gives priority to ensuring the normal response of the specific request sent by the specific client to ensure a better user experience for users using the specific client.

[0050] See also Figure 2As shown, the embodiment of the present application discloses a specific method for requesting speed limit, which is applied to the speed limit module. The method includes:

[0051] Step S21: Obtain the target request sent by the target client and determine whether the waiting queue is empty.

[0052] In an embodiment of the present application, before obtaining the target request sent by the target client, it also includes: obtaining the speed limit configuration issued by the business end; the speed limit configuration includes the token bucket size, the waiting queue size and the preset token addition speed; setting the token bucket and the waiting queue based on the speed limit configuration, and creating and adding tokens for the token bucket according to the preset token addition speed.

[0053] It should be noted that the speed limit configuration can also include independent configuration of key interfaces to ensure timely response to important requests. Important requests can directly obtain responses from the source station through the key interface regardless of whether the waiting queue is empty or not, without going through speed limit.

[0054] Step S22: If it is empty, allocate a new token to the target request from the token bucket, and send the target request carrying the new token to the source station, so that the source station returns a request response carrying the new token based on the target request.

[0055] In an embodiment of the present application, the target request will be stored in the waiting queue only when there is no token in the token bucket. Therefore, when the waiting queue is empty, it means that there is a token in the token bucket (indicating that the request speed has not reached the situation where speed limit is required). At this time, the target request does not need to wait, and can directly obtain a new token and send it to the source station.

[0056] It should be noted that the number of tokens in the token bucket can control the number of requests to limit the request rate; in addition, requests that must be allocated with new tokens can be sent to the source station.

[0057] Step S23: If it is not empty, determine whether the target request is a request sent by an online client that carries the original token. If so, the target request is a specific request; if not, the target request is not a specific request. Alternatively, determine whether the target request is a request sent by a newly online client that does not carry the original token. If so, the target request is a specific request; if not, the target request is not a specific request.

[0058] In the embodiment of the present application, whether the target request carries the original token is used to determine whether the client sending the request is an online client or a newly online client. In addition, a request sent by an online client carrying the original token can be regarded as a specific request sent by a specific user, and a request sent by a newly online client without the original token can be regarded as a specific request sent by a specific user.

[0059] In a specific embodiment, the successive target requests can also be directly regarded as specific requests sent by a specific client, and the specific requests can be stored in a waiting queue until the waiting queue is full. The target requests received when the waiting queue is full are discarded, and a request failure page is returned or a waiting page is returned to the target client. After the requests in the waiting queue are processed, the target requests that are not specific requests are processed.

[0060] In an embodiment of the present application, when the waiting queue is not empty, it means that the token generation speed is slower than the target request acquisition speed, and there is no token in the token bucket. At this time, it is necessary to determine the specific request from the target request so that the specific request can be processed later, and the processing of target requests that are not specific requests can be stopped to reduce the pressure of returning the request response.

[0061] Step S24: If it is not a specific request, the waiting page is returned to the target client; if it is a specific request, the target request is stored in the waiting queue, and when the waiting queue releases the target request, a new token is allocated to the target request from the token bucket, and the target request carrying the new token is sent to the source station, so that the source station returns a request response carrying the new token based on the target request; the request response carrying the new token is sent together to the target client, so that the target client sends the new request carrying the new token to the rate limiting module.

[0062] In an embodiment of the present application, specific requests will be stored in a waiting queue, and when there are tokens in the token bucket, new tokens will be allocated to the specific requests in the waiting queue in turn. Only specific requests allocated with new tokens can be sent to the source station.

[0063] In an embodiment of the present application, the new token of the target request currently obtained by the target client or the original token of the next new request of the target client, when the request sent by the target client does not carry the original token, the target client is a newly online client, when the request sent by the target client carries the original token, the target client is an already online client.

[0064] It should be pointed out that the rate limiting module will also set a validity period for the new token. When the target client obtains the request response carrying the new token, it will obtain the corresponding validity period of the new token. If the target client does not send a request to the rate limiting module within the validity period after obtaining the request response carrying the new token, the new token will become invalid. That is, the new token cannot be used as the original token for a new request sent by the target client to the rate limiting module after the validity period. At this time, the target client is considered to be a newly online client.

[0065] It should be noted that the new token carried in the request response can be encrypted or have verification information added to it. The new request also carries the same new token encrypted or with verification information added to it. The rate limit module decrypts or verifies the new token. It should be noted that the target client cannot modify the new token obtained.

[0066] In an embodiment of the present application, the method of sending the request response carrying the new token to the target client so that the target client can send the new request carrying the new token to the rate limiting module includes: storing the new token in a cookie, and sending the request response carrying the cookie to the target client so that the target client can send the new request carrying the cookie to the rate limiting module; when the rate limiting module obtains the new request carrying the cookie, it obtains the new token from the cookie as the original token of the parent request. It should be noted that the target client cannot change the obtained cookie.

[0067] It can be seen that the target request sent by the target client is obtained, and whether the waiting queue is empty is determined; if it is empty, the target request is obtained from the token, if so, the target request is a specific request, if not, the target request is not a specific request, or, it is determined whether the target request is a request sent by a newly online client without the original token, if so, the target request is a specific request, if not, the target request is not a specific request; if it is not a specific request, the waiting page is returned to the target client, if it is a specific request, the target request is stored in the waiting queue, and when the waiting queue releases the target request, a new token is allocated to the target request from the token bucket, and the target request carrying the new token is sent to the source station, so that the source station returns a request response carrying the new token based on the target request. It can be seen that the present application distinguishes whether the target request is sent by an online client or a newly online client based on whether the target request carries the original token, so as to determine the specific request sent by the specific client, and when there are many requests and the speed limit is required, the normal response of the specific request sent by the specific client is given priority to ensure a better user experience for users using the specific client.

[0068] See also Figure 3 As shown, the embodiment of the present application discloses a request speed limit device, which is applied to a speed limit module, including:

[0069] The request acquisition module 11 is used to acquire the target request sent by the target client;

[0070] A judging module 12 is used to judge whether the waiting queue is empty;

[0071] A first processing module 13 is configured to, if the value is empty, send the target request to the source station so that the source station returns a request response based on the target request; and if the value is not empty, determine whether the target request is a specific request sent by a specific client;

[0072] The second processing module 14 is used to return the waiting page to the target client if it is not a specific request, and if it is a specific request, store the target request in the waiting queue, and when the waiting queue releases the target request, send the target request to the source station so that the source station returns a request response based on the target request.

[0073] Among them, for more specific working processes of the above modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0074] It can be seen that the present application obtains the target request sent by the target client and determines whether the waiting queue is empty; if it is empty, the target request is sent to the source station so that the source station returns a request response based on the target request; if it is not empty, it determines whether the target request is a specific request sent by a specific client; if it is not a specific request, the waiting page is returned to the target client; if it is a specific request, the target request is stored in the waiting queue, and when the waiting queue releases the target request, the target request is sent to the source station so that the source station returns a request response based on the target request. It can be seen that when there are many requests, the present application gives priority to ensuring the normal response of the specific request sent by the specific client to ensure a better user experience for users using the specific client.

[0075] In a specific embodiment, the first processing module 13 and the second processing module 14 include:

[0076] a target request sending unit, configured to allocate a new token to the target request from a token bucket, and send the target request carrying the new token to a source station, so that the source station returns a request response carrying the new token based on the target request;

[0077] In a specific embodiment, the request speed limit device further includes:

[0078] A speed limit configuration acquisition unit is used to obtain the speed limit configuration issued by the service end; the speed limit configuration includes the token bucket size, the waiting queue size and the preset token addition speed;

[0079] A configuration setting unit, configured to set the token bucket and the waiting queue based on the rate limit configuration, and to create and add tokens to the token bucket according to the preset token addition speed;

[0080] In a specific embodiment, the judgment module 12 includes:

[0081] A first judging unit is configured to judge whether the target request is a request carrying an original token sent by an online client, if so, the target request is a specific request, and if not, the target request is not a specific request;

[0082] In a specific embodiment, the judgment module 12 includes:

[0083] a second determining unit, configured to determine whether the target request is a request sent by a newly online client without carrying an original token, if so, the target request is a specific request, and if not, the target request is not a specific request;

[0084] The target request sending unit specifically includes:

[0085] a target request sending subunit, configured to allocate a new token for the target request from a token bucket, and send the target request carrying the new token to a source station, so that the source station returns a request response carrying the new token based on the target request;

[0086] a response sending unit, configured to send the request response carrying the new token to the target client, so that the target client sends a new request carrying the new token to the rate limiting module;

[0087] In a specific embodiment, the response sending unit includes:

[0088] The response sending subunit is used to store the new token in a cookie and send the request response carrying the cookie to the target client, so that the target client sends the new request carrying the cookie to the rate limiting module.

[0089] Furthermore, an embodiment of the present application also provides an electronic device, Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.

[0090] Figure 4 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, an input / output interface 24, a communication interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps of the method for requesting a rate limit disclosed in any of the aforementioned embodiments.

[0091] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 24 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0092] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The memory 22 can include a random access memory as a running memory and a non-volatile memory for storage purposes of an external memory. The storage resources thereon include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0093] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 on the source host, as well as the computer program 222. The operating system 221 can be Windows, Unix, Linux, etc. In addition to including a computer program capable of implementing the request rate limit method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs capable of performing other specific tasks.

[0094] In this embodiment, the input and output interface 24 may specifically include but is not limited to a USB interface, a hard disk reading interface, a serial interface, a voice input interface, a fingerprint input interface, and the like.

[0095] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed method for requesting speed limiting is implemented.

[0096] For the specific steps of this method, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0097] The computer-readable storage medium referred to herein includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, magnetic disks, or optical disks, or any other form of storage medium known in the art. The computer program, when executed by a processor, implements the aforementioned request rate limit method. For the specific steps of this method, reference can be made to the corresponding content disclosed in the aforementioned embodiments, and no further details will be given here.

[0098] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from the other embodiments. For the identical or similar parts between the various embodiments, reference can be made to each other. For the device disclosed in the embodiments, since it corresponds to the request rate limit method disclosed in the embodiments, the description is relatively simple. For relevant parts, refer to the method description.

[0099] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0100] The steps of the algorithms described in conjunction with the embodiments disclosed herein can be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0101] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0102] The above describes in detail a method, apparatus, device, and medium for requesting a rate limit provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only intended to help understand the method and core concept of the present invention. At the same time, for those skilled in the art, according to the concept of the present invention, there may be changes in the specific implementation methods and application scope. In summary, the contents of this specification should not be understood as limiting the present invention.

Claims

1. A method for requesting a rate limit, characterized in that: Applicable to the speed limit module, including: Get the target request sent by the target client and determine whether the waiting queue is empty; If it is empty, the target request is sent to the source station so that the source station returns a request response based on the target request; if it is not empty, it is determined whether the target request is a specific request sent by a specific client; If it is not a specific request, returning a waiting page to the target client; if it is a specific request, storing the target request in the waiting queue, and when the waiting queue releases the target request, sending the target request to the source station, so that the source station returns a request response based on the target request; The step of determining whether the target request is a specific request sent by a specific client includes: Determine whether the target request is a request that has been sent by an online client and carries the original token. If so, the target request is a specific request; if not, the target request is not a specific request. The step of determining whether the target request is a specific request sent by a specific client includes: It is determined whether the target request is a request sent by a newly online client without carrying the original token. If so, the target request is a specific request; otherwise, the target request is not a specific request.

2. The method for requesting rate limiting according to claim 1, wherein: The sending the target request to the source station so that the source station returns a request response based on the target request includes: A new token is allocated to the target request from a token bucket, and the target request carrying the new token is sent to the source station, so that the source station returns a request response carrying the new token based on the target request.

3. The method for requesting speed limit according to claim 2, wherein: Before obtaining the target request sent by the target client, the method further includes: Obtain the speed limit configuration issued by the service end; the speed limit configuration includes the token bucket size, waiting queue size and preset token addition speed; The token bucket and the waiting queue are set based on the rate limit configuration, and tokens are created and added to the token bucket according to the preset token addition speed.

4. The method for requesting speed limit according to claim 2 or 3, wherein: Allocating a new token for the target request from a token bucket, and sending the target request carrying the new token to a source station, so that the source station returns a request response carrying the new token based on the target request, includes: Allocate a new token for the target request from a token bucket, and send the target request carrying the new token to the source station, so that the source station returns a request response carrying the new token based on the target request; The request response carrying the new token is sent together to the target client, so that the target client sends a new request carrying the new token to the rate limiting module.

5. The method for requesting speed limit according to claim 4, wherein: The step of sending the request and response carrying the new token to the target client together, so that the target client sends a new request carrying the new token to the rate limiting module, includes: The new token is stored in a cookie, and the request response carrying the cookie is sent to the target client, so that the target client sends a new request carrying the cookie to the rate limiting module.

6. A speed limit request device, characterized in that: Applicable to the speed limit module, including: The request acquisition module is used to obtain the target request sent by the target client; A judgment module is used to judge whether the waiting queue is empty; A first processing module is configured to, if the value is empty, send the target request to the source station so that the source station returns a request response based on the target request; and if the value is not empty, determine whether the target request is a specific request sent by a specific client; a second processing module, configured to return a waiting page to the target client if the request is not a specific request, and to store the target request in the waiting queue if the request is a specific request, and to send the target request to the source station when the waiting queue releases the target request, so that the source station returns a request response based on the target request; The first processing module is specifically configured to determine whether the target request is a request carrying an original token sent by an online client, if so, the target request is a specific request, and if not, the target request is not a specific request; Among them, the first processing module is specifically further used to determine whether the target request is a request sent by a newly online client without carrying the original token. If so, the target request is a specific request; if not, the target request is not a specific request.

7. An electronic device, characterized in that: The method comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the method for requesting speed limit according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium, characterized in that Used to store a computer program; wherein, when the computer program is executed by a processor, the method for requesting speed limit according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Third-party service integration method and device, equipment and storage medium

    CN113742109A

  • Including prior request performance information in requests to schedule subsequent request performance

    US11032392B1