Current limiting method, current limiting device and electronic equipment for service request

By obtaining the number of on-the-go requests and blocking rate of the backend service and dynamic current limit service requests, the problem of poor flexibility of the existing current limiting algorithm is solved, and the accurate and real-time limiting of service requests is achieved to avoid the service being dragged down.

CN116260875BActive Publication Date: 2024-11-01PEOPLE'S INSURANCE COMPANY OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211102110.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-09
Publication Date
2024-11-01
Estimated Expiration
2042-09-09

AI Technical Summary

Technical Problem

The existing current limiting algorithm has poor flexibility and cannot effectively respond to high concurrency scenarios of service requests, resulting in the possibility of service being dragged down.

Method used

By obtaining the number of on-road requests of the backend service when the front-end service interacts with the back-end service, the blocking rate is obtained based on the correspondence between the number of on-road requests and the blocking rate, and the service requests are dynamically restricted in real time to ensure that the back-end service is not Drag down.

Benefits of technology

It realizes the flow limit of service requests accurately, in real time and dynamically based on the processing capabilities of the back-end service, to prevent the service from being dragged down, and to ensure that requests that cannot be processed safely return to the front-end in a timely manner.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116260875B_ABST
    Figure CN116260875B_ABST
Patent Text Reader

Abstract

The present application discloses a flow limiting method, flow limiting device and electronic device for service requests, belonging to the field of communication technology. The flow limiting method for service requests comprises: obtaining a target number of requests for a backend service, wherein the target number of requests is the number of in-transit requests for the backend service when a frontend service interacts with the backend service for the Nth time, and N is an integer greater than 0; obtaining a first blocking rate corresponding to the target number of requests according to a corresponding relationship between the number of in-transit requests and a blocking rate; and when the first blocking rate is obtained, limiting the flow of the frontend service requests according to the first blocking rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a current limiting method, a current limiting device and an electronic device for a service request. Background Art

[0002] With the development of Internet technology and the rapid growth of business volume, services frequently encounter high-concurrency scenarios, which bring huge processing pressure to the services. In order to prevent the services from being dragged down by requests that exceed their own processing capabilities, it is necessary to limit the flow of service requests.

[0003] However, most of the current flow limiting algorithms are based on the performance evaluation before going online to determine the flow limiting threshold, and then limit the flow of service requests based on the flow limiting threshold, which is less flexible. Therefore, there is currently no relatively complete solution for the flow limiting of service requests. Summary of the invention

[0004] The present application discloses a method for limiting the flow of service requests, a current limiting device and an electronic device, so as to solve the problem that there is no relatively complete solution for the current limiting of service requests.

[0005] In order to solve the above problems, this application adopts the following technical solutions:

[0006] In a first aspect, an embodiment of the present application discloses a method for limiting the flow of service requests, comprising: obtaining a target number of requests for a backend service, wherein the target number of requests is the number of in-transit requests for the backend service when the front-end service interacts with the back-end service for the Nth time, and N is an integer greater than 0; according to the correspondence between the number of in-transit requests and the blocking rate, obtaining a first blocking rate corresponding to the target number of requests; when the first blocking rate is obtained, limiting the flow of the front-end service requests according to the first blocking rate.

[0007] In a second aspect, an embodiment of the present application discloses a flow limiting device for service requests, comprising: a first acquisition module, used to obtain a target number of requests for a backend service, wherein the target number of requests is the number of in-transit requests for the backend service when the front-end service interacts with the back-end service for the Nth time, and N is an integer greater than 0; a second acquisition module, used to obtain a first blocking rate corresponding to the target number of requests based on the correspondence between the number of in-transit requests and the blocking rate; a flow limiting module, used to limit the flow of the front-end service requests according to the first blocking rate when the first blocking rate is obtained.

[0008] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0009] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0010] An embodiment of the present application provides a method for limiting the flow of service requests, by obtaining the target number of requests for the backend service when the front-end service and the back-end service interact for the Nth time, and obtaining a first blocking rate corresponding to the target number of requests according to the corresponding relationship between the number of in-transit requests and the blocking rate. When the first blocking rate is obtained, the front-end service requests are limited according to the first blocking rate. The method can accurately, real-time and dynamically limit the flow of service requests according to the processing capacity of the back-end service, ensuring that requests that cannot be safely processed are returned to the front end in a timely manner, thereby solving the problem that there is currently no relatively complete solution to the flow limiting of service requests. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 A flow chart of a method for limiting the flow of a service request disclosed in an embodiment of the present application;

