High-concurrency request processing method and terminal

By creating a request buffer queue and merging requests in the high-concurrency request handling method, the problem of high database server load in the prior art is solved, and more efficient concurrent request handling is achieved.

CN121070580APending Publication Date: 2025-12-05FUJIAN HUAYU EDUCATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410715174.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2025-12-05

AI Technical Summary

Technical Problem

In existing technologies, high-concurrency request processing methods are not effective in reducing database server load, but instead increase the cost of server middleware.

Method used

By creating a request buffer queue, concurrent requests are merged and the merged requests are executed when the queue capacity is reached or a preset time interval is reached, the load on the database server is reduced.

Benefits of technology

It effectively reduces the load on the database server, decreases the number of times the database server is accessed, and improves the system's concurrent processing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121070580A_ABST
    Figure CN121070580A_ABST
Patent Text Reader

Abstract

The invention discloses a high-concurrency request processing method and a terminal, and the method comprises the steps: merging the concurrent requests in a request buffer queue when the number of the concurrent requests in the request buffer queue reaches the queue capacity, or when the time difference between the current time and the last merging time reaches a preset time interval, and obtaining a merged request, and the merged requests are executed to obtain a response result, so that even if a plurality of concurrent requests exist, the DB server is only penetrated once, and the load of the DB server is effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of request processing, in particular to a high-concurrency request processing method and a terminal. BACKGROUND

[0002] In distributed system applications, high-concurrency application scenarios are often encountered, at which point it is hoped that the load of a request DB (DataBase) server can be reduced to the greatest extent, in particular, some "invalid load" (such as identical repeated requests) is identified and filtered, so that the DB server can support a higher scale of concurrency and throughput capacity, and DB request connections are left for other effective requests to use.

[0003] In the prior art, an object information interface is usually obtained, and a cache server is built in front of a web application server, with an object ID as a cache, object detail information is cached in a high-performance memory, high-concurrency requests are made to the cache server, and the high-performance read-write efficiency of the cache server is utilized, so as to reduce the load of the web application server.

[0004] However, such a method only replaces a memory server to bear the high-concurrency load, and does not essentially reduce the load of the DB server, but instead increases the cost of a server middleware. SUMMARY

[0005] The technical problem to be solved by the present application is to provide a high-concurrency request processing method and a terminal, which can effectively reduce the load of a DB server.

[0006] In order to solve the above technical problems, the technical scheme adopted by the present application is as follows:

[0007] A high-concurrency request processing method, comprising the steps of:

[0008] acquiring a concurrent request and storing the concurrent request in a request buffer queue;

[0009] judging whether the number of concurrent requests in the request buffer queue reaches the queue capacity, if so, merging the concurrent requests in the request buffer queue to obtain a merged request, if not, judging whether the time difference between the current time and the last merging time reaches a preset time interval, if so, merging the concurrent requests in the request buffer queue to obtain a merged request, if not, not merging and returning to execute the step of judging whether the number of concurrent requests in the request buffer queue reaches the queue capacity;

[0010] executing the merged request to obtain a response result.

[0011] In order to solve the above technical problems, another technical scheme adopted by the present application is as follows:

[0012] A high-concurrency request processing terminal comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:

[0013] Obtain a concurrent request and store the concurrent request in a request buffer queue;

[0014] Determine whether the number of concurrent requests in the request buffer queue reaches the queue capacity, if yes, merge the concurrent requests in the request buffer queue to obtain a merged request, if no, determine whether the time difference between the current time and the time of the last merging reaches a preset time interval, if yes, merge the concurrent requests in the request buffer queue to obtain a merged request, if no, do not merge and return to determine whether the number of concurrent requests in the request buffer queue reaches the queue capacity;

[0015] Execute the merged request to obtain a response result.

[0016] The application has the beneficial effect that when the number of concurrent requests in the request buffer queue reaches the queue capacity or when the time difference between the current time and the time of the last merging reaches the preset time interval, the concurrent requests in the request buffer queue are merged to obtain a merged request, and the merged request is executed to obtain a response result, so even if there are multiple concurrent requests, the DB server is only penetrated once, thereby effectively reducing the load of the DB server. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 A step flow chart of a high-concurrency request processing method of an embodiment of the application;

