CN-121984773-A - Request processing method, apparatus, computer device, readable storage medium, and program product
Abstract
The present application relates to a request processing method, apparatus, computer device, computer readable storage medium and computer program product. The method is applied to a server, a server is deployed on the server, a transmission control connection is pre-established between the server and a client, the server comprises a working thread group, the method comprises the steps of receiving request data sent by the client, acquiring a load state index value of the server under the condition that a target data channel corresponding to the transmission control connection is registered on a target working thread in the working thread group, transmitting the request data to the target working thread through the target data channel under the condition that the load state index value meets a preset request receiving condition, and processing the request data through the target working thread. The method can improve the request response speed.
Inventors
- YE HAO
Assignees
- 湖南长银五八消费金融股份有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260304
Claims (10)
- 1. The request processing method is characterized by being applied to a server, wherein a server is deployed on the server, the server and a client are pre-established with transmission control connection, the server comprises a working thread group, and the method comprises the following steps: receiving request data sent by the client; On the condition that a target data channel corresponding to the transmission control connection is registered on a target working thread in the working thread group, acquiring a load state index value of the server; transmitting the request data to the target working thread through the target data channel under the condition that the load state index value meets a preset request accepting condition; And processing the request data through the target working thread.
- 2. The method of claim 1, wherein the server comprises a central processor and a memory, the central processor is configured to provide computing resources for the worker thread group, the memory is configured to provide data storage space for the worker thread group, the load status index value comprises a first utilization of the central processor and a second utilization of the memory, the preset accept request condition comprises the first utilization being less than a preset first utilization threshold, and the second utilization being less than a preset second utilization threshold; After the obtaining the load state index value of the server, the method further includes: Determining that the load state index value meets a preset acceptance request condition under the condition that the first utilization rate is smaller than a preset first utilization rate threshold value and the second utilization rate is smaller than a preset second utilization rate threshold value; And under the condition that the first utilization rate is not smaller than a preset first utilization rate threshold value or the second utilization rate is not smaller than a preset second utilization rate threshold value, determining that the load state index value does not meet a preset acceptance request condition.
- 3. The method of claim 1, wherein the server further comprises a management thread group, wherein the work thread group comprises at least one work thread, and wherein after the receiving the request data sent by the client, the method further comprises: Under the condition that the target data channel corresponding to the transmission control connection is not registered on each working thread, acquiring a load state index value of the server side; Under the condition that the load state index value meets the preset request accepting condition, determining a target working thread from the working threads through a management thread group, and registering a target data channel corresponding to the transmission control connection on the target working thread; transmitting request data sent by the client to the target working thread through the target data channel; And processing the request data through the target working thread.
- 4. The method of claim 3, wherein the load status indicator value comprises an average processing time length of tasks and a total number of current tasks corresponding to each of the worker threads, and wherein determining a target worker thread from among the worker threads comprises: Estimating estimated processing time required by each working thread to process the request data according to the average processing time of the tasks and the total number of the current tasks corresponding to each working thread; and determining the working thread corresponding to the shortest estimated processing time length as a target working thread.
- 5. The method of claim 4, wherein the determining the worker thread corresponding to the shortest estimated processing time length as the target worker thread comprises: under the condition that the shortest estimated processing time length is smaller than or equal to a preset timeout time length threshold, determining a working thread corresponding to the shortest estimated processing time length as a target working thread; After estimating the estimated processing time required by each working thread to process the request data according to the average processing time of the tasks and the total number of the current tasks corresponding to each working thread, the method further comprises: Generating response data rejecting the request data under the condition that the shortest estimated processing time is longer than a preset timeout time threshold; and returning the response data to the client.
- 6. The method according to any one of claims 1 to 5, wherein after the obtaining the load status indicator value of the server, further comprises: generating response data rejecting the request data according to the load state index value under the condition that the load state index value does not meet a preset request accepting condition; and returning the response data to the client.
- 7. The request processing device is characterized by being applied to a server, wherein the server and a client pre-establish transmission control connection, the server comprises a working thread group, and the device comprises: the receiving module is used for receiving the request data sent by the client; the acquisition module is used for acquiring the load state index value of the server under the condition that the target data channel corresponding to the transmission control connection is registered on the target working thread in the working thread group; The transmission module is used for transmitting the request data to the target working thread through the target data channel under the condition that the load state index value meets the preset request accepting condition; And the processing module is used for processing the request data through the target working thread.
- 8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
- 9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
- 10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
Description
Request processing method, apparatus, computer device, readable storage medium, and program product Technical Field The present application relates to the field of computer technology, and in particular, to a request processing method, apparatus, computer device, computer readable storage medium, and computer program product. Background With the rapid development of internet application and high concurrency systems, a thread pool is used as a basic resource management mechanism, and is widely applied to a server architecture, and massive concurrency requests are processed by a support system through effective control and multiplexing of execution threads. In the traditional processing mode, each time a new request arrives at the server, the system allocates a separate thread to it to execute the complete processing of the request until the response returns. However, in a high concurrency or long connectivity scenario, since the processing threads are heavily occupied and blocked in I/O (Input/Output) waiting, the effective thread resources for processing the actual computing tasks decrease sharply, resulting in the overall throughput reaching the bottleneck, the CPU (Central Processing Unit , central processing unit) resources cannot be fully utilized, and the request response delay increases accordingly. Disclosure of Invention In view of the foregoing, it is desirable to provide a request processing method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the request response speed. In a first aspect, the present application provides a request processing method, applied to a server, where a server is deployed, and the server and a client pre-establish a transmission control connection, and the server includes a working thread group, where the method includes: receiving request data sent by a client; on a target working thread in a working thread group, under the condition that a target data channel corresponding to transmission control connection is registered, acquiring a load state index value of a server side; Transmitting the request data to a target working thread through a target data channel under the condition that the load state index value meets the preset request receiving condition; the request data is processed by the target worker thread. In one embodiment, the server includes a central processor for providing computing resources for the worker thread groups and a memory for providing data storage space for the worker thread groups; the preset request receiving condition comprises that the first utilization rate is smaller than a preset first utilization rate threshold value, and the second utilization rate is smaller than a preset second utilization rate threshold value; After obtaining the load state index value of the server, the method further comprises the following steps: Determining that the load state index value meets a preset acceptance request condition under the condition that the first utilization rate is smaller than a preset first utilization rate threshold value and the second utilization rate is smaller than a preset second utilization rate threshold value; and under the condition that the first utilization rate is not smaller than a preset first utilization rate threshold value or the second utilization rate is not smaller than a preset second utilization rate threshold value, determining that the load state index value does not meet a preset acceptance request condition. In one embodiment, the server further comprises a management thread group, the work thread group comprises at least one work thread, and after receiving the request data sent by the client, the method further comprises: under the condition that the target data channels corresponding to the transmission control connection are not registered on each working thread, acquiring a load state index value of the server side; Under the condition that the load state index value meets the preset request accepting condition, determining a target working thread from all working threads through a management thread group, and registering a target data channel corresponding to transmission control connection on the target working thread; transmitting request data sent by a client to a target working thread through a target data channel; the request data is processed by the target worker thread. In one embodiment, the load state index value includes an average processing time length of tasks and a total number of current tasks corresponding to each working thread, and determining a target working thread from the working threads includes: estimating estimated processing time required by each working thread for processing request data according to the average processing time of the tasks corresponding to each working thread and the total number of the current tasks; and determining the working thread corresponding to the shortest estimated processing time length as