[0012] Figure 2 A flow chart of a service request flow limiting disclosed in an embodiment of the present application;

[0013] Figure 3 A flow chart of a current limiting calculation disclosed in an embodiment of the present application;

[0014] Figure 4 A flowchart of the calculation logic of the in-transit request current limiting strategy disclosed in an embodiment of the present application;

[0015] Figure 5 A flowchart of the calculation logic of the dynamic adjustment current limiting strategy disclosed in the embodiment of the present application;

[0016] Figure 6 A schematic diagram of the structure of a current limiting device for a service request disclosed in an embodiment of the present application;

[0017] Figure 7 A schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0018] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0019] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the electrically connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0020] In conjunction with the accompanying drawings, the current limiting method, current limiting device and electronic device for the service request disclosed in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.

[0021] Figure 1 FIG. 1 is a flow chart of a method for limiting the flow of a service request disclosed in an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:

[0022] S120: Obtain the target number of requests for the backend service.

[0023] The target number of requests is the number of in-transit requests of the backend service when the frontend service interacts with the backend service for the Nth time, and N is an integer greater than 0. The number of in-transit requests indicates the number of requests being processed by the backend service, that is, the number of in-transit requests of the backend service is the number of requests received by the backend service minus the number of requests already processed by the backend service. It should be noted that the Nth interaction between the frontend service and the backend service may be the latest interaction between the frontend service and the backend service.

[0024] In one implementation, the system obtains the target number of requests for the backend service from the latest in-transit request information of the service in Redis. The backend service may be a service in one region of the national region queue.

[0025] S140. Obtain a first blocking rate corresponding to the target number of requests according to a corresponding relationship between the number of in-transit requests and the blocking rate.

[0026] The flow limiting policy data of the pre-configured in-transit request flow limiting policy includes multiple sets of correspondences between the number of in-transit requests and the blocking rate. For example, the number of in-transit requests A corresponds to the blocking rate A1, the number of in-transit requests B corresponds to the blocking rate B1, and the number of in-transit requests C corresponds to the blocking rate C1. When the target number of requests for the back-end service obtained is D, D is compared with the number of in-transit requests in the flow limiting policy data in a loop. If D matches B, that is, the range corresponding to B includes D, or D=B, then the blocking rate corresponding to the target number of requests D is determined to be B1. If the cycle is completed and D does not match the number of in-transit requests in the flow limiting policy data, it is determined that the front-end service requests will not be limited temporarily according to the in-transit request flow limiting policy.

[0027] It should be noted that the blocking rate is the ratio of the number of requests that need to be blocked to the total number of requests.

[0028] S160: When the first blocking rate is obtained, limit the flow of the front-end service request according to the first blocking rate.

[0029] When the target number of requests for the backend service matches the number of in-transit requests in the flow limiting policy data of the in-transit request flow limiting policy, that is, when the first blocking rate can be obtained, the frontend service request is flow limited according to the first blocking rate, and the frontend service is controlled to slow down the request sending when the backend service load is large, so as to avoid the backend service being dragged down by requests that exceed its own processing capacity, and ensure that the requests that cannot be safely processed are returned to the frontend in time. In addition, when it is necessary to flow limit the frontend service request, it can be prompted that the frontend request service is busy and please try again later.

[0030] Furthermore, when the front-end service request is current limited according to the first blocking rate, the current limiting state information in Redis is set, and a log request for recording the current limiting event is pushed to the log processing queue.

[0031] An embodiment of the present application provides a method for limiting the flow of service requests, by obtaining the target number of requests for the backend service when the front-end service and the back-end service interact for the Nth time, and obtaining a first blocking rate corresponding to the target number of requests according to the corresponding relationship between the number of in-transit requests and the blocking rate. When the first blocking rate is obtained, the front-end service requests are limited according to the first blocking rate. The method can accurately, real-time and dynamically limit the flow of service requests according to the processing capacity of the back-end service, ensuring that requests that cannot be safely processed are returned to the front end in a timely manner, thereby solving the problem that there is currently no relatively complete solution to the flow limiting of service requests.

