Distributed concurrent request control method, device, equipment and medium

By deleting timeout requests and renewal tasks in the concurrent queue, combined with hierarchical processing of concurrent requests, the problem of system crash and concurrent requests not being released under the current current limiting method is solved, ensuring system stability and high performance.

CN117742923BActive Publication Date: 2024-09-13SHANGHAI SHUHE INFORMATION TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202311806274.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-26
Publication Date
2024-09-13
Estimated Expiration
2043-12-26

AI Technical Summary

Technical Problem

In the scenario of slow request response, the existing current limiting method will lead to an increase in the number of concurrent requests when the system processing time is long, which may cause the system to crash, and concurrent requests are not released, resulting in the inability to automatically clean up after the application goes down, affecting system stability. .

Method used

By deleting timed-out concurrent requests in the concurrent queue and updating the request time through renewal tasks, we ensure that concurrent requests will not be accidentally deleted due to timeouts. At the same time, concurrent requests are processed hierarchically, and requests with high priority are processed first to avoid system load. Too heavy.

Benefits of technology

It realizes automatic cleaning of concurrent requests after abnormal application downtime to ensure system stability, and prioritizes important tasks through hierarchical processing to avoid system crashes and improves the high performance and stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117742923B
    Figure CN117742923B
Patent Text Reader

Abstract

The present invention relates to a distributed concurrent request control method, device, equipment and medium. The method comprises: an application step, submitting a new concurrent request; an acquisition step, acquiring a concurrent queue; a deletion step, deleting concurrent requests that have timed out in the concurrent queue; a calculation step, calculating the number of requests in the concurrent queue; and a processing step, judging whether to accept the new concurrent request based on the number of requests. By deleting concurrent requests that have timed out in the concurrent queue, the problem of concurrent requests not being released due to application downtime after acquiring concurrent requests is solved, and by renewing tasks, the current concurrent request will not be deleted due to timeout.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a distributed concurrent request control method, device, equipment and medium. Background Art

[0002] The commonly used current limiting methods currently available include token buckets, leaky buckets, sliding windows, and other current limiting methods. These current limiting methods are based on the number of requests received by the system in a certain unit of time. The longer the time, the more requests will enter the system. In scenarios where the request response is slow, that is, the system processing time is long, as time goes by, the number of requests processed simultaneously in the system increases, which may eventually cause the system to crash. These current limiting methods are similar to limiting the number of people entering a park per second at the entrance, but if the visitors spend a long time playing, the park will be fully loaded. Therefore, the existing current limiting methods are prone to full-load crashes in some cases. Summary of the invention

[0003] Based on this, in order to solve the above problems, this paper proposes a distributed concurrent request control method, device, equipment and medium. By deleting the concurrent requests that have timed out in the concurrent queue, the problem of the concurrent requests not being released due to the application crashing after obtaining the concurrent requests is solved, and by renewing the task, the current concurrent requests will not be deleted due to timeout.

[0004] According to a first aspect of the present invention, a distributed concurrent request control method is provided, characterized in that it comprises the following steps:

[0005] Application step, submit new concurrent request;

[0006] Acquisition step, to acquire concurrent queues;

[0007] Delete step, delete the concurrent requests that have timed out in the concurrent queue;

[0008] Calculation step, calculate the number of requests in the concurrent queue;

[0009] A processing step is to determine whether to accept the new concurrent request based on the request amount.

[0010] In some embodiments, it also includes a renewal step, in which the request time of the current concurrency is updated through a renewal task in the application so that the current concurrency obtained by the application will not be deleted due to timeout.

[0011] In some embodiments, deleting concurrent requests that have timed out in the concurrent queue includes: setting a timeout period, subtracting the request time of the concurrent request from the current time to obtain the existence time, and deleting concurrent requests in the concurrent queue whose existence time is greater than the timeout period.

[0012] In some embodiments, determining whether to accept the new concurrent request based on the request amount includes: comparing the request amount with a set threshold, accepting the new concurrent request if the request amount is less than the set threshold, otherwise not accepting the new concurrent request.