[0018] Figure 2 A structural schematic diagram of a high-concurrency request processing terminal of an embodiment of the application;

[0019] Figure 3 A request merging flow chart of a high-concurrency request processing method of an embodiment of the application. DETAILED DESCRIPTION

[0020] The technical content, purposes and effects of the application will be described in detail below in combination with the embodiments and the accompanying drawings.

[0021] Please refer to Figure 1 A high-concurrency request processing method comprises the following steps:

[0022] Obtain a concurrent request and store the concurrent request in a request buffer queue;

[0023] determining whether the number of concurrent requests in the request buffer queue reaches the queue capacity, if yes, merging the concurrent requests in the request buffer queue to obtain a merged request, if no, determining whether the time difference between the current time and the last merging time reaches a preset time interval, if yes, merging the concurrent requests in the request buffer queue to obtain a merged request, if no, not merging and returning to the step of determining whether the number of concurrent requests in the request buffer queue reaches the queue capacity;

[0024] executing the merged request to obtain a response result.

[0025] From the above description, the beneficial effects of the present application are that when the number of concurrent requests in the request buffer queue reaches the queue capacity, or when the time difference between the current time and the last merging time reaches the preset time interval, the concurrent requests in the request buffer queue are merged to obtain a merged request, and the merged request is executed to obtain a response result, so that even if there are multiple concurrent requests, the DB server is only penetrated once, thereby effectively reducing the load of the DB server.

[0026] Further, before the concurrent request is obtained, the method further comprises:

[0027] creating a request buffer queue and initializing the queue capacity of the request buffer queue to a preset value.

[0028] From the above description, the request buffer queue is created and the queue capacity of the request buffer queue is initialized to a preset value, so as to buffer the current concurrent request.

[0029] Further, after the concurrent request is obtained, the method further comprises:

[0030] calculating the tag value of the concurrent request and establishing the association between the tag value and the current queue capacity.

[0031] From the above description, by establishing the association between the tag value of the concurrent request and the current queue capacity, the queue capacity corresponding to the concurrent request can be understood through the tag value of the concurrent request in the subsequent process, so as to determine the queue capacity elasticity adjustment.

[0032] Further, the method further comprises:

[0033] obtaining historical concurrent requests and their tag values according to a preset statistical period, and obtaining the queue capacity corresponding to the historical concurrent requests according to the tag values;

[0034] if the number of the historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, reducing the current queue capacity based on the number of the historical concurrent requests.

[0035] if the number of the historical concurrent requests continuously reaches the queue capacity for a preset number of times, increasing the current queue capacity based on the number of the historical concurrent requests.

[0036] As described above, if the number of the historical concurrent requests continuously reaches the queue capacity for a preset number of times, increasing the current queue capacity based on the number of the historical concurrent requests, and if the number of the historical concurrent requests continuously reaches the queue capacity for a preset number of times, increasing the current queue capacity based on the number of the historical concurrent requests, thereby elastically adjusting the queue capacity. When the number of the concurrent requests continuously increases, the adaptively increased queue capacity can ensure that the concurrent requests only need to be merged once, and when the number of the concurrent requests continuously decreases, the adaptively decreased queue capacity timely merges the requests, thereby more effectively reducing the load of the DB server.

[0037] Further, the decreasing the current queue capacity based on the number of the historical concurrent requests comprises:

[0038] acquiring the number of the last concurrent request from the number of the historical concurrent requests, and taking the number of the last concurrent request as the current queue capacity.

[0039] As described above, the number of the last concurrent request is acquired from the number of the historical concurrent requests, and the number of the last concurrent request is taken as the current queue capacity, thereby effectively adjusting the queue capacity and ensuring that the requests can be timely processed.

[0040] Please refer to Figure 2 A high-concurrent-request processing terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:

[0041] acquiring a concurrent request and storing the concurrent request in a request buffer queue;

[0042] judging whether the number of the concurrent requests in the request buffer queue reaches a queue capacity, if yes, merging the concurrent requests in the request buffer queue to obtain a merged request, if no, judging whether a time difference between a current time and a time of last merging reaches a preset time interval, if yes, merging the concurrent requests in the request buffer queue to obtain a merged request, if no, not merging and returning to the step of judging whether the number of the concurrent requests in the request buffer queue reaches the queue capacity;