[0032] In the embodiment of the present application, after obtaining the first blocking rate corresponding to the target number of requests, the method may further include: if the first blocking rate cannot be obtained, obtaining the first number of requests, the second number of requests, the first service request response time, and the second service request response time, wherein the first number of requests is the number of in-transit requests of the backend service when the front-end service interacts with the backend service for the (N-1)th time, the second number of requests is the average number of in-transit requests of the backend service when the front-end service interacts with the backend service for the first (N-2)th time, and the first service request response time is the average number of in-transit requests of the backend service when the front-end service interacts with the backend service for the first (N-3)th time. -1) the request response time of the backend service during the first (N-2) interactions between the front-end service and the back-end service, the second service request response time being the average of the request response times of the back-end service during the first (N-2) interactions between the front-end service and the back-end service; determining the target service request response time according to the target number of requests, the first number of requests, the second number of requests, the first service request response time and the second service request response time; obtaining the second blocking rate corresponding to the target service request response time according to the correspondence between the service request response time and the blocking rate; in the case of obtaining the second blocking rate, limiting the flow of the front-end service request according to the second blocking rate. The present application determines the second blocking rate according to the target service request response time of the back-end service, and then limits the flow of the front-end service request according to the second blocking rate, which can accurately, in real time and dynamically ensure that the back-end service will not be dragged down by the front-end request, and at the same time ensure that the requests that cannot be safely processed are returned to the front-end in a timely manner.

[0033] In addition, in an embodiment of the present application, when a first blocking rate corresponding to the target number of requests for the backend service is obtained based on the correspondence between the number of in-transit requests and the blocking rate, the front-end service requests are limited according to the first blocking rate; when the first blocking rate cannot be obtained, the target service request response time of the back-end service is determined based on the target number of requests, the first number of requests, the second number of requests, the first service request response time, and the second service request response time; then, based on the correspondence between the service request response time and the blocking rate, the second blocking rate corresponding to the target service request response time is obtained; when the second blocking rate is obtained, the front-end service requests are limited according to the second blocking rate, which can take into account both controlling sudden high-concurrency requests and comprehensively evaluating the real-time processing capabilities of the back-end services, thereby increasing the applicable scenarios and limiting effects of the limiting strategy.

[0034] It should be noted that the first request quantity, the second request quantity, the first service request response time, and the second service request response time can be obtained by the system based on the historical in-transit data read from the service in-transit request information queue at the calculation time point of Redis. The target service request response time can be the predicted service request response time of the backend service when the frontend service and the backend service interact for the Nth time.

[0035] The pre-set dynamic adjustment flow limiting strategy data includes multiple groups of correspondences between service request response times and blocking rates. For example, the service request response time E corresponds to the blocking rate E1, the service request response time F corresponds to the blocking rate F1, and the service request response time G corresponds to the blocking rate G1. When the target service request response time is determined to be H, H is compared with the service request response time in the flow limiting strategy data in a loop. If H matches E, that is, the response time range corresponding to E includes H, or H=E, then the blocking rate corresponding to the target service request response time H is determined to be E1. If the cycle is completed and H does not match the service request response time in the flow limiting strategy data, it is determined that the front-end service request will not be limited according to the dynamically adjusted flow limiting strategy.

[0036] When limiting the flow of front-end service requests, a flow limiting identifier and a flow limiting type are set for the service request, and the flow limiting identifier and the flow limiting type set for the service request are stored in Redis. It should be noted that the flow limiting type can be set to automatic flow limiting to distinguish manual flow limiting.

[0037] In an embodiment of the present application, determining the target service request response duration based on the target request quantity, the first request quantity, the second request quantity, the first service request response duration, and the second service request response duration may include: judging whether the first request quantity is equal to the second request quantity; if the first request quantity is not equal to the second request quantity, determining a concurrent response duration influence coefficient based on the first request quantity, the second request quantity, the first service request response duration, and the second service request response duration; determining the target service request response duration based on the second service request response duration, the concurrent response duration influence coefficient, the target request quantity, and the second request quantity.

[0038] In one implementation, determining the concurrent response time impact coefficient based on the first request number, the second request number, the first service request response time and the second service request response time may include: determining the concurrent response time impact coefficient by the following formula; R = |(D2-D1) / (P2-P1)|; wherein R is the concurrent response time impact coefficient, D1 is the first service request response time, D2 is the second service request response time, P1 is the first request number, and P2 is the second request number.

[0039] In one implementation, determining the target service request response time based on the second service request response time, the concurrent response time influence coefficient, the target request number and the second request number may include: determining the target service request response time by the following formula; D3=D2+R*|(P3-P2)|; wherein D3 is the target service request response time, and P3 is the target request number.

