Request processing method and device, equipment, storage medium and program product
By assigning target priority to pending requests and prioritizing processing within the flow control limit time, the request failure problem when the downstream system has flow control limit is solved, and the request success rate and processing efficiency are improved.
Patent Information
- Application Number
- CN202411145168.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-12-13
AI Technical Summary
The downstream system may have flow control restrictions when processing requests initiated by the upstream system, resulting in the request failure, and the existing first-in-first-out request queue processing mechanism cannot effectively process requests within the flow control limit time, reducing the request success rate.
By obtaining pending requests carrying access address information and request source information, we can determine whether the flow control limit will be triggered, and assign the target priority to the requests that may trigger the limit, and enter the target priority queue for processing; when the flow control limit time arrives, we can reach the target priority queue. , prioritize requests with high priority.
This improves the request success rate within the flow control limit time, avoids requests with high priority rejection by downstream systems due to flow control limits, and improves request processing efficiency.
Smart Images

Figure CN119127118A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a request processing method, apparatus, device, storage medium and program product. Background Art
[0002] Since the downstream system may have flow control restrictions when processing requests initiated by the upstream system, if the flow control restrictions are triggered, the request may fail; for example, if the downstream system limits each interface to only one request every n seconds, any request within n seconds after the first request will be rejected by the downstream system.
[0003] Moreover, currently, a first-in-first-out request queue processing mechanism is usually used to process requests initiated by upstream systems. It can be understood that when this method is used, when there is a flow control limit in the downstream system, the requests initiated by the upstream system within the flow control limit time cannot be processed, thereby reducing the request success rate. Summary of the invention
[0004] The main purpose of this application is to provide a request processing method, device, equipment, storage medium and program product, aiming to solve the technical problem that when there is flow control restriction in the downstream system, the request initiated by the upstream system within the flow control limit time cannot be processed, thereby reducing the request success rate.
[0005] To achieve the above objectives, the present application proposes a request processing method, which includes:
[0006] Obtaining a pending request, wherein the pending request carries access address information and request source information;
[0007] Based on the access address information and a preset correspondence between the access address and the flow control limit, determining whether the pending request will trigger the flow control limit;
[0008] If flow control restriction is triggered, a target priority is assigned to the pending request based on the request source information, and the pending request is queued based on the target priority;
[0009] If the current time reaches the preset flow control limit time, the pending request is dequeued based on the target priority.
[0010] In one embodiment, the step of enqueuing the pending request based on the target priority includes:
[0011] Based on the target priority, adding the pending request to the target priority queue to complete the enqueue processing;
[0012] Among them, the target priority queue is the request queue corresponding to the target request path of the request to be processed, and the target request path is the request path with flow control restrictions.
[0013] In one embodiment, different request paths correspond to different preset priority queues. If the current time reaches the preset flow control limit time, before the step of dequeuing the pending request based on the target priority, the step includes:
[0014] Traversing each of the preset priority queues, and determining whether the current time is less than the preset consumable time corresponding to each of the preset priority queues;
[0015] The preset consumable time is obtained by summing the last consumable time corresponding to the preset priority queue and the preset time window, and the last consumable time is the time when the queue request in the preset priority queue was last dequeued;
[0016] If the current time is greater than or equal to the preset consumable time corresponding to the preset priority queue, it is determined that the current time reaches the preset flow control limit time.
[0017] In one embodiment, when the step of traversing each of the preset priority queues is started, the waiting time for the next traversal is determined, and after the step of determining whether the current time is less than the preset consumable time corresponding to each of the preset priority queues, the method further includes:
[0018] If the current time is less than the preset consumable time corresponding to the preset priority queue, then determine the waiting time for each of the preset priority queues based on the preset time window and the current time;
[0019] Determine whether the waiting time required for the preset priority queue is less than the waiting time for the next traversal;
[0020] If it is less than the waiting time for the next traversal, the waiting time for the next traversal is set to the waiting time of the preset priority queue.
[0021] In one embodiment, after the step of enqueuing the pending request based on the target priority, the method further includes:
[0022] Determine whether the current time is greater than or equal to the target consumable time corresponding to the target priority queue;
[0023] If the current time is greater than or equal to the target consumable time, determining whether the step of traversing each of the preset priority queues is being executed, and determining whether the current time is less than the preset consumable time corresponding to each of the preset priority queues;
[0024] If not executed, it is determined that the current time reaches the preset flow control limit time, so as to immediately execute the step of dequeuing the pending requests based on the target priority.
[0025] In one embodiment, if the current time reaches the preset flow control limit time, the step of dequeuing the pending request based on the target priority includes:
[0026] If the current time reaches the preset flow control limit time, determine whether there is a queue request in the target priority queue;
[0027] If it exists, the target request with the highest priority in the target priority queue will be dequeued.
[0028] In addition, to achieve the above purpose, the present application also proposes a request processing device, the request processing device comprising:
[0029] An acquisition module, used for acquiring a pending request, wherein the pending request carries access address information and request source information;
[0030] A judgment module, used to judge whether the pending request will trigger the flow control restriction based on the access address information and the preset corresponding relationship between the access address and the flow control restriction;
[0031] An enqueue processing module, configured to assign a target priority to the pending request based on the request source information if flow control restriction is triggered, and to enqueue the pending request based on the target priority;
[0032] The dequeue processing module is used to dequeue the pending request based on the target priority if the current time reaches the preset flow control limit time.
[0033] In addition, to achieve the above objectives, the present application also proposes a request processing device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the request processing method described above.
[0034] In addition, to achieve the above objectives, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the request processing method described above are implemented.
[0035] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the request processing method described above are implemented.
[0036] One or more technical solutions proposed in this application have at least the following technical effects:
[0037] The present application obtains pending requests carrying access address information and request source information, determines whether the pending requests will trigger flow control restrictions based on the access address information and the preset correspondence between the access address and the flow control restriction, assigns a target priority to the request that will trigger the flow control restriction based on the request source information, and queues the pending requests based on the target priority. If the current time reaches the preset flow control limit time, the pending requests are dequeued based on the target priority. It can be understood that if the pending requests will trigger the flow control restriction, different priorities are assigned to pending requests with different request sources, and the pending requests are dequeued based on the target priority, so that pending requests with high priority can be dequeued outside the preset flow control limit time. Instead of using a first-in-first-out request queue processing mechanism to process pending requests, pending requests with high priority will not be rejected by the downstream system due to being dequeued within the flow control limit time, thereby improving the request success rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0040] Figure 1 A flowchart of the first embodiment of the method for processing a request of this application is provided;
[0041] Figure 2 A schematic diagram of a first scenario provided for Embodiment 1 of the method for processing a request of this application;
[0042] Figure 3 A schematic diagram of a second scenario provided for Embodiment 1 of the method for processing a request of this application;
[0043] Figure 4 A flowchart of the second embodiment of the method for processing a request of this application is provided;
[0044] Figure 5 A schematic diagram of a third scenario provided for Embodiment 2 of the method for processing a request of this application;
[0045] Figure 6 This is a schematic diagram of the module structure of the request processing device according to an embodiment of the present application;
[0046] Figure 7 A schematic diagram of the device structure of the hardware operating environment involved in the request processing method in the embodiment of the present application.
[0047] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0048] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0049] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0050] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a request processing device, etc. The following takes the request processing device as an example to illustrate this embodiment and the following embodiments.
[0051] Based on this, the present application embodiment provides a request processing method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the method for processing requests of this application.
[0052] In this embodiment, the request processing method includes steps S10 to S40:
[0053] Step S10, obtaining a pending request, wherein the pending request carries access address information and request source information;
[0054] It should be noted that the request processing device can be a server. Different upstream systems can send multiple pending requests for the same URL (Uniform Resource Locator, a standard format address used to identify downstream systems) to the server, or can send multiple pending requests for different URLs to the server; wherein the upstream system can be a client application, other servers or services, etc.
[0055] Specifically, the request to be processed may be a data interaction request, such as an access request, a service request, etc., wherein the request to be processed consists of a request header and a request body.
[0056] Since there may be flow control restrictions when the downstream system processes the requests initiated by the upstream system, if the flow control restrictions are triggered, the request may fail; for example, if the downstream system limits each interface to only one request every n seconds, any request within n seconds after the first request will be rejected by the downstream system; and, currently, a first-in-first-out request queue processing mechanism is usually used to process the requests initiated by the upstream system. It can be understood that when this method is used, when there are flow control restrictions in the downstream system, the requests initiated by the upstream system within the flow control limit time cannot be processed, thereby reducing the request success rate.
[0057] In order to solve the above problem, the server in this embodiment obtains a pending request carrying access address information and request source information.
[0058] Among them, the access address information can be the interface identifier of the downstream system accessed, or the website of the downstream system accessed, etc.; the request source information (channel information) can be the interface identifier of the upstream system that initiates the request to be processed, or the website of the upstream system that initiates the request to be processed, etc.
[0059] Step S20, based on the access address information and the preset correspondence between the access address and the flow control limit, determining whether the pending request will trigger the flow control limit;
[0060] It is understandable that there may be flow control restrictions when the downstream system processes the request initiated by the upstream system. If the flow control restriction is triggered, the request may fail. When the server processes the pending request, it needs to determine whether the pending request will trigger the flow control restriction.
[0061] Specifically, since some downstream systems may have flow control restrictions on requests initiated by the upstream system, the server can determine the downstream system that the upstream system wants to access after obtaining the access address information. Moreover, since the server is pre-configured with a preset correspondence between the access address and the flow control restriction, based on the access address information and the preset correspondence between the access address and the flow control restriction, it can be determined whether the pending request will trigger the flow control restriction.
[0062] For example, if there is a flow control restriction on the request initiated by the downstream system a to the upstream system, after the server obtains the access address information, it determines that the access address information corresponds to the downstream system a, and then the server determines that the pending request will trigger the flow control restriction.
[0063] It should be noted that flow control refers to a mechanism used in network communications to prevent data packets from being sent too quickly and causing the receiver to be unable to process them in time. It usually limits the number or frequency of requests to ensure processing stability.
[0064] Step S30: if flow control restriction is triggered, a target priority is assigned to the pending request based on the request source information, and the pending request is queued based on the target priority;
[0065] Further, after determining whether the pending request will trigger the flow control restriction, if it is determined that the pending request will not trigger the flow control restriction, the pending request can be directly processed; if it is determined that the pending request will trigger the flow control restriction, the pending request cannot be directly processed, refer to Figure 2 .
[0066] Specifically, when it is determined that the pending request will trigger flow control restrictions, a target priority can be assigned to the pending request based on the request source information; it can be understood that more than one upstream system will call the server interface (initiate pending requests), and the importance of different upstream systems is different. If a first-in-first-out request queue processing mechanism is used to process requests initiated by upstream systems, important pending requests will not be processed in a timely manner, thereby reducing the request success rate.
[0067] Therefore, the server assigns a target priority to the pending request based on the request source information, thereby assigning corresponding priorities to pending requests of different importance. For example, a higher priority can be assigned to a more important pending request, that is, the importance of the pending request is positively correlated with the priority. The server can obtain the request source information from the request header of the pending request, or can obtain the request source information by parsing the content of the request body. The method of obtaining the request source information can be defined by the interacting parties.
[0068] Specifically, there is a preset correlation between the importance of the pending request and the request source information. For example, if the request source information indicates that the pending request is initiated by a high-level customer system or a fault alarm system, the importance is relatively high. If the request source information indicates that the pending request is initiated by a low-level customer system, the importance is relatively low, etc.; this preset correlation can be dynamically adjusted according to actual conditions.
[0069] Furthermore, based on the target priority, the pending requests are queued for processing, which is conducive to solving the problem of failure to process important pending requests in a timely manner due to the first-in-first-out request queue processing mechanism in the related art.
[0070] It can be understood that in the request queue obtained by enqueuing the pending requests based on the target priority, each request has a corresponding priority.
[0071] Specifically, the specific implementation method of enqueuing the pending request based on the target priority may be:
[0072] Based on the target priority, the pending request is added to a target priority queue to complete the enqueue processing; wherein the target priority queue is a request queue corresponding to the target request path of the pending request, and the target request path is a request path with flow control restrictions.
[0073] It should be noted that since the request paths of different downstream systems are different, when there are flow control restrictions in the downstream systems, multiple requests sent to the same downstream system with flow control restrictions can be added to the same queue, that is, multiple requests sent to the same target request path can be added to the same queue. Since the request queue corresponding to the target request path is called a target priority queue, multiple requests sent to the same target request path can be added to the same target priority queue to facilitate queue management.
[0074] Specifically, the specific implementation of adding the pending request to the target priority queue based on the target priority may be:
[0075] Based on the target priority and the priority of each queued request in the target priority queue, the requests in the target priority queue are arranged from high to low priority to add the pending requests to the target priority queue; it can be understood that the requests in the obtained target priority queue are arranged from high to low priority, that is, the head element of the target priority queue is the pending request with the highest priority in the target priority queue.
[0076] Before adding the pending request to the target priority queue, the relevant information of the pending request needs to be encapsulated into an entity, including the target priority, the original pending request (including request method, request header, request body, etc.), request time, etc.
[0077] Specifically, the specific implementation of adding the pending request to the target priority queue based on the target priority may also be:
[0078] Based on the target priority, the priority of the previous request in the target priority queue that is adjacent to the request to be added is compared. If the priority of the previous request is lower than the target priority, the arrangement positions of the two requests are swapped until the priority of the previous request is higher than the target priority.
[0079] Step S40: If the current time reaches the preset flow control limit time, the pending request is dequeued based on the target priority.
[0080] It should be noted that for pending requests on the same request path, there is a corresponding same priority queue, and different priority queues have different preset flow control limit times. For example, if the preset flow control limit time of the target priority queue is 11:20:50, and the current time is 11:20:49, then the current time has not reached the preset flow control limit time; if the preset flow control limit time of the target priority queue is 11:20:50, and the current time is 11:20:51, then the current time has reached the preset flow control limit time.
[0081] It can be understood that when the current time reaches the preset flow control limit time, it is considered that the downstream system has no flow control limit on the pending request, that is, the downstream system can respond to the pending request. Therefore, when the current time reaches the preset flow control limit time, the server dequeues the pending request based on the target priority.
[0082] Specifically, if the current time reaches the preset flow control limit time, the specific implementation method of dequeuing the pending request based on the target priority may be:
[0083] If the current time reaches the preset flow control limit time, it is determined whether there is a queue request in the target priority queue; if so, the target request with the highest priority in the target priority queue is dequeued.
[0084] It can be understood that when the current time reaches the preset flow control limit time, by judging whether there is a queue request in the target priority queue, it can be determined whether the queue request in the target priority queue needs to be dequeued; if so, it is determined that the queue request in the target priority queue needs to be dequeued. In order to ensure the effectiveness of scheduling, the target request with the highest priority in the target priority queue can be dequeued.
[0085] Specifically, the higher the priority of the pending request, the higher the priority of the pending request, or the highest priority pending request at the head of the target priority queue may be dequeued, so that the server responds to the pending request (for example, sends the pending request to the corresponding downstream system, etc.), thereby improving the response efficiency.
[0086] Based on the above, refer to Figure 3The request processing device of this embodiment is also provided with a parsing module, a reservation module, a response module, a scheduling module (dequeue processing module), and a configuration module; wherein the parsing module is used to parse the pending requests to obtain access address information and request source information; the reservation module is used to determine whether it is necessary to discard the request from the end of the queue (i.e., discard the request with the lowest priority after priority sorting) according to the preset maximum queue length of the target priority queue during the process of enqueuing the pending requests based on the target priority; the response module is used to respond to the pending requests that will not trigger the flow control restriction; the configuration module is used to dynamically configure parameters, which include the target request path, the preset association relationship, the preset correspondence relationship, the preset time window of the target request path, the preset maximum queue length, the preset traversal waiting time, etc.
[0087] In this embodiment, by obtaining a pending request carrying access address information and request source information, based on the access address information and the preset correspondence between the access address and the flow control limit, it is determined whether the pending request will trigger the flow control limit, based on the request source information, a target priority is assigned to the request that will trigger the flow control limit, and based on the target priority, the pending request is queued, and if the current time reaches the preset flow control limit time, the pending request is dequeued based on the target priority; it can be understood that if the pending request will trigger the flow control limit, different priorities are assigned to pending requests with different request sources, and based on the target priority, the pending request is queued, so that outside the preset flow control limit time, the pending request with a high priority is preferentially dequeued; instead of using a first-in-first-out request queue processing mechanism to process the pending request, the pending request with a high priority will not be rejected by the downstream system due to being dequeued within the flow control limit time, thereby improving the request success rate and thus improving the response efficiency of the downstream system.
[0088] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 , before the step of dequeuing the pending request based on the target priority if the current time reaches the preset flow control limit time, the process includes steps S01-S02:
[0089] Step S01, traverse each of the preset priority queues, and determine whether the current time is less than the preset consumable time corresponding to each of the preset priority queues; wherein the preset consumable time is obtained by summing the last consumable time corresponding to the preset priority queue and the preset time window, and the last consumable time is the time when the queue request in the preset priority queue was last dequeued;
[0090] Step S02: If the current time is greater than or equal to the preset consumable time corresponding to the preset priority queue, it is determined that the current time reaches the preset flow control limit time.
[0091] It should be noted that different request paths correspond to different preset priority queues. The number of preset priority queues is consistent with the number of URLs with flow control restrictions configured in the server. Different preset priority queues correspond to different preset time windows. The preset time window refers to the response time interval set by the downstream system when performing flow control restrictions. For example, if the preset time window is 2 seconds, the downstream system will accept a request every 2 seconds. Starting from the last time a request was accepted, if it has not been 2 seconds, the downstream system will not accept any request.
[0092] Therefore, different preset priority queues correspond to different preset consumable times. It can be understood that if the preset time window has not passed since the last consumption, the preset priority queue is in an unconsumable state, that is, the preset consumable time is equal to the sum of the last consumable time corresponding to the preset priority queue and the preset time window. For example, the last consumable time is 11:50:50, and the preset time window is 2 seconds. Then the preset consumable time of the preset priority queue is 11:50:52.
[0093] Since the pending requests received by the server correspond to different request paths, there are correspondingly multiple priority queues that need to be processed; the server needs to traverse each of the preset priority queues and determine whether the current time is less than the preset consumable time corresponding to each of the preset priority queues. If the current time is greater than or equal to the preset consumable time corresponding to the currently traversed preset priority queue, it is determined that the current time has reached the preset flow control limit time; if the current time is less than the preset consumable time corresponding to the currently traversed preset priority queue, it is determined that the current time has not reached the preset flow control limit time, refer to Figure 5 .
[0094] It can be understood that if the current time is greater than or equal to the preset consumable time corresponding to the currently traversed preset priority queue, it can be determined whether there is a queue request in the currently traversed preset priority queue. If so, the pending request is dequeued based on the target priority. If not, the next preset priority queue is traversed until the traversal is completed. Figure 5 .
[0095] It should be noted that when the step of traversing each of the preset priority queues is started, the waiting time for the next traversal will be determined, and the waiting time required between every two traversals can be preset or dynamically adjusted.
[0096] Specifically, if there are no queued requests in all the preset priority queues that are traversed, the waiting time for the next traversal can be set to a preset value.
[0097] Further, in order to improve the request processing efficiency, after the step of determining whether the current time is less than the preset consumable time corresponding to each of the preset priority queues, the following feasible embodiments may also exist:
[0098] If the current time is less than the preset consumable time corresponding to the preset priority queue, then determine the waiting time for each of the preset priority queues based on the preset time window and the current time;
[0099] Determine whether the waiting time required by the preset priority queue is less than the waiting time of the next traversal; if less than the waiting time of the next traversal, set the waiting time of the next traversal to the waiting time required by the preset priority queue, referring to Figure 5 .
[0100] It can be understood that if the current time is less than the preset consumable time corresponding to the preset priority queue, the time required to wait is determined to be (last consumption time + preset time window - current time). If the waiting time required by the preset priority queue is less than the predetermined waiting time for the next traversal, the preset priority queue will be consumed before the next traversal. However, when the preset priority queue can be consumed, the preset priority queue has not been traversed, which will cause the preset priority queue to wait until it can be consumed and is being traversed before it can successfully perform the dequeue processing, affecting the dequeue efficiency.
[0101] Therefore, if the waiting time required by the preset priority queue is less than the waiting time of the next traversal, the waiting time of the next traversal is set to the waiting time required by the preset priority queue; thereby, when the preset priority queue is traversed next time, the preset priority queue can be consumed, thereby improving the dequeuing efficiency.
[0102] It should be noted that the preset time window is determined based on the regulations of the downstream system; the preset maximum queue length is set based on the maximum acceptable waiting time of the upstream system; and the initial consumable time of the preset priority queue is the queue creation time.
[0103] In a feasible embodiment, if the waiting time required for the preset priority queue is greater than or equal to the waiting time of the next traversal, the waiting time for the next traversal remains unchanged. If there is no queue request in the currently traversed preset priority queue, continue to traverse the next preset priority queue. When all preset priority queues are traversed, wait until the waiting time for the next traversal is reached, and then start the traversal again.
[0104] In order to further improve the request processing efficiency, after the step of enqueuing the pending requests based on the target priority, the following steps may be performed:
[0105] Determine whether the current time is greater than or equal to the target consumable time corresponding to the target priority queue; if the current time is greater than or equal to the target consumable time, determine whether the step of traversing each of the preset priority queues and determining whether the current time is less than the preset consumable time corresponding to each of the preset priority queues is being executed; if not executed, determine that the current time reaches the preset flow control limit time, so as to immediately execute the step of dequeuing the pending requests based on the target priority.
[0106] It should be noted that when the server is just started or has not received any pending requests for a long time, it is still necessary to wait for the above-mentioned waiting time for the next traversal, which will result in the pending requests received during this waiting period not being consumed in time.
[0107] Therefore, after the pending requests are enqueued based on the target priority, it can be directly determined whether the current time is greater than or equal to the target consumable time corresponding to the target priority queue. If the current time is greater than or equal to the target consumable time, it is determined whether the steps of traversing the preset priority queues and determining whether the current time is less than the preset consumable time corresponding to each preset priority queue are being executed. It can be understood that if the traversal has started, the pending requests received during this waiting period will not be unable to be consumed in time. If the traversal has not started yet, the step of dequeuing the pending requests based on the target priority will be executed immediately.
[0108] In this embodiment, the above method can solve the problem that when the preset priority queue can be consumed, but the preset priority queue has not been traversed, the preset priority queue needs to wait until it can be consumed and is being traversed before it can be successfully dequeued, affecting the dequeue efficiency; and solve the problem that when the server is just started or has not received any pending requests for a long time, it still needs to wait for the above-mentioned waiting time for the next traversal, which will cause the pending requests received during this waiting period to not be consumed in time, thereby improving the request success rate and thus improving the response efficiency of the downstream system.
[0109] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the request processing method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0110] This application also provides a request processing device, please refer to Figure 6 , the request processing device comprises:
[0111] The acquisition module 10 is used to acquire a pending request, wherein the pending request carries access address information and request source information;
[0112] A judgment module 20, configured to judge whether the pending request will trigger the flow control restriction based on the access address information and a preset correspondence between the access address and the flow control restriction;
[0113] An enqueue processing module 30, configured to assign a target priority to the pending request based on the request source information if flow control restriction is triggered, and to enqueue the pending request based on the target priority;
[0114] The dequeue processing module 40 is used to dequeue the pending request based on the target priority if the current time reaches the preset flow control limit time.
[0115] The request processing device provided by the present application adopts the request processing method in the above embodiment, which can solve the technical problem that when there is a flow control restriction in the downstream system, the request initiated by the upstream system within the flow control restriction time cannot be processed, thereby reducing the request success rate. Compared with the prior art, the beneficial effects of the request processing device provided by the present application are the same as the beneficial effects of the request processing method provided by the above embodiment, and the other technical features in the request processing device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0116] The present application provides a request processing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the request processing method in the above-mentioned embodiment one.
[0117] Reference below Figure 7, which shows a schematic diagram of the structure of a request processing device suitable for implementing the embodiment of the present application. The request processing device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, tablet computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The request processing 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 application.
[0118] like Figure 7 As shown, the request processing device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the request processing device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the request processing device to communicate with other devices wirelessly or by wire to exchange data. Although the request processing device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0119] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0120] The request processing device provided by the present application adopts the request processing method in the above embodiment, which can solve the technical problem that when there is a flow control restriction in the downstream system, the request initiated by the upstream system within the flow control restriction time cannot be processed, thereby reducing the request success rate. Compared with the prior art, the beneficial effects of the request processing device provided by the present application are the same as the beneficial effects of the request processing method provided by the above embodiment, and the other technical features in the request processing device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0121] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0122] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0123] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the request processing method in the above-mentioned embodiment.
[0124] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0125] The computer-readable storage medium may be included in the request processing device; or may exist independently without being assembled into the request processing device.
[0126] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the request processing device, the request processing device executes the request processing method.
[0127] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0128] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0129] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0130] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned request processing method, and can solve the technical problem that when there is a flow control restriction in the downstream system, the request initiated by the upstream system within the flow control restriction time cannot be processed, thereby reducing the request success rate. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the request processing method provided by the above-mentioned embodiment, and will not be elaborated here.
[0131] The present application also provides a computer program product, including a computer program, which implements the steps of the request processing method as described above when executed by a processor.
[0132] The computer program product provided by the present application can solve the technical problem that when there is a flow control limit in the downstream system, the request initiated by the upstream system within the flow control limit time cannot be processed, thereby reducing the request success rate. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the request processing method provided by the above embodiment, and will not be repeated here.
[0133] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A request processing method, characterized in that: The method includes: Obtaining a pending request, wherein the pending request carries access address information and request source information; Based on the access address information and a preset correspondence between the access address and the flow control limit, determining whether the pending request will trigger the flow control limit; If flow control restriction is triggered, a target priority is assigned to the pending request based on the request source information, and the pending request is queued based on the target priority; If the current time reaches the preset flow control limit time, the pending request is dequeued based on the target priority.
2. The method according to claim 1, characterized in that The step of enqueuing the pending requests based on the target priority comprises: Based on the target priority, adding the pending request to the target priority queue to complete the enqueue processing; Among them, the target priority queue is the request queue corresponding to the target request path of the request to be processed, and the target request path is the request path with flow control restrictions.
3. The method according to claim 1, characterized in that Different request paths correspond to different preset priority queues. If the current time reaches the preset flow control limit time, before the step of dequeuing the pending request based on the target priority, the method includes: Traversing each of the preset priority queues, and determining whether the current time is less than the preset consumable time corresponding to each of the preset priority queues; The preset consumable time is obtained by summing the last consumable time corresponding to the preset priority queue and the preset time window, and the last consumable time is the time when the queue request in the preset priority queue was last dequeued; If the current time is greater than or equal to the preset consumable time corresponding to the preset priority queue, it is determined that the current time reaches the preset flow control limit time.
4. The method according to claim 3, characterized in that When starting to execute the step of traversing each of the preset priority queues, determining the waiting time for the next traversal, after the step of judging whether the current time is less than the preset consumable time corresponding to each of the preset priority queues, it also includes: If the current time is less than the preset consumable time corresponding to the preset priority queue, then determine the waiting time for each of the preset priority queues based on the preset time window and the current time; Determine whether the waiting time required for the preset priority queue is less than the waiting time for the next traversal; If it is less than the waiting time for the next traversal, the waiting time for the next traversal is set to the waiting time of the preset priority queue.
5. The method according to claim 3, characterized in that After the step of enqueuing the pending requests based on the target priority, the method further includes: Determine whether the current time is greater than or equal to the target consumable time corresponding to the target priority queue; If the current time is greater than or equal to the target consumable time, determining whether the step of traversing each of the preset priority queues is being executed, and determining whether the current time is less than the preset consumable time corresponding to each of the preset priority queues; If not executed, it is determined that the current time reaches the preset flow control limit time, so as to immediately execute the step of dequeuing the pending requests based on the target priority.
6. The method according to claim 1, characterized in that The step of dequeuing the pending request based on the target priority if the current time reaches the preset flow control limit time includes: If the current time reaches the preset flow control limit time, determine whether there is a queue request in the target priority queue; If it exists, the target request with the highest priority in the target priority queue will be dequeued.
7. A request processing device, characterized in that: The device comprises: An acquisition module, used for acquiring a pending request, wherein the pending request carries access address information and request source information; A judgment module, used to judge whether the pending request will trigger the flow control restriction based on the access address information and the preset corresponding relationship between the access address and the flow control restriction; An enqueue processing module, configured to assign a target priority to the pending request based on the request source information if flow control restriction is triggered, and to enqueue the pending request based on the target priority; The dequeue processing module is used to dequeue the pending request based on the target priority if the current time reaches the preset flow control limit time.
8. A request processing device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the request processing method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the request processing method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the request processing method according to any one of claims 1 to 6 are implemented.