[0043] executing the merged request to obtain a response result.

[0044] From the above description, the beneficial effects of the present application are that when the number of concurrent requests in the request buffer queue reaches the queue capacity, or when the time difference between the current time and the last merging time reaches the preset time interval, the concurrent requests in the request buffer queue are merged to obtain the merged request, the merged request is executed to obtain the response result, so that even if there are multiple concurrent requests, the DB server is equivalent to being penetrated only once, thereby effectively reducing the load of the DB server.

[0045] Further, before the concurrent request is obtained, the method further comprises:

[0046] The request buffer queue is created, and the queue capacity of the request buffer queue is initialized to a preset value.

[0047] From the above description, the request buffer queue is created, and the queue capacity of the request buffer queue is initialized to a preset value, so as to buffer the current concurrent request.

[0048] Further, after the concurrent request is obtained, the method further comprises:

[0049] The tag value of the concurrent request is calculated, and the association between the tag value and the current queue capacity is established.

[0050] From the above description, by establishing the association between the tag value of the concurrent request and the current queue capacity, the queue capacity corresponding to the concurrent request can be understood through the tag value of the concurrent request in the future, so as to make a judgment on the elastic adjustment of the queue capacity.

[0051] Further, the method further comprises:

[0052] The historical concurrent requests and their tag values are obtained according to a preset statistical period, and the queue capacity corresponding to the historical concurrent requests is obtained according to the tag values;

[0053] If the number of the historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, the current queue capacity is reduced based on the number of the historical concurrent requests;

[0054] If the number of the historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, the current queue capacity is increased based on the number of the historical concurrent requests.

[0055] As can be seen from the above description, if the number of historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, the current queue capacity is reduced based on the number of historical concurrent requests, and if the number of historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, the current queue capacity is increased based on the number of historical concurrent requests, so as to elastically adjust the queue capacity. When the number of concurrent requests continuously increases, the adaptively increased queue capacity can also ensure that the concurrent requests only need to be merged once, and when the number of concurrent requests continuously decreases, the adaptively reduced queue capacity timely merges the requests, so as to more effectively reduce the load of the DB server.

[0056] Further, the reducing the current queue capacity based on the number of historical concurrent requests comprises:

[0057] acquiring the number of last concurrent requests from the number of historical concurrent requests, and taking the number of last concurrent requests as the current queue capacity.

[0058] As can be seen from the above description, the number of last concurrent requests is acquired from the number of historical concurrent requests, and the number of last concurrent requests is taken as the current queue capacity, so as to effectively adjust the queue capacity and ensure that the requests can be timely processed.

[0059] The high-concurrent-request processing method and the terminal described above can be applied to a high-concurrent scenario, and the following specific embodiments are described:

[0060] Please refer to Figure 1 and Figure 3 , and the first embodiment of the present application is:

[0061] A high-concurrent-request processing method comprises the following steps:

[0062] S1, creating a request buffer queue (RequestQueue) and initializing the queue capacity of the request buffer queue to a preset value.

[0063] The preset value is flexibly set according to actual conditions.

[0064] S2, acquiring a concurrent request and storing the concurrent request in the request buffer queue.

[0065] S3, calculating a tag value of the concurrent request and establishing an association between the tag value and the current queue capacity.

[0066] In an optional embodiment, the MD5 value of the concurrent request is calculated and taken as the tag value of the concurrent request.

[0067] S4, judging whether the number of concurrent requests in the request buffer queue reaches the queue capacity, if yes, merging the concurrent requests in the request buffer queue to obtain the merged request, if no, judging whether the time difference between the current time and the time of last merging reaches the preset time interval, if yes, merging the concurrent requests in the request buffer queue to obtain the merged request, if no, not merging and returning to execute S4, and so on. Figure 3

[0068] In an optional implementation, whether the time difference between the current time and the time of last merging reaches the preset time interval is automatically judged by creating a timer task (TimerTask). The preset time interval is flexibly set according to actual conditions.