[0040] In an embodiment of the present application, after determining whether the first request number is equal to the second request number, the following may also be included: when the first request number is equal to the second request number, determining a concurrent response duration change rate according to the first service request response duration and the second service request response duration; determining a third service request response duration according to the second service request response duration, the target request number and the second request number; determining the target service request response duration according to the concurrent response duration change rate and the third service request response duration.

[0041] In one implementation, determining the concurrent response duration change rate based on the first service request response duration and the second service request response duration may include: determining the concurrent response duration change rate by the following formula; Dc = |(D2-D1) / D1|; wherein Dc is the concurrent response duration change rate, D1 is the first service request response duration, and D2 is the second service request response duration.

[0042] In one implementation, determining the third service request response time according to the second service request response time, the target request number and the second request number may include: determining the third service request response time by the following formula; LD3 = D2*P3 / P2; wherein LD3 is the third service request response time, P2 is the second request number, and P3 is the target request number. It should be noted that the third service request response time is the request response time that the backend service should take when the front-end service and the backend service interact for the Nth time under the premise that the performance remains unchanged.

[0043] In one implementation, determining the target service request response duration according to the concurrent response duration change rate and the third service request response duration may include: determining the target service request response duration by the following formula; D3 = (1 + Dc) * LD3; wherein D3 is the target service request response duration. It should be noted that the target service request response duration is the request response duration of the backend service when the frontend service and the backend service interact for the Nth time, with the influence of the concurrent response duration change rate superimposed.

[0044] In an embodiment of the present application, after obtaining the second blocking rate corresponding to the response time of the target service request, it may also include: if the second blocking rate cannot be obtained, not limiting the flow of requests to the front-end service, and setting the Redis flow limiting flag to no flow limiting.

[0045] In the embodiment of the present application, before obtaining the target number of requests for the backend service, it may also include: receiving the correspondence between the number of in-transit requests and the blocking rate input externally; and receiving the correspondence between the service request response time and the blocking rate input externally.

[0046] Exemplarily, the query conditions for querying the current limiting records can be received, and the system queries the corresponding current limiting policy configuration data and the current limiting data without policy configuration (need to be summarized according to the service) from the PG database and displays them. The displayed content also includes the "integrity check" control, the "maintain the current limiting policy for in-transit requests" control, and the "maintain the dynamic adjustment current limiting policy" control. When receiving the operation of clicking the "integrity check" control, the system performs an integrity check on the configured current limiting policies that have been queried to ensure that each service route is configured with a dual current limiting policy including the in-transit request current limiting policy and the dynamic adjustment current limiting policy, that is, to ensure that the corresponding relationship between the number of in-transit requests and the blocking rate and the corresponding relationship between the service request response time and the blocking rate are configured. When receiving the operation of clicking the "Maintain In-Transit Request Limiting Strategy" control, the in-transit request limiting strategy configuration interface is displayed, and the external input adjustment operation of the corresponding relationship between the number of in-transit requests and the blocking rate is received, for example, the corresponding relationship between the number of in-transit requests and the blocking rate is received, the corresponding relationship between the number of in-transit requests and the blocking rate is modified, the corresponding relationship between the number of in-transit requests and the blocking rate is deleted, and the adjusted corresponding relationship between the number of in-transit requests and the blocking rate is updated to the PG database. When receiving the operation of clicking the "Maintain Dynamic Adjustment Limiting Strategy" control, the dynamic adjustment limit strategy configuration interface is displayed, and the external input adjustment operation of the corresponding relationship between the service request response time and the blocking rate is received, for example, the corresponding relationship between the service request response time and the blocking rate is received, the corresponding relationship between the service request response time and the blocking rate is modified, the corresponding relationship between the service request response time and the blocking rate is deleted, and the adjusted corresponding relationship between the service request response time and the blocking rate is updated to the PG database.

[0047] It should be noted that there are multiple sets of correspondences between the number of configured in-transit requests and the blocking rate, and there are multiple sets of correspondences between the configured service request response time and the blocking rate. The correspondences between the number of configured in-transit requests and the blocking rate for different services may be different, and the correspondences between the service request response time and the blocking rate for different services may be different.

