Request processing method, device, electronic device and storage medium
By adding preset annotations to the source code of the target application and using monitoring sections to collect requests, the problem of poor current limit control flexibility in the prior art is solved, and accurate current limiting and stability improvements for user requests are achieved.
Patent Information
- Application Number
- CN202211250399.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-12
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-10-12
AI Technical Summary
The current limit control method for user requests in the prior art is poor in flexibility and cannot achieve accurate processing of user requests of different granularities.
By adding preset annotations to the source code of the target application, using these annotations as the tangent point of the current limiting section, obtaining the request parameters of the target request, and matching with the current limiting instance in the instance library, and determining the current limiting result based on the matching result. If the request parameter misses any current limit instance, the request is collected by monitoring the section to generate a new current limit instance.
It realizes automatic current limit processing for user requests and automatic collection of unlimited requests, improves the accuracy and flexibility of current limit processing, and enhances the operation stability of target applications.
Smart Images

Figure CN115567601B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of computer technology and finance, and more specifically, to a request processing method, device, electronic device, and storage medium. Background Art
[0002] With the continuous development of Internet technology, the threshold of Internet technology has also been lowered. With a low learning cost, users can obtain data from various web applications through tools such as crawlers. The data acquisition process requires the web application server to respond to the request. High-frequency data acquisition will cause the server to process a large number of requests in a short period of time, affecting the stable operation of the web application. Therefore, various web applications inevitably need to limit the flow of user requests.
[0003] In the process of implementing the concept of the present disclosure, the inventors found that there are at least the following problems in the related art: the current limiting control method for user requests in the related art is less flexible and cannot achieve accurate processing of user requests of different granularities. Summary of the invention
[0004] In view of this, the present disclosure provides a request processing method, apparatus, electronic device, readable storage medium and computer program product.
[0005] One aspect of the present disclosure provides a request processing method, including: using a preset annotation in a target application as a cutoff point of a current limiting aspect, obtaining a first target request through the cutoff point, wherein the first target request carries a request parameter; using the request parameter to match multiple current limiting instances in an instance library to obtain a matching result; when the matching result indicates that the request parameter hits the first target current limiting instance, determining the current limiting result based on the request count information of the first target current limiting instance; and when the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, collecting the first target request through a monitoring aspect so as to generate a new current limiting instance based on the collected request.
[0006] According to an embodiment of the present disclosure, the above-mentioned first target request is collected through the monitoring aspect so as to generate a new current limiting instance based on the collected request, including: using the above-mentioned preset annotation in the above-mentioned target application as the cut-off point of the above-mentioned monitoring aspect, and collecting the above-mentioned first target request through the above-mentioned cut-off point; extracting at least one current limiting factor from the request parameters of the above-mentioned first target request; determining a target current limiting factor combination based on at least one of the above-mentioned current limiting factors; storing the above-mentioned first target request in a target request set associated with the above-mentioned target current limiting factor combination; and generating a new current limiting instance based on the above-mentioned target current limiting factor combination when the number of requests stored in the above-mentioned target request set meets the preset current limiting condition.
[0007] According to an embodiment of the present disclosure, the above-mentioned first target request is configured with a time tag; wherein, when the number of requests stored in the above-mentioned target request set meets the preset flow limiting condition, a new flow limiting instance is generated based on the above-mentioned target flow limiting factor combination, including: based on the time tags of the requests stored in the above-mentioned target request set, determining the number of second target requests stored in the above-mentioned target request set within the sliding time window, wherein the moment represented by the time tag of the above-mentioned second target request is within the above-mentioned sliding time window; and when the number of the above-mentioned second target requests reaches a first preset threshold, a new flow limiting instance is generated based on the above-mentioned target flow limiting factor combination.
[0008] According to an embodiment of the present disclosure, the above-mentioned current limiting instance has an instance primary key, and the above-mentioned instance primary key is related to the current limiting factor combination used to generate the above-mentioned current limiting instance; wherein, the above-mentioned request parameters are used to match multiple current limiting instances in the instance library to obtain a matching result, including: determining the target instance primary key based on the above-mentioned target current limiting factor combination; and using the above-mentioned target instance primary key to match the instance primary keys of multiple above-mentioned current limiting instances respectively to obtain a matching result.
[0009] According to an embodiment of the present disclosure, the above-mentioned current limiting instance is configured with a limited current time period; wherein, the above-mentioned use of the above-mentioned request parameters to match multiple current limiting instances in the instance library to obtain a matching result includes: obtaining the current system time; based on the above-mentioned current system time, determining at least one second target current limiting instance from the multiple current limiting instances in the above-mentioned instance library, wherein the above-mentioned current system time is within the current limiting time period of the above-mentioned second target current limiting instance; and using the above-mentioned request parameters to match at least one of the above-mentioned second target current limiting instances to obtain the above-mentioned matching result.
[0010] According to an embodiment of the present disclosure, the method further includes: loading the request wrapper into an initialization container to obtain a target container; and using the target container to store request parameters of the first target request so as to read the request parameters of the first target request multiple times.
[0011] According to an embodiment of the present disclosure, the above method also includes: embedding a filter into the request reading method of the above target application; in response to the above target application calling the above request reading method, resetting the above first target request using the above filter so that the above target application responds to the above first target request.
[0012] According to an embodiment of the present disclosure, in the case where the above-mentioned matching result represents that the above-mentioned request parameter hits the first target current limiting instance, the current limiting result is determined based on the request number information of the above-mentioned first target current limiting instance, including: in the case where the above-mentioned matching result represents that the above-mentioned request parameter hits the above-mentioned first target current limiting instance, the target request number information of the above-mentioned first target current limiting instance is determined from the cache, wherein the above-mentioned first target current limiting instance has a time window, and the above-mentioned target request number information represents the number of hits of the above-mentioned first target current limiting instance within the above-mentioned time window; in the case where the number of hits represented by the above-mentioned target request number information is greater than or equal to the second preset threshold, the above-mentioned current limiting result representing the refusal to respond to the above-mentioned target request is obtained; and in the case where the number of hits represented by the above-mentioned target request number information is less than the above-mentioned second preset threshold, the above-mentioned current limiting result representing the response to the above-mentioned target request is obtained, and the above-mentioned target request number information is modified.
[0013] According to an embodiment of the present disclosure, the above method also includes: in the case where the target request number information of the above-mentioned first target current limiting instance cannot be obtained from the above-mentioned cache, writing the initialization request number information of the above-mentioned first target current limiting instance into the above-mentioned cache, wherein the number of hits represented by the above-mentioned initialization request number information is less than the above-mentioned second preset threshold.
[0014] According to an embodiment of the present disclosure, the method further includes: responding to the first target request when the matching result indicates that the request parameter does not hit the first target current limiting instance.
[0015] Another aspect of the present disclosure provides a request processing device, including: an acquisition module, used to use a preset annotation in a target application as a cut-off point of a current limiting aspect, and obtain a first target request through the cut-off point, wherein the first target request carries a request parameter; a matching module, used to use the request parameter to match multiple current limiting instances in an instance library to obtain a matching result; a determination module, used to determine the current limiting result based on the request count information of the first target current limiting instance when the matching result indicates that the request parameter hits the first target current limiting instance; and a collection module, used to collect the first target request through a monitoring aspect when the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, so as to generate a new current limiting instance based on the collected request.
[0016] Another aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more instructions, wherein when the one or more instructions are executed by the one or more processors, the one or more processors implement the method described above.
[0017] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.
[0018] Another aspect of the present disclosure provides a computer program product, the computer program product comprising computer executable instructions, and the instructions are used to implement the above method when executed.
[0019] According to the embodiments of the present disclosure, by adding a preset annotation to the source code of the target application, during the operation of the target application, the preset annotation can be used as the cut-off point of the current limiting aspect to obtain the first target request received by the target application, and then the request parameters of the first target request can be used to match the current limiting instance, and when the target current limiting instance is determined to be matched, the current limiting result is determined according to the request count information of the target current limiting instance. In addition, if the request parameters of the first target request fail to hit any current limiting instance, the first target request can be collected through the monitoring aspect to realize the automatic generation of the current limiting instance. Through the above technical means, the current limiting aspect and the monitoring aspect are used to realize the automatic current limiting processing of user requests and the automatic collection of non-current limiting requests, at least partially overcoming the technical problem that the current limiting control method for user requests in the related art is poor in flexibility and cannot realize the accurate processing of user requests of different granularities, effectively improving the current limiting processing accuracy and flexibility of user requests, and improving the stability of the target application during operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0021] Figure 1 An exemplary system architecture to which the request processing method and apparatus according to an embodiment of the present disclosure can be applied is schematically shown.
[0022] Figure 2 The flowchart of the request processing method according to the embodiment of the present disclosure is schematically shown.
[0023] Figure 3 A schematic diagram of a current limiting factor in a request parameter according to an embodiment of the present disclosure is schematically shown.
[0024] Figure 4 The timing diagram schematically shows the flow limiting processing process of user requests according to an embodiment of the present disclosure.
[0025] Figure 5 The timing diagram of the flow limiting instance generation process according to an embodiment of the present disclosure is schematically shown.
[0026] Figure 6The block diagram of a request processing device according to an embodiment of the present disclosure is schematically shown.
[0027] Figure 7 A block diagram of an electronic device suitable for implementing a request processing method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0028] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0029] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0030] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0031] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0032] In the related art, when technicians perform flow control on user requests received by web applications, they usually adopt a relatively extensive processing method. For example, when it is found that users crawl data through crawlers, it is often impossible to perform flow control on the requests of a specific user. All users are limited, and the flow control standards are mostly based on the subjective judgment of technicians. The specific reason is that the related art usually adopts the method of using collection components to collect jar packages generated in web applications to realize request monitoring. This monitoring method cannot analyze fine-grained user requests and cannot reasonably perform service governance and module division. Therefore, the flow control method for user requests in the related art is less flexible and less accurate.
[0033] In view of this, the embodiments of the present disclosure add cut-off points in the source code of the web application through aspect programming, so as to intercept and limit the user's requests from the cut-off points, thereby realizing fully automated current limiting, reducing the system stability risks brought by human judgment, human analysis, manual current limiting, etc., and improving the flexibility and accuracy of request current limiting.
[0034] Specifically, the embodiments of the present disclosure provide a request processing method, device, electronic device, readable storage medium and computer program product. The method includes: using the preset annotation in the target application as the cut point of the current limiting aspect, obtaining the first target request through the cut point, wherein the first target request carries the request parameter; using the request parameter to match with multiple current limiting instances in the instance library to obtain the matching result; when the matching result indicates that the request parameter hits the first target current limiting instance, the current limiting result is determined based on the request count information of the first target current limiting instance; and when the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, the first target request is collected through the monitoring aspect so as to generate a new current limiting instance based on the collected request.
[0035] In the technical solution disclosed in the present invention, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations, necessary confidentiality measures are taken, and do not violate public order and good morals.
[0036] In the technical solution of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.
[0037] It should be noted that, unless it is explicitly stated that there is a sequence of execution between different operations shown in the flowchart in the embodiments of the present disclosure, or there is a sequence of execution between different operations in technical implementation, otherwise, the execution order of multiple operations may not be prioritized, and multiple operations may also be executed simultaneously.
[0038] Figure 1The exemplary system architecture to which the request processing method and apparatus according to the embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0039] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0040] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc.
[0041] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0042] The server 105 may be a server that provides various services, such as a management server that responds to requests initiated by users through the terminal devices 101, 102, and 103. The management server may match the request with the current limiting instance to determine whether to respond to the request.
[0043] It should be noted that the request processing method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the request processing device provided in the embodiment of the present disclosure can generally be set in the server 105. The request processing method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal device 101, 102, 103 and / or the server 105. Accordingly, the request processing device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal device 101, 102, 103 and / or the server 105. Alternatively, the request processing method provided in the embodiment of the present disclosure can also be executed by the terminal device 101, 102, or 103, or it can also be executed by other terminal devices different from the terminal device 101, 102, or 103. Accordingly, the request processing device provided in the embodiment of the present disclosure can also be set in the terminal device 101, 102, or 103, or it can be set in other terminal devices different from the terminal device 101, 102, or 103.
[0044] For example, a target application may be running on any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101, but not limited thereto), and a user may initiate a request to access the target application through the terminal device 101. After receiving the request, the terminal device 101 may execute the request processing method provided by the embodiment of the present disclosure to determine whether to respond to the request. Alternatively, the request may be sent to other terminal devices, servers, or server clusters through the network 104, and the other terminal devices, servers, or server clusters that receive the image to be processed may execute the request processing method provided by the embodiment of the present disclosure to determine whether to respond to the request and return the processing result to the terminal device 101.
[0045] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0046] Figure 2 The flowchart of the request processing method according to the embodiment of the present disclosure is schematically shown.
[0047] like Figure 2 As shown, the method includes operations S201 to S204.
[0048] In operation S201, a preset annotation in a target application is used as a cut point of a current limiting aspect, and a first target request is obtained through the cut point. The first target request carries a request parameter.
[0049] In operation S202, the request parameters are matched with multiple current limiting instances in the instance library to obtain a matching result.
[0050] In operation S203, when the matching result indicates that the request parameter hits the first target current limiting instance, a current limiting result is determined based on the request count information of the first target current limiting instance.
[0051] In operation S204, when the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, the first target request is collected through the monitoring aspect, so as to generate a new current limiting instance based on the collected request.
[0052] According to an embodiment of the present disclosure, the target application may refer to various web applications, including but not limited to web applications based on browsers, web applications based on applications, web applications based on microservices, etc.
[0053] According to an embodiment of the present disclosure, the preset annotation may be @XXMapping, including @GetMapping (get), @PostMapping (add), @PutMapping (update), @DeleteMapping (delete), and the like.
[0054] According to an embodiment of the present disclosure, a preset annotation can be added to the source code of the target application. In particular, the preset annotation can be added to the source code of the external interface part of the target application. For example, if the target application provides services mainly in the form of Rest interfaces, the preset annotation can be added to the relevant location of calling the Rest interface in the source code.
[0055] According to an embodiment of the present disclosure, a pointcut may be used to indicate a location where a current limiting aspect is woven into the execution flow of a target application.
[0056] According to an embodiment of the present disclosure, the request parameters may include the name of the first target request, comments, the address for sending the first target request, the port number, the timeout period of the request and response, the protocol, the method, the target URL path, the account number, etc.
[0057] According to an embodiment of the present disclosure, any one or a combination of multiple items in the request parameters can be used as a dimension for current limiting. For example, the account used when sending the first target request can be used as a dimension for current limiting; for another example, the combination of the account used when sending the first target request and the address to send the first target request can be used as a dimension for current limiting, which is not limited here.
[0058] According to an embodiment of the present disclosure, a current limiting instance may correspond to a current limiting dimension separately. Using request parameters to match the current limiting instance may refer to matching the current limiting dimension obtained by combining the request parameters with the current limiting dimension corresponding to the current limiting instance.
[0059] According to an embodiment of the present disclosure, the monitoring aspect can be used to collect the first target request that has not been throttled, and the collected requests can be processed to generate a new throttling instance based on the collected requests when it is necessary to throttle the throttling dimension corresponding to the first target request.
[0060] According to the embodiments of the present disclosure, by adding a preset annotation to the source code of the target application, during the operation of the target application, the preset annotation can be used as the cut-off point of the current limiting aspect to obtain the first target request received by the target application, and then the request parameters of the first target request can be used to match the current limiting instance, and when the target current limiting instance is determined to be matched, the current limiting result is determined according to the request count information of the target current limiting instance. In addition, if the request parameters of the first target request fail to hit any current limiting instance, the first target request can be collected through the monitoring aspect to realize the automatic generation of the current limiting instance. Through the above technical means, the current limiting aspect and the monitoring aspect are used to realize the automatic current limiting processing of user requests and the automatic collection of non-current limiting requests, at least partially overcoming the technical problem that the current limiting control method for user requests in the related art is poor in flexibility and cannot realize the accurate processing of user requests of different granularities, effectively improving the current limiting processing accuracy and flexibility of user requests, and improving the stability of the target application during operation.
[0061] Reference below Figure 3 to Figure 5 , combined with specific embodiments Figure 2 The method shown is further explained.
[0062] According to an embodiment of the present disclosure, when obtaining the first target request, the @XXManpping of the Controller layer (control layer) of the target application can be used as a cut point to obtain the request parameters of the first target request through the parameters in the current limiting aspect.
[0063] According to an embodiment of the present disclosure, when obtaining the request parameters of the first target request, the request wrapper can be loaded into the initialization container to obtain the target container; and the request parameters of the first target request can be stored using the target container to facilitate multiple readings of the request parameters of the first target request.
[0064] According to an embodiment of the present disclosure, the request wrapper may be obtained by encapsulating a class related to a user request. For example, the class related to a user request may be HTTPServletRequest, and the request wrapper may be HttpSerVletRequestWrapper, which may implement HTTPSerVletRequest based on the decorator pattern.
[0065] According to an embodiment of the present disclosure, the container of the application may be based on a doctor container, a k8s container, etc., or may be an array or a collection, which is not limited here.
[0066] According to an embodiment of the present disclosure, taking the application container as a doctor container as an example, the request wrapper can be used as an image and saved in the container engine. The initialization container can refer to a container that has a built operating environment and has not loaded an image or application. When loading the request wrapper into the initialization container, the image of the request wrapper can be loaded into the initialization container.
[0067] According to an embodiment of the present disclosure, by storing request parameters in a target container, repeated reading of request parameters can be facilitated, thereby improving the operating efficiency of the system.
[0068] According to the embodiment of the present disclosure, based on the design of the request input stream object in the related art, the number of times the first target request can be read in the target application is limited. Taking the input stream of the first target request as the HttpServletRequest input stream as an example, the reading of the HttpServletRequest input stream can be realized by calling the getInputStream() method to obtain the InputStream object. Since there is a flag bit inside the read() method of InputStream, the flag bit is used to indicate the position where the current stream is read, and the flag bit will move with the progress of the object reading, that is, after the object is read, the flag bit will move to the end, and read() can return -1 to indicate that the reading has been completed. If only the reset() method in the related art is used, the flag bit will move to the position where the mask was called last time, and the input stream cannot be read again. Since InputStream cannot implement the related methods of reset by default, and ServletInputStream does not rewrite the related methods of reset, the HttpServletRequest input stream can only be read once.
[0069] According to an embodiment of the present disclosure, the problem that the first target request cannot be read repeatedly can be solved by resetting the first target request. Specifically, the following operations are included: embedding a filter into a request reading method of a target application; and, in response to the target application calling the request reading method, resetting the first target request using the filter so that the target application responds to the first target request.
[0070] According to an embodiment of the present disclosure, a filter may be embedded in a request reading method of a target application by rewriting the calling request reading method.
[0071] According to an embodiment of the present disclosure, the filter may be a RequestFilter. Resetting the first target request by using the filter may be resetting the first target request by using a doFilter method in the filter RequestFilter, so that the first target request can be read repeatedly.
[0072] According to an embodiment of the present disclosure, the request parameters of the first target request may include a current limiting factor.
[0073] Figure 3 A schematic diagram of a current limiting factor in a request parameter according to an embodiment of the present disclosure is schematically shown.
[0074] like Figure 3 As shown, the flow limiting factors in the request parameters of the first target request may include: ajaxPath (the path where the request is sent), Origin (the client that sends the request), refer (the comment of the request), client IP (the address where the request is sent), erp (the system used when sending the request), pin (the personal identification code of the user who sends the request), etc.
[0075] According to an embodiment of the present disclosure, a combination of one or more of the above upper current limiting factors may form a current limiting factor combination.
[0076] According to an embodiment of the present disclosure, a throttling instance may have an instance primary key, and the instance primary key may be associated with a throttling factor combination used to generate the throttling instance. For example, the instance primary key may be a combination of a dynamic prefix generated by a random number algorithm and a throttling factor.
[0077] According to an embodiment of the present disclosure, operation S202 may include the following operations:
[0078] Based on the target current limiting factor combination, a target instance primary key is determined; and instance primary keys of multiple current limiting instances are matched respectively using the target instance primary key to obtain a matching result.
[0079] According to an embodiment of the present disclosure, the target instance primary key may be generated by stringing the current limiting factors in the request parameters into a character string.
[0080] According to an embodiment of the present disclosure, the target instance primary key may only include the second half of the instance primary key of the throttling instance, that is, a combination of the throttling factor combination.
[0081] According to an embodiment of the present disclosure, matching instance primary keys of multiple current limiting instances respectively using the target instance primary key may be matching the target instance primary key with the second half of the instance primary key of each current limiting instance.
[0082] In some embodiments, the current limiting instance may also be configured with a current limiting period, which may refer to a period during which the current limiting instance is effective. The current limiting period may be set when configuring the current limiting instance, and its specific range may be set according to a specific application scenario, which is not limited here. In this embodiment, operation S202 may include the following operations:
[0083] Obtain the current system time; based on the current system time, determine at least one second target current limiting instance from multiple current limiting instances in the instance library, wherein the current system time is within the current limiting period of the second target current limiting instance; and use the request parameters to match the at least one second target current limiting instance to obtain a matching result.
[0084] According to an embodiment of the present disclosure, the current system moment may refer to the moment when the current limiting matching operation is performed, the moment when the first target request is obtained, or the moment when the current limiting processing of the first target request is started, etc. The specific moment referred to by the current system moment may be determined according to a specific application scenario and is not limited here.
[0085] Figure 4 The timing diagram schematically shows the flow limiting processing process of user requests according to an embodiment of the present disclosure.
[0086] like Figure 4 As shown, before the current limiting process is performed, each current limiting instance configured in the instance library can be imported into the current limiting service.
[0087] According to an embodiment of the present disclosure, a first target request initiated by a user through various client devices can be intercepted by a current limiting aspect at the control layer of a target application. Afterwards, the first target request can be sent to a current limiting service, which determines whether the first target request hits a current limiting instance.
[0088] According to an embodiment of the present disclosure, when the judgment result of the current limiting service is that the first target request does not hit the current limiting instance, that is, when the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, the current limiting service can feedback information that no current limiting is required to the control layer. After receiving the feedback information, the control layer of the target application can send the first target request to the service layer of the target application, and the service layer of the target application executes the business logic of the target application to achieve a response to the first target request.
[0089] According to an embodiment of the present disclosure, when the judgment result of the current limiting service is that the first target request hits the first target current limiting instance, that is, the matching result characterizes that the request parameter hits the first target current limiting instance, the current limiting result can be determined based on the request count information of the first target current limiting instance.
[0090] According to an embodiment of the present disclosure, the first target current limiting instance may have a time window, and the length of the time period represented by the time window may be determined according to a specific application scenario and is not limited here.
[0091] According to an embodiment of the present disclosure, the request count information of the first target throttling instance may represent the number of times the first target throttling instance is hit within a time window.
[0092] According to an embodiment of the present disclosure, target request count information of the first target current limiting instance may be determined from the cache.
[0093] According to an embodiment of the present disclosure, the request count information of the first target current limiting instance recorded in the cache may be null (empty), that is, the target request count information of the first target current limiting instance cannot be obtained from the cache. In this case, the initialization request count information of the first target current limiting instance may be written into the cache. At the same time, the cache may also return a current limiting result representing the response to the first target request to the current limiting service. The current limiting service may feedback information that no current limiting is required to the control layer of the target application based on the current limiting result, so that the target application can respond to the first target request.
[0094] According to an embodiment of the present disclosure, the initialization request count information may include an initialized hit count value and an initialized time window. The initialized hit count value may be 1, the start time of the initialized time window may be the time when the initialization request count information is written to the cache, and the length of the time period represented by the initialized time window may be the same as the time window of the first target current limiting instance.
[0095] According to an embodiment of the present disclosure, when the target request number information of the first target current limiting instance is successfully determined from the cache, the number of hits represented by the target request number information can be compared with the second preset threshold to determine the current limiting result.
[0096] According to an embodiment of the present disclosure, the second preset threshold may be any integer greater than the initialized hit count value, which is not limited herein.
[0097] According to an embodiment of the present disclosure, when the number of hits represented by the target request frequency information is greater than or equal to the second preset threshold, a current limiting result representing a refusal to respond to the first target request can be obtained. At this time, the cache can return a current limiting result representing a refusal to respond to the first target request to the current limiting service. The current limiting service can feedback information requiring current limiting to the control layer based on the current limiting result. After receiving the feedback information, the control layer of the target application can throw out the first target request and not process the first target request.
[0098] According to an embodiment of the present disclosure, when the number of hits represented by the target request frequency information is less than the second preset threshold, a current limiting result representing the response to the first target request can be obtained. At this time, the target request frequency information can be modified in the cache, that is, the number of hits represented by the target request frequency information is increased by one by modification. At the same time, the cache can also return the current limiting result representing the response to the first target request to the current limiting service. The current limiting service can feedback information that does not require current limiting to the control layer of the target application based on the current limiting result, so that the target application can respond to the first target request.
[0099] Figure 5 The timing diagram of the flow limiting instance generation process according to an embodiment of the present disclosure is schematically shown.
[0100] like Figure 5 As shown, the first target request for generating a new current limiting instance may be a request that misses any current limiting instance in the instance library.
[0101] According to an embodiment of the present disclosure, a preset annotation in a target application may be used as a cutoff point of a monitoring section, and the first target request may be collected through the cutoff point.
[0102] According to an embodiment of the present disclosure, the first target request may be pushed to the request processing cluster through the message middleware.
[0103] According to an embodiment of the present disclosure, the request processing cluster can obtain the current limiting configuration from the current limiting service through an external interface, such as an RPC interface. The current limiting configuration may include preset current limiting conditions, current limiting time periods, etc. The information contained in the current limiting configuration can be set according to the specific application scenario, which is not limited here.
[0104] According to an embodiment of the present disclosure, after receiving the first target request, the request processing cluster can extract at least one flow limiting factor from the request parameters of the first target request; determine a target flow limiting factor combination based on the at least one flow limiting factor; and store the first target request in a target request set associated with the target flow limiting factor combination.
[0105] According to an embodiment of the present disclosure, a request cluster can determine whether each request set in the cluster hits the current limiting configuration, that is, determine whether the number of requests stored in the request set meets the preset current limiting condition. When the number of requests stored in the target request set meets the preset current limiting condition, the request cluster can generate a new current limiting instance based on the target current limiting factor combination.
[0106] According to an embodiment of the present disclosure, the first target request may be configured with a time tag, and the time tag may refer to the time when the first target request is responded to, etc., or may refer to the current system time, which is not limited here.
[0107] According to an embodiment of the present disclosure, the preset flow limiting condition may be expressed as the number of requests in the request set within a period of time being greater than a preset value. Specifically, when the number of requests stored in the target request set meets the preset flow limiting condition, generating a new flow limiting instance based on the target flow limiting factor combination may include the following operations:
[0108] Based on the time tags of the requests stored in the target request set, determine the number of second target requests stored in the target request set within the sliding time window, wherein the moment represented by the time tag of the second target request is within the sliding time window; and, when the number of second target requests reaches a first preset threshold, generate a new current limiting instance based on the target current limiting factor combination.
[0109] According to an embodiment of the present disclosure, a sliding time window may be configured with a window width and a window sliding duration. The window width may refer to the length of the time period represented by the sliding time window, such as 60 minutes, 30 minutes, etc.; the window sliding duration may refer to the interval between every two slides of the sliding time window, such as the sliding time window slides once every 20 minutes, etc.
[0110] According to an embodiment of the present disclosure, the current limiting instance generated by the request processing cluster can be pushed to the current limiting service through the message middleware, so that the current limiting service applies the current limiting instance to implement the current limiting control requested by the user.
[0111] According to an embodiment of the present disclosure, the request processing cluster may also perform aggregation operations on received requests to reduce storage pressure.
[0112] According to an embodiment of the present disclosure, the request processing cluster can also obtain the alarm configuration from the alarm service. During the process of generating a current limiting instance, it can also determine whether each request set in the cluster hits the alarm configuration, and when it is determined that the alarm configuration is hit, push alarm feedback information to the alarm service. The feedback information can be forwarded to the managers or R&D personnel of the target application so that the managers or R&D personnel of the target application can process the alarm feedback information in real time, thereby reducing the operation risk of the target application.
[0113] Figure 6 The block diagram of a request processing device according to an embodiment of the present disclosure is schematically shown.
[0114] like Figure 6 As shown, the request processing device 600 includes an acquisition module 610 , a matching module 620 , a determination module 630 and a collection module 640 .
[0115] The acquisition module 610 is used to use the preset annotation in the target application as the cut-off point of the current limiting aspect, and obtain the first target request through the cut-off point, wherein the first target request carries the request parameters.
[0116] The matching module 620 is used to match the request parameters with multiple current limiting instances in the instance library to obtain a matching result.
[0117] The determination module 630 is used to determine the current limiting result based on the request number information of the first target current limiting instance when the matching result indicates that the request parameter hits the first target current limiting instance.
[0118] The collection module 640 is used to collect the first target request through the monitoring aspect when the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, so as to generate a new current limiting instance based on the collected request.
[0119] According to the embodiments of the present disclosure, by adding a preset annotation to the source code of the target application, during the operation of the target application, the preset annotation can be used as the cut-off point of the current limiting aspect to obtain the first target request received by the target application, and then the request parameters of the first target request can be used to match the current limiting instance, and when the target current limiting instance is determined to be matched, the current limiting result is determined according to the request count information of the target current limiting instance. In addition, if the request parameters of the first target request fail to hit any current limiting instance, the first target request can be collected through the monitoring aspect to realize the automatic generation of the current limiting instance. Through the above technical means, the current limiting aspect and the monitoring aspect are used to realize the automatic current limiting processing of user requests and the automatic collection of non-current limiting requests, at least partially overcoming the technical problem that the current limiting control method for user requests in the related art is poor in flexibility and cannot realize the accurate processing of user requests of different granularities, effectively improving the current limiting processing accuracy and flexibility of user requests, and improving the stability of the target application during operation.
[0120] According to an embodiment of the present disclosure, the acquisition module 640 includes a first acquisition unit, a second acquisition unit, a third acquisition unit, a fourth acquisition unit, and a fifth acquisition unit.
[0121] The first collection unit is used to use the preset annotation in the target application as the cut-off point of the monitoring section, and collect the first target request through the cut-off point.
[0122] The second collection unit is used to extract at least one current limiting factor from the request parameters of the first target request.
[0123] The third acquisition unit is used to determine a target current limiting factor combination based on at least one current limiting factor.
[0124] The fourth collection unit is used to store the first target request into a target request set associated with the target current limiting factor combination.
[0125] The fifth collection unit is used to generate a new current limiting instance based on the target current limiting factor combination when the number of requests stored in the target request set meets the preset current limiting condition.
[0126] According to an embodiment of the present disclosure, the first target request is configured with a time tag.
[0127] According to an embodiment of the present disclosure, the fifth acquisition unit includes a first acquisition subunit and a second acquisition subunit.
[0128] The first collection subunit is used to determine the number of second target requests stored in the target request set within the sliding time window based on the time tags of the requests stored in the target request set, wherein the moment represented by the time tags of the second target requests is within the sliding time window.
[0129] The second collection subunit is used to generate a new current limiting instance based on the target current limiting factor combination when the number of second target requests reaches the first preset threshold.
[0130] According to an embodiment of the present disclosure, a current limiting instance has an instance primary key, and the instance primary key is associated with a current limiting factor combination used to generate the current limiting instance.
[0131] According to an embodiment of the present disclosure, the matching module 620 includes a first matching unit and a second matching unit.
[0132] The first matching unit is used to determine the target instance primary key based on the target current limiting factor combination.
[0133] The second matching unit is used to use the target instance primary key to match the instance primary keys of multiple current limiting instances respectively to obtain matching results.
[0134] According to an embodiment of the present disclosure, a flow limiting instance is configured with a flow limiting period.
[0135] According to an embodiment of the present disclosure, the matching module 620 includes a third matching unit, a fourth matching unit, and a fifth matching unit.
[0136] The third matching unit is used to obtain the current system time.
[0137] The fourth matching unit is used to determine at least one second target current limiting instance from multiple current limiting instances in the instance library based on the current system time, wherein the current system time is within the current limiting period of the second target current limiting instance.
[0138] The fifth matching unit is used to match the request parameters with at least one second target current limiting instance to obtain a matching result.
[0139] According to an embodiment of the present disclosure, the request processing device 600 further includes a first processing module and a storage module.
[0140] The first processing module is used to load the request wrapper into the initialization container to obtain a target container.
[0141] The storage module is used to store the request parameters of the first target request by using the target container, so as to read the request parameters of the first target request multiple times.
[0142] According to an embodiment of the present disclosure, the request processing device 600 further includes a second processing module and a third processing module.
[0143] The second processing module is used to embed the filter into the request reading method of the target application.
[0144] The third processing module is used for resetting the first target request by using a filter in response to the target application calling the request reading method, so that the target application responds to the first target request.
[0145] According to an embodiment of the present disclosure, the determination module 630 includes a first determination unit, a second determination unit, and a third determination unit.
[0146] The first determination unit is used to determine the target request count information of the first target current limiting instance from the cache when the matching result indicates that the request parameter hits the first target current limiting instance, wherein the first target current limiting instance has a time window, and the target request count information indicates the number of times the first target current limiting instance is hit within the time window.
[0147] The second determining unit is used to obtain a current limiting result representing a refusal to respond to the target request when the number of hits represented by the target request number information is greater than or equal to a second preset threshold.
[0148] The third determination unit is used to obtain a current limiting result representing the response to the target request and modify the target request number information when the number of hits represented by the target request number information is less than a second preset threshold.
[0149] According to an embodiment of the present disclosure, the request processing device 600 further includes a writing module.
[0150] A writing module is used to write the initialization request number information of the first target current limiting instance into the cache when the target request number information of the first target current limiting instance cannot be obtained from the cache, wherein the number of hits represented by the initialization request number information is less than the second preset threshold.
[0151] According to an embodiment of the present disclosure, the request processing device 600 further includes a fourth processing module.
[0152] The fourth processing module is used to respond to the first target request when the matching result indicates that the request parameter does not hit the first target current limiting instance.
[0153] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.
[0154] For example, any multiple of the acquisition module 610, the matching module 620, the determination module 630, and the acquisition module 640 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present disclosure, at least one of the acquisition module 610, the matching module 620, the determination module 630, and the acquisition module 640 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware, or by a suitable combination of any of them. Alternatively, at least one of the acquisition module 610 , the matching module 620 , the determination module 630 , and the collection module 640 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be executed.
[0155] It should be noted that the request processing device part in the embodiment of the present disclosure corresponds to the request processing method part in the embodiment of the present disclosure. The description of the request processing device part specifically refers to the request processing method part, which will not be repeated here.
[0156] Figure 7 A block diagram of an electronic device suitable for implementing a request processing method according to an embodiment of the present disclosure is schematically shown. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0157] like Figure 7 As shown, the computer electronic device 700 according to the embodiment of the present disclosure includes a processor 701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 702 or the program loaded from the storage part 708 to the random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.
[0158] In RAM 703, various programs and data required for the operation of electronic device 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other via bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0159] According to an embodiment of the present disclosure, the electronic device 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the I / O interface 705: an input portion 706 including a keyboard, a mouse, etc.; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 708 including a hard disk, etc.; and a communication portion 709 including a network interface card such as a LAN card, a modem, etc. The communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage portion 708 as needed.
[0160] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0161] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0162] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.
[0163] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 702 and / or the RAM 703 described above and / or one or more memories other than the ROM 702 and the RAM 703 .
[0164] An embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains a program code for executing the method provided by the embodiment of the present disclosure. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the request processing method provided by the embodiment of the present disclosure.
[0165] When the computer program is executed by the processor 701, the above functions defined in the system / device of the embodiment of the present disclosure are executed. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0166] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 709, and / or installed from the removable medium 711. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0167] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0168] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments and / or claims of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0169] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A request processing method, comprising: Using a preset annotation in the target application as a cut point of the current limiting aspect, obtaining a first target request through the cut point, wherein the first target request carries a request parameter, and the preset annotation includes @XXMapping; Using the request parameters to match multiple current limiting instances in the instance library to obtain a matching result; In a case where the matching result indicates that the request parameter hits a first target current limiting instance, determining a current limiting result based on the request count information of the first target current limiting instance; and When the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, the first target request is collected through the monitoring aspect so as to generate a new current limiting instance based on a combination of current limiting factors included in the collected request.
2. The method according to claim 1, wherein: The collecting the first target request through the monitoring section so as to generate a new current limiting instance based on the collected request includes: Using the preset annotation in the target application as a cutoff point of the monitoring section, and collecting the first target request through the cutoff point; Extracting at least one current limiting factor from the request parameters of the first target request; Based on at least one of the current limiting factors, determining a target current limiting factor combination; storing the first target request into a target request set associated with the target current limiting factor combination; and When the number of requests stored in the target request set meets the preset current limiting condition, a new current limiting instance is generated based on the target current limiting factor combination.
3. The method according to claim 2, wherein: The first target request is configured with a time tag; Wherein, when the number of requests stored in the target request set meets the preset current limiting condition, generating a new current limiting instance based on the target current limiting factor combination includes: Determining, based on time tags of requests stored in the target request set, a number of second target requests stored in the target request set within a sliding time window, wherein a time moment represented by the time tag of the second target request is within the sliding time window; and When the number of the second target requests reaches a first preset threshold, a new current limiting instance is generated based on the target current limiting factor combination.
4. The method according to claim 3, wherein: The current limiting instance has an instance primary key, and the instance primary key is associated with a current limiting factor combination used to generate the current limiting instance; The use of the request parameters to match multiple current limiting instances in the instance library to obtain a matching result includes: Determining a target instance primary key based on the target current limiting factor combination; and The instance primary keys of the plurality of current limiting instances are matched respectively using the target instance primary key to obtain a matching result.
5. The method according to claim 1, wherein: The current limiting instance is configured with a current limiting period; The use of the request parameters to match multiple current limiting instances in the instance library to obtain a matching result includes: Get the current system time; Based on the current system time, determining at least one second target current limiting instance from a plurality of current limiting instances in the instance library, wherein the current system time is within a current limiting period of the second target current limiting instance; and The request parameter is used to match at least one of the second target current limiting instances to obtain the matching result.
6. The method according to claim 1, further comprising: Load the request wrapper into the initialization container to obtain the target container; as well as The target container is used to store the request parameters of the first target request, so as to read the request parameters of the first target request multiple times.
7. The method according to claim 6, further comprising: embedding the filter into the request reading method of the target application; In response to the target application calling the request reading method, the first target request is reset using the filter so that the target application responds to the first target request.
8. The method according to claim 1, wherein: In the case where the matching result indicates that the request parameter hits the first target current limiting instance, determining the current limiting result based on the request number information of the first target current limiting instance includes: In a case where the matching result indicates that the request parameter hits the first target current limiting instance, determining target request count information of the first target current limiting instance from a cache, wherein the first target current limiting instance has a time window, and the target request count information indicates the number of times the first target current limiting instance is hit within the time window; When the number of hits represented by the target request number information is greater than or equal to a second preset threshold, obtaining the current limiting result representing a refusal to respond to the target request; and When the number of hits represented by the target request number information is less than the second preset threshold, the current limiting result representing the response to the target request is obtained, and the target request number information is modified.
9. The method according to claim 8, further comprising: When the target request number information of the first target current limiting instance cannot be obtained from the cache, the initialization request number information of the first target current limiting instance is written into the cache, wherein the number of hits represented by the initialization request number information is less than the second preset threshold.
10. The method according to claim 1, further comprising: If the matching result indicates that the request parameter does not hit the first target current limiting instance, respond to the first target request.
11. A request processing device, comprising: An acquisition module, used to use a preset annotation in a target application as a cut point of a current limiting aspect, and acquire a first target request through the cut point, wherein the first target request carries a request parameter, and the preset annotation includes @XXMapping; A matching module, used to match the request parameters with multiple current limiting instances in the instance library to obtain a matching result; a determination module, configured to determine a current limiting result based on the request count information of the first target current limiting instance when the matching result indicates that the request parameter hits the first target current limiting instance; and A collection module is used to collect the first target request through a monitoring aspect when the matching result indicates that the request parameter does not hit any current limiting instance in the instance library, so as to generate a new current limiting instance based on a combination of current limiting factors included in the collected request.
12. An electronic device comprising: one or more processors; A memory for storing one or more instructions, Wherein, when the one or more instructions are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 10.
13. A computer-readable storage medium having executable instructions stored thereon, wherein when the executable instructions are executed by a processor, the processor is enabled to implement the method according to any one of claims 1 to 10.
14. A computer program product, comprising computer executable instructions, which are used to implement the method of any one of claims 1 to 10 when executed.
Citation Information
Patent Citations
Access request processing method, device and equipment and readable storage medium
CN113377350A
Current limiting method and device, electronic equipment and computer readable medium
CN113765692A