[0013] In some embodiments, the concurrent queue stores the request time and unique ID of the concurrent request, and inserting, deleting, and querying the concurrent request in the concurrent queue are implemented through the unique ID.

[0014] In some embodiments, the processing steps include: classifying the new concurrent requests into three categories: high priority, medium priority, and low priority according to their priorities; dividing the concurrent queues into concurrent queue A and concurrent queue B;

[0015] When the priority of the new concurrent request is high, first determine whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A. If not, the new concurrent request will enter concurrent queue A; otherwise, determine whether the number of concurrent requests in concurrent queue B has reached the set upper limit of concurrent queue B. If not, the new concurrent request will enter concurrent queue B; otherwise, the new concurrent request will enter the deferred processing queue, and enter concurrent queue A or concurrent queue B when the number of concurrent requests in concurrent queue A or concurrent queue B is less than the set upper limit;

[0016] When the new concurrent request is of medium priority, determine whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A. If not, enter the new concurrent request into concurrent queue A; otherwise, reject the new concurrent request;

[0017] When the priority of the new concurrent request is low, it is determined whether the number of concurrent requests in concurrent queue A has reached the set value of concurrent queue A. If not, the new concurrent request is put into concurrent queue A; otherwise, the new concurrent request is rejected;

[0018] The set value of the concurrent queue A is less than the set upper limit of the concurrent queue A.

[0019] According to a second aspect of the present invention, there is provided a distributed concurrent request control device, comprising:

[0020] Application module, used to submit new concurrent requests;

[0021] Acquisition module, used to acquire concurrent queues;

[0022] The deletion module is used to delete concurrent requests that have timed out in the concurrent queue;

[0023] The calculation module is used to calculate the number of requests in the concurrent queue;

[0024] A processing module is used to determine whether to accept the new concurrent request according to the request amount.

[0025] In some embodiments, it also includes a renewal module, which is used to update the request time of the current concurrency through the renewal task in the application so that the current concurrency obtained by the application will not be deleted due to timeout.

[0026] According to a third aspect of the present invention, there is provided a computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above-mentioned method embodiments when executing the computer program.

[0027] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method of any of the above embodiments are implemented.

[0028] By implementing the above solution of the present invention, the following beneficial effects can be obtained:

[0029] 1. When the application crashes abnormally after acquiring concurrency and does not release concurrency before crashing, it can automatically clean up the problem of concurrency not being released due to crashing. After the application acquires concurrency, it regularly updates the request time to ensure that it will not be cleaned up by other threads due to timeout.

[0030] 2. By saving the concurrent request time and the globally unique ID in the concurrent queue, it is ensured that in the event of a downtime, the application service can still delete the concurrent data of the downtime according to the timeout parameter and the request time data in the queue. The globally unique ID can provide the ability to quickly insert, delete, and query, which can meet the high performance of the concurrent control system.

[0031] 3. Perform hierarchical processing on concurrent requests to ensure that important tasks are processed first under high load conditions and to ensure system stability. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 is a flow chart of some embodiments of the distributed concurrent request control method of the present invention;

[0033] Figure 2 is a timing diagram of some embodiments of the distributed concurrent request control method of the present invention;

[0034] Figure 3 is a schematic diagram of concurrent queue data structure design in some embodiments of the present invention;

[0035] Figure 4 It is a schematic diagram of the structure of some embodiments of the distributed concurrent request control device of the present invention;

[0036] Figure 5 It is a diagram of the internal structure of a computer device used to implement some embodiments of the present invention. DETAILED DESCRIPTION

[0037] Embodiments of the present invention will be described more fully below with reference to the accompanying drawings, in which embodiments of the present invention are shown. However, the present invention can be embodied in many different forms and should not be construed as limited to the embodiments set forth herein.

[0038] The terms used herein are used only for the purpose of describing specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a", "an", "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that when used herein, the term "comprising" specifies the presence of the claimed features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof.