[0048] In an embodiment of the present application, before obtaining the first blocking rate corresponding to the target number of requests based on the correspondence between the number of in-transit requests and the blocking rate, it may also include: determining whether the target number of requests is equal to a third number of requests, wherein the third number of requests is the average number of in-transit requests of the backend service during the first (N-1) interactions between the front-end service and the backend service; if the target number of requests is not equal to the third number of requests, the backend service is written into the current limiting logic processing queue. According to the correspondence between the number of in-transit requests and the blocking rate, obtaining the first blocking rate corresponding to the target number of requests may include: obtaining the backend service from the current limiting logic processing queue; obtaining the target number of requests corresponding to the backend service; and obtaining the first blocking rate corresponding to the target number of requests based on the correspondence between the number of in-transit requests and the blocking rate.

[0049] That is to say, before performing the current limiting calculation, it can be determined whether the backend service needs to perform the current limiting calculation. Specifically, it is determined whether the target number of requests for the backend service during the Nth interaction between the frontend service and the backend service is equal to the average number of in-transit requests for the backend service during the previous (N-1) interactions between the frontend service and the backend service, that is, whether the target number of requests is equal to the third number of requests. When the target number of requests for the backend service is not equal to the third number of requests, it is determined that the backend service needs to perform the current limiting calculation, and the backend service is written into the current limiting logic processing queue of Redis. When performing the current limiting calculation, a list of services that need to perform the current limiting calculation is obtained from the current limiting logic processing queue of Redis, and the service list includes the backend service described above. Then, the target number of requests corresponding to the backend service is obtained, and the first blocking rate corresponding to the target number of requests is obtained according to the corresponding relationship between the number of in-transit requests and the blocking rate. When the first blocking rate is obtained, the frontend service request is current limited according to the first blocking rate.

[0050] It should be noted that the national regional queue includes multiple regions. The backend service can be a service in one region of the national regional queue. The system obtains a service in one region from the national regional queue for processing and determines whether the service needs to be limited. If the system cannot obtain data from the national regional queue, it means that the data in the national regional queue has been consumed, and the national regional polling completion mark data in Redis is reset. When obtaining services from the current limiting logic processing queue, if no data is obtained, read the national regional polling completion mark in Redis. If the mark is not completed (0), this stage is completed. If the mark is completed (1), change the national regional polling completion mark to not completed (0), and re-initialize the data of the national regional queue in Redis.

[0051] In addition, to maximize the operating performance, cluster deployment can be used, with multiple cluster nodes obtaining services from a region in parallel from the national regional queue for processing, and multiple cluster nodes obtaining services from the current limiting logic processing queue for current limiting calculation. At the same time, this application adopts the no-access automatic sleep mode to reduce the overall resource consumption of the application.

[0052] In addition, in this application, the front-end request and back-end response information are collected in an asynchronous processing mode (both the front-end request and the back-end response information are pushed to the queue), which can decouple the front-end processing main logic and avoid the impact of the current limiting processing logic on the front-end service request processing time.

[0053] The flow limiting process of the service request disclosed in this application is explained below.

[0054] like Figure 2 As shown, determine whether the service needs to perform current limiting calculation: S1.1 The cluster node obtains a region from the national regional queue for processing; S1.2 Obtain the current in-transit data of the regional service (i.e., the target number of requests mentioned above); S1.3 Obtain the last in-transit data of the regional service (i.e., the third number of requests mentioned above); S1.4 Write the current in-transit data into the service in-transit request information queue at the calculation time point of Redis; S1.5 When the current in-transit data is not equal to the last in-transit data, form a list of services that need current limiting calculation and write it into the current limiting logic processing queue. Trigger current limiting calculation: S2.1 The node obtains the list of services that need current limiting calculation from the current limiting logic processing queue for current limiting calculation; S2.2 If no data can be read in the current limiting logic processing queue (i.e., the current limiting logic queue data is empty), read the national regional polling completion flag; S2.3 If the national regional queue polling completion flag is 1, reinitialize the national regional queue; S2.4 If the national regional queue polling completion flag is 1, change it to 0.

[0055] The current limiting calculation process is as follows Figure 3As shown, the service that needs current limiting calculation is obtained from the current limiting logic processing queue, and the current limiting logic judgment calculation of the in-transit request current limiting strategy is first performed on the service. When it is determined that the current limiting is performed according to the in-transit request current limiting strategy, the current limiting information (i.e., the first blocking rate obtained according to the in-transit request current limiting strategy) is set, and the current limiting event information is pushed to the log queue. When it is determined that the current limiting is not performed according to the in-transit request current limiting strategy, the current limiting logic judgment calculation of the dynamic adjustment current limiting strategy is continued. When it is determined that the current limiting is performed according to the dynamic adjustment current limiting strategy, the current limiting information (i.e., the second blocking rate obtained according to the dynamic adjustment current limiting strategy) is set, and the current limiting event information is pushed to the log queue. When it is determined that the current limiting is not performed according to the dynamic adjustment current limiting strategy, the cancellation current limiting information is set, and the current limiting event information is pushed to the log queue. It should be noted that the above-mentioned setting of current limiting information or setting of cancellation of current limiting information requires writing Redis data.