[0069] For example, assuming that the preset value of the queue capacity initialization is 5 and the preset time interval is 6s, when the number of concurrent requests in the request buffer queue reaches 5, the concurrent requests in the request buffer queue are merged, if the number of concurrent requests in the request buffer queue does not reach 5, but the time difference between the current time and the time of last merging reaches 6s, the concurrent requests in the request buffer queue are also merged.

[0070] In an optional implementation, the concurrent requests in the request buffer queue are merged by creating a HystrixCommand command to obtain the merged request.

[0071] S5, executing the merged request to obtain a response result.

[0072] In an optional implementation, as shown in Figure 3 , it further includes:

[0073] S6, returning the response result.

[0074] In an optional implementation, the mapResponseToRequests method is created to map the response result to each individual request.

[0075] In an optional implementation, as shown in Figure 3 , it further includes:

[0076] S7, obtaining historical concurrent requests and their tag values according to a preset statistical period, and obtaining the queue capacity corresponding to the historical concurrent requests according to the tag values.

[0077] ​The preset statistical period can be flexibly set according to actual conditions. In an optional implementation, the preset statistical period is 5 minutes. For example, the historical concurrent request and the label value thereof are acquired once every 5 minutes, and the queue capacity corresponding to the historical concurrent request is acquired according to the label value.

[0078] S8, if the number of historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, reducing the current queue capacity based on the number of historical concurrent requests;

[0079] The reducing the current queue capacity based on the number of historical concurrent requests includes:

[0080] acquiring the number of last concurrent request from the number of historical concurrent requests, and taking the number of last concurrent request as the current queue capacity.

[0081] For example, assuming that the preset number of times is 3, the current queue capacity is 10, the number of historical concurrent requests is 5, 5, 6 and 7 respectively, and the queue capacity corresponding to the historical concurrent requests is 10, 10, 10 and 10 respectively, there is a case that the number of historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for 3 times in succession, at this time, the current queue capacity is changed from 10 to 7. In this way, the queue capacity is adaptively adjusted according to the number of historical concurrent requests, and the high-concurrent request can be responded in time.

[0082] S9, if the number of historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, increasing the current queue capacity based on the number of historical concurrent requests.

[0083] The increasing the current queue capacity based on the number of historical concurrent requests includes:

[0084] acquiring the number of last concurrent request from the number of historical concurrent requests, and taking the number of last concurrent request as the current queue capacity.

[0085] For example, assuming that the preset number of times is 3, the current queue capacity is 10, the number of historical concurrent requests is 10, 30, 50 and 100 respectively, and the queue capacity corresponding to the historical concurrent requests is 10, 10, 10 and 10 respectively, there is a case that the number of historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for 3 times in succession, at this time, the current queue capacity is changed from 10 to 100. In this way, the high-concurrent request can be sent to the DB server only once as much as possible, so as to effectively reduce the load of the DB server.

[0086] The S7-S9 can be executed synchronously with the S1-S6.

[0087] Please refer to Figure 2 Embodiment two of the present application is:

[0088] A high-concurrency request processing terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements each step in the high-concurrency request processing method of embodiment one when executing the computer program.

[0089] In summary, the present application provides a high-concurrency request processing method and terminal. When the number of concurrent requests in the request buffer queue reaches the queue capacity, or when the time difference between the current time and the last merging time reaches the preset time interval, the concurrent requests in the request buffer queue are merged to obtain the merged request, and the merged request is executed to obtain the response result. In this way, even if there are multiple concurrent requests, the DB server is only penetrated once, thereby effectively reducing the load of the DB server. In addition, if the number of historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a continuous preset number of times, the current queue capacity is reduced based on the number of historical concurrent requests, and if the number of historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for a continuous preset number of times, the current queue capacity is increased based on the number of historical concurrent requests. In this way, the queue capacity is elastically adjusted. When the number of concurrent requests is continuously increasing, the adaptively increased queue capacity can ensure that these concurrent requests only need to be merged once. When the number of concurrent requests is continuously decreasing, the adaptively reduced queue capacity timely merges the requests, thereby more effectively reducing the load of the DB server.

[0090] The above is only an embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent transformation or direct or indirect application in related technical fields based on the content of the present application specification and drawings is also included in the patent protection scope of the present application.