[0039] Unless otherwise defined, the terms (including technical and scientific terms) used herein have the same meanings as commonly understood by those of ordinary skill in the art to which the present disclosure belongs. The terms used herein should be interpreted as having the meanings consistent with their meanings in the context of this specification and in the relevant field, and should not be interpreted in an idealized or overly formal sense, unless specifically defined as such herein.

[0040] Figure 1 The flowcharts of some embodiments of the distributed concurrent request control method of the present invention are shown.

[0041] like Figure 1 As shown, the method includes:

[0042] Application step S102, submitting a new concurrent request;

[0043] Acquisition step S104, acquiring a concurrent queue;

[0044] In some embodiments, the concurrent queue is obtained according to the concurrent key. The concurrent key is a corresponding parameter passed in according to the requirement of limiting concurrency, such as: if the concurrency is limited to a certain interface, the unique ID of the interface is passed in; if the concurrency is limited to all interfaces of a certain application, the unique ID of the application is passed in.

[0045] Delete step S106, delete the concurrent request that has timed out in the concurrent queue;

[0046] In some embodiments, deleting concurrent requests that have timed out in the concurrent queue includes: setting a timeout period, subtracting the request time of the concurrent request from the current time to obtain the existence time, and deleting concurrent requests in the concurrent queue whose existence time is greater than the timeout period.

[0047] Calculation step S108, calculating the number of requests in the concurrent queue;

[0048] Processing step S110, determining whether to accept the new concurrent request according to the request amount.

[0049] In some embodiments, determining whether to accept the new concurrent request based on the request amount includes: comparing the request amount with a set threshold, accepting the new concurrent request if the request amount is less than the set threshold, otherwise not accepting the new concurrent request.

[0050] In addition, in order to ensure that the concurrency acquired by the application will not be deleted due to timeout, some embodiments also include a renewal step, adding a renewal task to the background scheduled task of the application, and updating the request time in the concurrency control system at regular intervals to ensure that the current concurrency will not time out and will not be mistaken for a zombie application, causing the concurrency to be released.

[0051] In some embodiments, the concurrent queue stores the request time and unique ID of the concurrent request, and inserting, deleting, and querying the concurrent request in the concurrent queue are implemented through the unique ID. The unique ID can use UUID to uniquely mark this request.

[0052] In addition, when the number of concurrent requests exceeds the normal processing capacity of the system and affects the normal operation of the system, hierarchical processing is designed for new concurrent requests. According to different actual application scenarios, corresponding system load thresholds are set. When the load of the system processing concurrent requests exceeds the set threshold, hierarchical processing is enabled.

[0053] The hierarchical processing specifically includes: classifying new concurrent requests, and dividing new concurrent requests into three categories according to their priorities: high priority, medium priority, and low priority; dividing concurrent queues into concurrent queue A and concurrent queue B; when the new concurrent request has a high priority, first determine whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A, and if not, place the new concurrent request in concurrent queue A; otherwise, determine whether the number of concurrent requests in concurrent queue B has reached the set upper limit of concurrent queue B, and if not, place the new concurrent request in concurrent queue B; otherwise, place the new concurrent request in the deferred processing queue, and wait for the concurrent When the number of concurrent requests in queue A or concurrent queue B is less than the set upper limit, it enters concurrent queue A or concurrent queue B; when the new concurrent request is of medium priority, it is determined whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A. If not, the new concurrent request enters concurrent queue A; otherwise, the new concurrent request is rejected; when the new concurrent request is of low priority, it is determined whether the number of concurrent requests in concurrent queue A has reached the set value of concurrent queue A. If not, the new concurrent request enters concurrent queue A; otherwise, the new concurrent request is rejected; the set value of concurrent queue A is less than the set upper limit of concurrent queue A.

[0054] The priority classification can be classified according to the importance of concurrent requests, with high priority for high importance and low priority for low importance. In addition, the upper limits of concurrent queue A and concurrent queue B can be adjusted according to actual application scenarios.