[0056] The calculation logic of the in-transit request flow limiting strategy is as follows Figure 4 As shown, the current in-transit data of the service (i.e., the target number of requests mentioned above) is obtained, the in-transit request current limiting strategy is obtained from the global variable (i.e., the corresponding relationship between the number of in-transit requests and the blocking rate is obtained), and the strategy matching is performed in a loop. When the first blocking rate corresponding to the target number of requests is matched, the matching current limiting information (i.e., the first blocking rate) is returned. After the loop is completed and the first blocking rate corresponding to the target number of requests is not matched, the current limiting logic judgment calculation of the dynamic adjustment of the current limiting strategy is continued.

[0057] The calculation logic of dynamically adjusting the current limiting strategy is as follows Figure 5As shown, the current in-transit data of the service (i.e., the target number of requests mentioned above), the first number of requests, the second number of requests, the first service request response time, and the second service request response time are obtained, and it is determined whether the first number of requests is equal to the second number of requests. In the case that the first number of requests is not equal to the second number of requests, a concurrent response time influence coefficient is determined according to the first number of requests, the second number of requests, the first service request response time, and the second service request response time. The target service request response time is determined according to the second service request response time, the concurrent response time influence coefficient, the target number of requests, and the second number of requests. In the case that the first number of requests is equal to the second number of requests, a concurrent response time influence coefficient is determined according to the first service request. The response time and the second service request response time are used to determine the change rate of the concurrent response time; the third service request response time is determined according to the second service request response time, the target request number and the second request number; the target service request response time is determined according to the change rate of the concurrent response time and the third service request response time, and the dynamic adjustment current limiting strategy is obtained from the global variable (that is, the correspondence between the service request response time and the blocking rate is obtained), and the strategy matching is performed in a loop. When the second blocking rate corresponding to the target service request response time is matched, the matching current limiting information (that is, the second blocking rate) is returned. After the loop is completed and the second blocking rate corresponding to the target service request response time is not matched, the current limiting information is set to be cancelled.

[0058] The current limiting method for service requests provided in the embodiment of the present application can be performed by a current limiting device for service requests. The current limiting method for service requests performed by a current limiting device for service requests is taken as an example to illustrate the current limiting device for service requests provided in the embodiment of the present application.

[0059] Figure 6 This is a schematic diagram of the structure of a current limiting device for a service request disclosed in an embodiment of the present application. Figure 6 As shown, the current limiting device 600 for service request includes: a first acquisition module 610 , a second acquisition module 620 and a current limiting module 630 .

[0060] In the present application, the first acquisition module 610 is used to obtain the target number of requests for the backend service, wherein the target number of requests is the number of in-transit requests for the backend service when the front-end service interacts with the back-end service for the Nth time, and N is an integer greater than 0; the second acquisition module 620 is used to obtain a first blocking rate corresponding to the target number of requests based on the correspondence between the number of in-transit requests and the blocking rate; the current limiting module 630 is used to limit the current of the front-end service requests according to the first blocking rate when the first blocking rate is obtained.

[0061] In one implementation, the current limiting device also includes: the first acquisition module 610, which is also used to obtain the first request number, the second request number, the first service request response time and the second service request response time after the first blocking rate corresponding to the target request number is obtained, if the first blocking rate cannot be obtained, wherein the first request number is the number of in-transit requests of the backend service when the front-end service interacts with the back-end service for the (N-1)th time, the second request number is the average number of in-transit requests of the back-end service when the front-end service interacts with the back-end service for the first (N-2)th time, and the first service request response time is the average number of in-transit requests of the back-end service when the front-end service interacts with the back-end service for the first (N-1)th time. The request response time of the backend service, the second service request response time is the average of the request response times of the backend service during the previous (N-2) interactions between the front-end service and the back-end service; a determination module is used to determine the target service request response time according to the target number of requests, the first number of requests, the second number of requests, the first service request response time and the second service request response time; the second acquisition module 620 is also used to obtain the second blocking rate corresponding to the target service request response time according to the corresponding relationship between the service request response time and the blocking rate; the current limiting module 630 is also used to limit the current of the front-end service request according to the second blocking rate when the second blocking rate is obtained.