Claims

1. A high-concurrency request processing method, characterized in that, The method comprises the steps of: acquiring a concurrent request and storing the concurrent request in a request buffer queue; determining whether the number of concurrent requests in the request buffer queue reaches a queue capacity, if yes, merging the concurrent requests in the request buffer queue to obtain a merged request, if no, determining whether a time difference between a current time and a time of last merging reaches a preset time interval, if yes, merging the concurrent requests in the request buffer queue to obtain the merged request, if no, not merging and returning to the step of determining whether the number of concurrent requests in the request buffer queue reaches the queue capacity; executing the merged request to obtain a response result.

2. The high-concurrency request processing method according to claim 1, characterized in that, Before the step of acquiring the concurrent request, the method further comprises the steps of: creating the request buffer queue and initializing a queue capacity of the request buffer queue to a preset value.

3. The high-concurrency request processing method according to claim 2, characterized in that, After the step of acquiring the concurrent request, the method further comprises the steps of: calculating a label value of the concurrent request and establishing an association between the label value and a current queue capacity.

4. The high-concurrency request processing method according to claim 3, characterized in that, The method further comprises the steps of: acquiring historical concurrent requests and label values of the historical concurrent requests according to a preset statistical period, and acquiring a queue capacity corresponding to the historical concurrent requests according to the label values; if the number of the historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, reducing the current queue capacity based on the number of the historical concurrent requests; if the number of the historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for the preset number of times in succession, increasing the current queue capacity based on the number of the historical concurrent requests.

5. The high-concurrency request processing method according to claim 4, characterized in that, The step of reducing the current queue capacity based on the number of the historical concurrent requests comprises the steps of: acquiring a number of last concurrent requests from the number of the historical concurrent requests, and taking the number of the last concurrent requests as the current queue capacity.

6. A high-concurrency request processing terminal comprising a memory, a processor, and a computer program stored on the memory and capable of running on the processor, characterized in that, When the processor executes the computer program, the following steps are implemented: acquiring a concurrent request and storing the concurrent request in a request buffer queue; determining whether the number of concurrent requests in the request buffer queue reaches a queue capacity, if yes, merging the concurrent requests in the request buffer queue to obtain a merged request, if no, determining whether a time difference between a current time and a time of last merging reaches a preset time interval, if yes, merging the concurrent requests in the request buffer queue to obtain the merged request, if no, not merging and returning to the step of determining whether the number of concurrent requests in the request buffer queue reaches the queue capacity; executing the merged request to obtain a response result.

7. The high-concurrency request processing terminal according to claim 6, characterized in that, Before the step of acquiring the concurrent request, the method further comprises the steps of: creating the request buffer queue and initializing a queue capacity of the request buffer queue to a preset value.

8. The high-concurrency request processing terminal according to claim 7, characterized in that, After the step of acquiring the concurrent request, the method further comprises the steps of: calculating a label value of the concurrent request and establishing an association between the label value and a current queue capacity.

9. The high-concurrency request processing terminal according to claim 8, characterized in that, The method further comprises the steps of: acquiring historical concurrent requests and label values of the historical concurrent requests according to a preset statistical period, and acquiring a queue capacity corresponding to the historical concurrent requests according to the label values; if the number of the historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a preset number of times in succession, reducing the current queue capacity based on the number of the historical concurrent requests; if the number of the historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for the preset number of times in succession, increasing the current queue capacity based on the number of the historical concurrent requests. if the number of the historical concurrent requests is less than the queue capacity corresponding to the historical concurrent requests for a preset number of times continuously, reducing the current queue capacity based on the number of the historical concurrent requests; if the number of the historical concurrent requests is greater than the queue capacity corresponding to the historical concurrent requests for a preset number of times continuously, increasing the current queue capacity based on the number of the historical concurrent requests.

10. The high-concurrency request processing terminal of claim 9, wherein, The reducing the current queue capacity based on the number of the historical concurrent requests comprises: acquiring a last concurrent request number from the number of the historical concurrent requests, and taking the last concurrent request number as the current queue capacity.

Citation Information

Cited By

  • A method for request aggregation and dynamic scheduling based on lock contention, electronic devices, and application products.

    CN122412173A