[0055] Through the above-mentioned hierarchical processing, it is possible to give priority to concurrent requests with high priorities when the system load is high, and concurrent requests with high priorities will not be rejected. Different concurrent requests are managed hierarchically, which improves the stability of system operation.

[0056] Figure 2 The timing diagrams of some embodiments of the distributed concurrent request control method of the present invention are shown.

[0057] like Figure 2As shown in the figure, the user submits a request to an application service, and the application service applies for a concurrency to the concurrency control system. The concurrency control system feeds back the failure of the concurrency application or the success of the concurrency application to the application service. If the feedback is that the concurrency application fails, the application service feeds back the rejection of the request to the user; if the feedback is that the concurrency application succeeds, the application service processes the user request and renews the time of the concurrency request regularly. After the user request is processed, the renewal task is deleted and a concurrency is released, and the successful submission is fed back to the user. The scheduled renewal is implemented through the renewal task of the application service. The concurrency key generated by the application service and the unique ID that uniquely marks this request are used as two input parameters and transmitted to the concurrency control system to update the request time. The release of concurrency is also carried out by transmitting the concurrency key and the unique ID that uniquely marks this request as two input parameters to the concurrency control system. After the application service completes the processing of the business request, the concurrency control system finds the concurrent queue through the concurrency key and deletes the concurrent request data in the queue using the global unique ID.

[0058] Figure 3 A schematic diagram showing the concurrent queue data structure design of some embodiments of the present invention is shown. Figure 3 As shown in the figure, the queue is an ordered queue sorted by time. Timed out requests can be easily deleted and concurrent requests can be released. This data structure can be implemented in the ZSET data structure of Redis, where the request time can be stored in the score of ZSET and the globally unique ID of the request can be stored in the member of ZSET.

[0059] The present invention can automatically clean up the problem of concurrency not being released due to downtime through the design of a distributed concurrent request control method and a storage structure of a concurrent control system queue. Timed-out concurrent data can be actively cleaned up. After the application obtains the concurrency, the request time is regularly updated to ensure that it will not be cleaned up by other threads due to timeout. The application deletes the task of regularly updating the request time before releasing the concurrency. The queue stores the concurrent request time and the globally unique ID. Data with (current time - request time) > timeout time will be deleted, ensuring that the application service can still delete the downtime concurrent data according to the timeout time parameter and the request time data in the queue in a downtime scenario.

[0060] Figure 4 The schematic diagrams of the structures of some embodiments of the distributed concurrent request control device of the present invention are shown; Figure 4 As shown, the distributed concurrent request control device in the embodiment includes:

[0061] Application module 100, used to submit new concurrent requests;

[0062] The acquisition module 200 is used to acquire the concurrent queue;

[0063] A deletion module 300 is used to delete concurrent requests that have timed out in a concurrent queue;

[0064] A calculation module 400 is used to calculate the number of requests in the concurrent queue;

[0065] The processing module 500 is used to determine whether to accept the new concurrent request according to the request amount.

[0066] For the specific definition of a distributed concurrent request control device, please refer to the definition of a distributed concurrent request control method above, which will not be repeated here. Each module in the above-mentioned distributed concurrent request control device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0067] The present invention also provides a computer device, which may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the above-mentioned distributed concurrent request control method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc. Those skilled in the art can understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0068] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned distributed concurrent request control method is implemented.

[0069] Those skilled in the art can understand that all or part of the processes in the above method embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus), direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0070] So far, the embodiments of the present invention have been described in detail. In order to avoid obscuring the concept of the present invention, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solutions disclosed herein.

[0071] Although some specific embodiments of the present invention have been described in detail by way of examples, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It should be understood by those skilled in the art that the above embodiments may be modified or some technical features may be replaced by equivalents without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.

Claims