[0062] In one implementation, the determination module determines the target service request response time based on the target request number, the first request number, the second request number, the first service request response time, and the second service request response time, including: judging whether the first request number is equal to the second request number; when the first request number is not equal to the second request number, determining a concurrent response time influence coefficient based on the first request number, the second request number, the first service request response time, and the second service request response time; determining the target service request response time based on the second service request response time, the concurrent response time influence coefficient, the target request number, and the second request number.

[0063] In one implementation, the determination module is also used to: after determining whether the first request number is equal to the second request number, if the first request number is equal to the second request number, determine the concurrent response duration change rate according to the first service request response duration and the second service request response duration; determine the third service request response duration according to the second service request response duration, the target request number and the second request number; determine the target service request response duration according to the concurrent response duration change rate and the third service request response duration.

[0064] In one implementation, the current limiting module 630 is further configured to, after obtaining the second blocking rate corresponding to the target service request response duration, not limit the current of the front-end service request if the second blocking rate cannot be obtained.

[0065] In one implementation, the current limiting device also includes: a receiving module, which is used to receive the correspondence between the number of in-transit requests and the blocking rate input externally before obtaining the target number of requests for the back-end service; the receiving module is also used to receive the correspondence between the service request response time and the blocking rate input externally.

[0066] In one implementation, the current limiting device also includes: a judgment module, which is used to judge whether the target request number is equal to a third request number before obtaining the first blocking rate corresponding to the target request number according to the correspondence between the number of in-transit requests and the blocking rate, wherein the third request number is the average number of in-transit requests of the backend service during the first (N-1) interactions between the front-end service and the backend service; a writing module, which is used to write the backend service into the current limiting logic processing queue when the target request number is not equal to the third request number; the second acquisition module 620 obtains the first blocking rate corresponding to the target request number according to the correspondence between the number of in-transit requests and the blocking rate, including: obtaining the backend service from the current limiting logic processing queue; obtaining the target request number corresponding to the backend service; and obtaining the first blocking rate corresponding to the target request number according to the correspondence between the number of in-transit requests and the blocking rate.

[0067] The service request current limiting device provided in the embodiment of the present application can implement each process implemented in the embodiment of the service request current limiting method, and will not be described again here to avoid repetition.

[0068] Alternatively, if Figure 7As shown, an embodiment of the present application also provides an electronic device 700, including a processor 701 and a memory 702, and the memory 702 stores a program or instruction that can be executed on the processor 701. When the program or instruction is executed by the processor 701, the various steps of the current limiting method embodiment of the above-mentioned service request are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0069] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0070] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the current limiting method embodiment of the above-mentioned service request is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0071] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0072] The above embodiments of the present application focus on describing the differences between the various embodiments. As long as the different optimization features between the various embodiments are not contradictory, they can be combined to form a better embodiment. Considering the simplicity of the text, they will not be repeated here.

[0073] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A method for limiting the flow of service requests, characterized in that: include: Obtaining a target number of requests for the backend service, wherein the target number of requests is the number of in-transit requests for the backend service when the frontend service interacts with the backend service for the Nth time, and N is an integer greater than 0; According to the corresponding relationship between the number of in-transit requests and the blocking rate, obtaining a first blocking rate corresponding to the target number of requests; When the first blocking rate is obtained, limiting the flow of the front-end service request according to the first blocking rate; The obtaining, according to the correspondence between the number of in-transit requests and the blocking rate, a first blocking rate corresponding to the target number of requests includes: Obtain the backend service from the current limiting logic processing queue; Obtaining the target request quantity corresponding to the backend service; According to the corresponding relationship between the number of in-transit requests and the blocking rate, obtaining a first blocking rate corresponding to the target number of requests; After obtaining the first blocking rate corresponding to the target number of requests, the method further includes: If the first blocking rate cannot be obtained, obtain the first request number, the second request number, the first service request response time, and the second service request response time, wherein the first request number is the number of in-transit requests of the backend service during the (N-1)th interaction between the front-end service and the backend service, the second request number is the average number of in-transit requests of the backend service during the first (N-2) interactions between the front-end service and the backend service, the first service request response time is the request response time of the backend service during the (N-1)th interaction between the front-end service and the backend service, and the second service request response time is the average value of the request response time of the backend service during the first (N-2) interactions between the front-end service and the backend service; Determine a target service request response time according to the target request quantity, the first request quantity, the second request quantity, the first service request response time, and the second service request response time; According to the corresponding relationship between the service request response time and the blocking rate, obtaining a second blocking rate corresponding to the target service request response time; When the second blocking rate is obtained, limiting the flow of the front-end service request according to the second blocking rate; When the second blocking rate cannot be obtained, the request for the front-end service is not limited, and the current limiting flag of Redis is set to no current limiting.

2. The current limiting method according to claim 1, characterized in that: The determining a target service request response duration according to the target request quantity, the first request quantity, the second request quantity, the first service request response duration, and the second service request response duration includes: Determining whether the first request quantity is equal to the second request quantity; In the case where the first request number is not equal to the second request number, determining a concurrent response duration impact coefficient according to the first request number, the second request number, the first service request response duration, and the second service request response duration; The target service request response time is determined according to the second service request response time, the concurrent response time influence coefficient, the target request quantity and the second request quantity.

3. The current limiting method according to claim 2, characterized in that: After determining whether the first request quantity is equal to the second request quantity, the method further includes: When the number of the first requests is equal to the number of the second requests, determining a concurrent response duration change rate according to the first service request response duration and the second service request response duration; Determine a third service request response time according to the second service request response time, the target request quantity and the second request quantity; A target service request response duration is determined according to the concurrent response duration change rate and the third service request response duration.

4. The current limiting method according to claim 1, characterized in that: Before obtaining the target number of requests for the backend service, the following steps are also included: Receive the corresponding relationship between the number of in-transit requests and the blocking rate from external input; The corresponding relationship between the response time and blocking rate of service requests received from external input.

5. The current limiting method according to claim 1, characterized in that: Before acquiring the first blocking rate corresponding to the target number of requests according to the corresponding relationship between the number of in-transit requests and the blocking rate, the method further includes: Determine whether the target request quantity is equal to a third request quantity, wherein the third request quantity is an average value of the number of in-transit requests of the backend service during the previous (N-1) interactions between the frontend service and the backend service; When the target request quantity is not equal to the third request quantity, the backend service is written into the current limiting logic processing queue.

6. A current limiting device for service requests, characterized in that: include: A first acquisition module is used to acquire a target number of requests for a backend service, wherein the target number of requests is the number of in-transit requests for the backend service when the frontend service interacts with the backend service for the Nth time, and N is an integer greater than 0; A second acquisition module, configured to acquire a first blocking rate corresponding to the target number of requests according to a corresponding relationship between the number of in-transit requests and the blocking rate; a current limiting module, configured to, when the first blocking rate is obtained, limit the current of the front-end service request according to the first blocking rate; In the second acquisition module, according to the corresponding relationship between the number of in-transit requests and the blocking rate, acquiring a first blocking rate corresponding to the target number of requests includes: Obtain the backend service from the current limiting logic processing queue; Obtaining the target request quantity corresponding to the backend service; According to the corresponding relationship between the number of in-transit requests and the blocking rate, obtaining a first blocking rate corresponding to the target number of requests; The first acquisition module is further configured to, after acquiring the first blocking rate corresponding to the target number of requests, acquire the first number of requests, the second number of requests, the first service request response time, and the second service request response time if the first blocking rate cannot be acquired, wherein the first number of requests is the number of in-transit requests of the backend service during the (N-1)th interaction between the frontend service and the backend service, the second number of requests is the average number of in-transit requests of the backend service during the first (N-2)th interaction between the frontend service and the backend service, the first service request response time is the request response time of the backend service during the (N-1)th interaction between the frontend service and the backend service, and the second service request response time is the average value of the request response time of the backend service during the first (N-2)th interaction between the frontend service and the backend service; a determination module, configured to determine a target service request response time according to the target request quantity, the first request quantity, the second request quantity, the first service request response time, and the second service request response time; The second acquisition module is further used to acquire a second blocking rate corresponding to the target service request response time according to the corresponding relationship between the service request response time and the blocking rate; The current limiting module is also used to, when the second blocking rate is obtained, limit the current of the front-end service requests according to the second blocking rate; when the second blocking rate cannot be obtained, not limit the current of the front-end service requests, and set the Redis current limiting flag to no current limiting.

7. An electronic device, characterized in that: It includes a processor and a memory, the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method for limiting the flow of service requests as described in any one of claims 1 to 5 are implemented.

8. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the method for limiting the flow of service requests as described in any one of claims 1-5 are implemented.