1. A distributed concurrent request control method, characterized in that: The following steps are involved: Application step, submit new concurrent request; Acquisition step, to acquire concurrent queues; Delete step, delete the concurrent requests that have timed out in the concurrent queue; Calculation step, calculate the number of requests in the concurrent queue; Processing step, determining whether to accept the new concurrent request according to the request amount; The processing steps include: classifying the new concurrent requests into three categories: high priority, medium priority, and low priority according to their priorities; dividing the concurrent queues into concurrent queue A and concurrent queue B; When the priority of the new concurrent request is high, first determine whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A. If not, the new concurrent request will enter concurrent queue A; otherwise, determine whether the number of concurrent requests in concurrent queue B has reached the set upper limit of concurrent queue B. If not, the new concurrent request will enter concurrent queue B; otherwise, the new concurrent request will enter the deferred processing queue, and enter concurrent queue A or concurrent queue B when the number of concurrent requests in concurrent queue A or concurrent queue B is less than the set upper limit; When the new concurrent request is of medium priority, determine whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A. If not, enter the new concurrent request into concurrent queue A; otherwise, reject the new concurrent request; When the priority of the new concurrent request is low, it is determined whether the number of concurrent requests in concurrent queue A has reached the set value of concurrent queue A. If not, the new concurrent request is put into concurrent queue A; otherwise, the new concurrent request is rejected; The set value of the concurrent queue A is less than the set upper limit of the concurrent queue A.

2. The distributed concurrent request control method according to claim 1, characterized in that: The method also includes a renewal step, in which the request time of the current concurrency is updated through the renewal task in the application so that the current concurrency obtained by the application will not be deleted due to timeout.

3. The distributed concurrent request control method according to claim 1, characterized in that: The deleting of concurrent requests that have timed out in the concurrent queue includes: setting a timeout time, subtracting the request time of the concurrent request from the current time to obtain the existence time, and deleting the concurrent requests in the concurrent queue whose existence time is greater than the timeout time.

4. The distributed concurrent request control method according to claim 1, characterized in that: The concurrent queue stores the request time and unique ID of the concurrent request, and inserting, deleting and querying the concurrent request in the concurrent queue are realized through the unique ID.

5. A distributed concurrent request control device, characterized in that: include: Application module, used to submit new concurrent requests; Acquisition module, used to acquire concurrent queues; The deletion module is used to delete concurrent requests that have timed out in the concurrent queue; The calculation module is used to calculate the number of requests in the concurrent queue; A processing module is used to determine whether to accept the new concurrent request according to the request amount, specifically including: classifying the new concurrent requests, and classifying the new concurrent requests into three categories according to their priorities: high priority, medium priority, and low priority; and dividing the concurrent queues into concurrent queue A and concurrent queue B; When the priority of the new concurrent request is high, first determine whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A. If not, the new concurrent request will enter concurrent queue A; otherwise, determine whether the number of concurrent requests in concurrent queue B has reached the set upper limit of concurrent queue B. If not, the new concurrent request will enter concurrent queue B; otherwise, the new concurrent request will enter the deferred processing queue, and enter concurrent queue A or concurrent queue B when the number of concurrent requests in concurrent queue A or concurrent queue B is less than the set upper limit; When the new concurrent request is of medium priority, determine whether the number of concurrent requests in concurrent queue A has reached the set upper limit of concurrent queue A. If not, enter the new concurrent request into concurrent queue A; otherwise, reject the new concurrent request; When the priority of the new concurrent request is low, it is determined whether the number of concurrent requests in concurrent queue A has reached the set value of concurrent queue A. If not, the new concurrent request is put into concurrent queue A; otherwise, the new concurrent request is rejected; The set value of the concurrent queue A is less than the set upper limit of the concurrent queue A.

6. The distributed concurrent request control device according to claim 5, characterized in that: It also includes a renewal module, which is used to update the request time of the current concurrency through the renewal task in the application so that the current concurrency obtained by the application will not be deleted due to timeout.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Server performance optimization method and system

    CN106302809A

  • Method, system and device for concurrently processing HTTP request

    CN110401697A

  • Distributed task scheduling method and device, electronic equipment and storage medium

    CN110858158A

  • Optimization method and device for executing priority tasks, computer equipment and medium

    CN111061556A

  • Method, system and device for scheduling plug-in tasks based on message queues and medium

    CN111367693A