Configuration method of request timeout time and terminal
By obtaining the weight and hierarchy of microservice applications and personalizing the timeout time, the system instability and performance problems caused by unified timeout configuration are solved, and more efficient system response and stability are achieved.
Patent Information
- Application Number
- CN202510402772.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-08-05
AI Technical Summary
In the prior art, setting the interface timeout time cannot take into account both system stability and performance, resulting in too long waiting time or frequent failures, and setting the timeout time separately increases configuration complexity.
By receiving external requests, the weight and hierarchy of each microservice application in the request link are obtained, and the microservice application is sequentially traversed, and the next level timeout time is set according to the current microservice application timeout time and the next level weight to realize personalized timeout time configuration.
It realizes the appropriate personalized configuration of external request timeout, reduces unnecessary waiting time, improves system response speed and throughput, avoids faults caused by frequent access, and improves system stability.
Smart Images

Figure CN120434307A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network communication and protocol, and in particular to a configuration method and terminal for requesting a timeout. Background Art
[0002] Most systems rely on external systems during operation. These cross-system resource requirements typically exchange data via HTTP interfaces. However, HTTP requests must be transmitted over a network, which is inherently unstable due to latency, bandwidth limitations, and routing changes, leading to data transmission uncertainty. To prevent system lag caused by delays in requesting external data sources, an appropriate interface timeout is typically set for the interfaces that request external data sources. However, since the timeout is consistent across all interfaces, a long timeout will result in extended wait times and reduced system throughput; a short timeout will lead to frequent interface failures and compromise stability. Given the limitations of setting a unified timeout, an alternative optimization approach is to set a timeout for each interface. This approach allows for more precise control over the timeout behavior of each interface, thereby improving system stability and performance to a certain extent. However, this approach also has certain limitations. Setting a timeout for each interface increases configuration complexity and workload. Even with careful analysis and configuration, it is difficult to guarantee the optimal timeout for each interface. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method and terminal for configuring a request timeout, which can configure a personalized timeout for an external request and effectively improve the stability and performance of the system.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: A method for configuring a request timeout period, comprising the steps of: S1. Receive an external request, obtain a request link of the external request, and obtain the weight and level of each microservice application in the request link; S2. Use the timeout of the external request as the timeout of the first microservice application in the request link, sequentially traverse the microservice applications of each layer in the request link starting from the first microservice application, and set the timeout of the microservice application of the next layer according to the timeout of the current microservice application and the weight of the microservice application of the next layer below the current microservice application.
[0005] In order to solve the above technical problems, another technical solution adopted by the present invention is: A terminal for configuring a request timeout comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step of the above-mentioned method for configuring a request timeout is implemented.
[0006] The beneficial effects of the present invention are as follows: a method and terminal for configuring a request timeout provided by the present invention receives an external request, obtains a request link of the external request, and obtains the weight and level of each microservice application in the request link, thereby providing a data basis for subsequent personalized timeout configuration, thereby avoiding excessive waiting time for non-critical services; using the timeout of the external request as the timeout of the first microservice application in the request link, sequentially traversing the microservice applications of each level in the request link, and setting the timeout of the microservice application of the next level according to the timeout of the current microservice application currently traversed and the weight of the microservice application of the next level of the current microservice application, thereby realizing appropriate personalized configuration of the external request timeout, thereby reducing unnecessary waiting time, improving the response speed and throughput of the overall system, avoiding failures caused by frequent access, and improving the stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] Figure 1 This is a flowchart of a method for configuring a request timeout according to an embodiment of the present invention; Figure 2 A request link diagram in a method for configuring a request timeout according to an embodiment of the present invention; Figure 3 A schematic diagram of a terminal for configuring a request timeout according to an embodiment of the present invention; Description of labels: 1. A terminal for configuring a request timeout; 2. A memory; 3. A processor. DETAILED DESCRIPTION
[0008] To illustrate the technical content, achieved objectives and effects of the present invention in detail, the following description is given in conjunction with the embodiments and accompanying drawings.
[0009] Please refer to Figure 1 , an embodiment of the present invention provides a method for configuring a request timeout, comprising the steps of: S1. Receive an external request, obtain a request link of the external request, and obtain the weight and level of each microservice application in the request link; S2. Use the timeout of the external request as the timeout of the first microservice application in the request link, sequentially traverse the microservice applications of each layer in the request link starting from the first microservice application, and set the timeout of the microservice application of the next layer according to the timeout of the current microservice application and the weight of the microservice application of the next layer below the current microservice application.
[0010] From the above description, it can be seen that the beneficial effects of the present invention are: by receiving an external request, obtaining the request link of the external request, and obtaining the weight and level of each microservice application in the request link, a data basis is provided for subsequent personalized timeout configuration to avoid excessive waiting time for non-critical services; the timeout time of the external request is used as the timeout time of the first microservice application in the request link, and the microservice applications of each level in the request link are traversed sequentially, and the timeout time of the microservice application of the next level is set according to the timeout time of the current microservice application currently traversed and the weight of the microservice application of the next level of the current microservice application, so as to realize appropriate personalized configuration of the external request timeout time, which not only reduces unnecessary waiting time, improves the response speed and throughput of the overall system, but also avoids failures caused by frequent access and improves the stability of the system.
[0011] Furthermore, obtaining the request link of the external request includes: Deploy a distributed link system, and when the external request reaches the gateway of the microservice application, generate a corresponding path identifier through the distributed link system, and bind the path identifier to the external request; The request link of the external request is composed of the path identifier.
[0012] As can be seen from the above description, by generating corresponding path identifiers through the distributed link system and binding the path identifiers to external requests, the flow path of external requests in the microservice architecture can be effectively tracked, which helps to configure the timeout period for each microservice application in the request link in a targeted manner.
[0013] Furthermore, the weight and level of each microservice application in the request link are obtained, including: The distributed link system is used to divide the request link according to the routing information of the microservice application, and the microservice level of each microservice application in the request link is determined.
[0014] From the above description, it can be seen that by dividing the request chain through routing information and determining the microservice level of each microservice application, the request chain can be visualized and a complete request chain graph can be formed, so that the appropriate timeout period can be assigned to each microservice application according to its level and weight.
[0015] Furthermore, the timeout time of the microservice application at the next level is set according to the timeout time of the current microservice application currently traversed and the weight of the microservice application at the next level of the current microservice application, including: Determine the number of microservice applications in the next level of the current microservice application, and calculate the time usage ratio of each microservice application in the next level based on the number of microservice applications in the next level and the weight of each microservice application in the next level; The timeout time of each microservice application in the next layer is calculated according to the timeout time of the current microservice application and the time usage ratio of each microservice application in the next layer of the current microservice application.
[0016] From the above description, we can see that by calculating the time usage ratio of each microservice application in the next layer, the timeout time is allocated to each microservice application in the next layer according to the timeout time of the current microservice application and the time usage ratio of each microservice application in the next layer, thus realizing personalized configuration of the timeout time and improving the performance and reliability of the overall system.
[0017] Furthermore, after step S2, the method further includes: The request link is stored in a cache. When the same external request is received, the corresponding request link is retrieved from the cache, and a corresponding timeout period is configured for each microservice application in the request link.
[0018] From the above description, we can see that in response to the same external request, the corresponding request link is retrieved from the cache to avoid the process of re-acquiring the request link, and the corresponding timeout period is quickly configured for each microservice application in the request link, which not only reduces resource consumption but also improves system throughput.
[0019] Please refer to Figure 3 Another embodiment of the present invention provides a terminal for configuring a request timeout, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the processor implements the various steps of the above-mentioned method for configuring a request timeout.
[0020] The above-mentioned request timeout configuration method and terminal of the present invention are applicable to network communication scenarios, can configure personalized timeouts for external requests, and effectively improve the stability and performance of the system. The following is an explanation through specific implementation methods: Please refer to Figure 1 and Figure 2 , embodiment 1 of the present invention is: A method for configuring a request timeout period, comprising the steps of: S1. Receive an external request, obtain the request link of the external request, and obtain the weight and level of each microservice application in the request link, specifically including: S1.1-S1.2. S1.1. Deploy a distributed link system. When the external request reaches the gateway of the microservice application, the distributed link system generates a corresponding path identifier, binds the path identifier to the external request, and forms a request link for the external request with the path identifier.
[0021] In this embodiment, a distributed link tracking system is deployed for the microservice architecture. This system is capable of tracking all requests under the microservice architecture. Specifically, each microservice application will embed an SDK package of the distributed link system. When an external request reaches the gateway of the microservice application, the SDK package will generate a traceId. Subsequent external requests to any child microservice application will carry this traceId. Through this traceId, all links of the external request can be associated and queried, effectively tracking the flow path of the external request in the microservice architecture, so as to facilitate the subsequent configuration of timeouts for each microservice application in the request link.
[0022] S1.2. Use the distributed link system to divide the request link according to the routing information of the microservice application, and determine the microservice level of each microservice application in the request link.
[0023] In this embodiment, each microservice application needs to be assigned an importance weight (priority), ranging from 1 to 10, with a higher number indicating a higher level.
[0024] The distributed link system divides the request link through routing information and determines the microservice level of each microservice application. It can visualize the request link and form a complete request link graph, so that it can assign appropriate timeout time to each microservice application according to its level and weight.
[0025] S2. Use the timeout of the external request as the timeout of the first microservice application in the request chain. In the request chain, sequentially traverse the microservice applications of each layer starting from the first microservice application. Set the timeout of the microservice application at the next layer according to the timeout of the current microservice application and the weight of the microservice application at the next layer below the current microservice application. Specifically, Determine the number of microservice applications in the next level of the current microservice application, and calculate the time usage ratio of each microservice application in the next level based on the number of microservice applications in the next level and the weight of each microservice application in the next level; The timeout time of each microservice application in the next layer is calculated according to the timeout time of the current microservice application and the time usage ratio of each microservice application in the next layer of the current microservice application.
[0026] In this embodiment, by calculating the usage ratio of each microservice application in the next layer, the timeout time is allocated to each microservice application in the next layer according to the timeout time of the current microservice application and the usage ratio of each microservice application in the next layer, thereby realizing personalized configuration of the timeout time and improving the performance and reliability of the overall system.
[0027] For details, please refer to Figure 2 , assuming that the timeout of each external request interface is 500ms, through the distributed link tracking of step S1.1, the request link of the interface can be known. At this time, the weights of microservice applications B, C, D, E, and F are 8, 10, 7, 6, and 5 respectively. The external request reaches microservice application A, and the timeout of the external request of 500ms is used as the timeout of microservice application A. As can be seen from the figure, microservice applications B and C are at the same level and are both the next level of microservice application A. Therefore, the timeout of microservice application B can be set to , the timeout of microservice application C can be set to ,The remaining subsequent microservice applications continue to be personalized in this way.
[0028] S3. Store the request link in a cache. When the same external request is received, retrieve the corresponding request link from the cache and configure a corresponding timeout for each microservice application in the request link.
[0029] In this embodiment, under normal circumstances, there will be different branches within the link of an interface. Assuming that there are three branches, these three branches are fixed. Therefore, after analyzing the request link of this interface, the analysis result information is cached in a unified cache, including the branch nodes of the request link and their corresponding microservice applications (weights and levels). When the same external request is received, the corresponding analyzed result information in the cache is obtained in advance, and a corresponding timeout time is configured for each microservice application in the request link, which reduces resource consumption and improves system performance.
[0030] Please refer to Figure 3 , embodiment 2 of the present invention is: a terminal 1 for configuring a request timeout, comprising a memory 2, a processor 3, and a computer program stored on the memory 2 and executable on the processor 3, wherein the processor 3 implements the various steps of a method for configuring a request timeout in embodiment 1 when executing the computer program.
[0031] In summary, the present invention provides a method and terminal for configuring a request timeout, which receives an external request, obtains the request link of the external request by deploying a distributed link system, and obtains the weight and level of each microservice application in the request link based on routing information, effectively tracking the flow path of the external request in the microservice architecture, and providing a data basis for subsequent personalized timeout configuration, thereby avoiding excessive waiting time for non-critical services. The timeout of the external request is used as the timeout of the first microservice application in the request link, and the microservice applications of each level in the request link are sequentially traversed. The time ratio of each microservice application in the next level of the current microservice application currently traversed is calculated, and the time ratio of each microservice application in the next level is set according to the timeout of the current microservice application currently traversed and the time ratio of each microservice application in the next level, so as to realize appropriate personalized configuration of the external request timeout, reduce unnecessary waiting time, improve the response speed and throughput of the overall system, avoid failures caused by frequent access, and improve the stability of the system.
[0032] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's description and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for configuring a request timeout, characterized in that: Including steps: S1. Receive an external request, obtain a request link of the external request, and obtain the weight and level of each microservice application in the request link; S2. Use the timeout of the external request as the timeout of the first microservice application in the request link, sequentially traverse the microservice applications of each layer in the request link starting from the first microservice application, and set the timeout of the microservice application of the next layer according to the timeout of the current microservice application and the weight of the microservice application of the next layer below the current microservice application.
2. A method for configuring a request timeout according to claim 1, characterized in that: Obtaining the request link of the external request includes: Deploy a distributed link system, and when the external request reaches the gateway of the microservice application, generate a corresponding path identifier through the distributed link system, and bind the path identifier to the external request; The request link of the external request is composed of the path identifier.
3. The method for configuring a request timeout according to claim 2, wherein: Obtain the weight and level of each microservice application in the request chain, including: The distributed link system is used to divide the request link according to the routing information of the microservice application, and the microservice level of each microservice application in the request link is determined.
4. The method for configuring a request timeout according to claim 1, wherein: Setting the timeout time of the microservice application at the next level according to the timeout time of the current microservice application and the weight of the microservice application at the next level of the current microservice application includes: Determine the number of microservice applications in the next level of the current microservice application, and calculate the time usage ratio of each microservice application in the next level based on the number of microservice applications in the next level and the weight of each microservice application in the next level; The timeout time of each microservice application in the next layer is calculated according to the timeout time of the current microservice application and the time usage ratio of each microservice application in the next layer of the current microservice application.
5. The method for configuring a request timeout according to claim 1, wherein: After step S2, the method further includes: The request link is stored in a cache. When the same external request is received, the corresponding request link is retrieved from the cache, and a corresponding timeout period is configured for each microservice application in the request link.
6. A terminal for configuring a request timeout, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the following steps are implemented: S1. Receive an external request, obtain a request link of the external request, and obtain the weight and level of each microservice application in the request link; S2. Use the timeout of the external request as the timeout of the first microservice application in the request link, sequentially traverse the microservice applications of each layer in the request link starting from the first microservice application, and set the timeout of the microservice application of the next layer according to the timeout of the current microservice application and the weight of the microservice application of the next layer below the current microservice application.
7. A terminal for configuring a request timeout according to claim 6, characterized in that: Obtaining the request link of the external request includes: Deploy a distributed link system, and when the external request reaches the gateway of the microservice application, generate a corresponding path identifier through the distributed link system, and bind the path identifier to the external request; The request link of the external request is composed of the path identifier.
8. A terminal for configuring a request timeout according to claim 7, characterized in that: Obtain the weight and level of each microservice application in the request chain, including: The distributed link system is used to divide the request link according to the routing information of the microservice application, and the level of each microservice application in the request link is determined.
9. The terminal for configuring a request timeout according to claim 6, wherein: Setting the timeout time of the microservice application at the next level according to the timeout time of the current microservice application and the weight of the microservice application at the next level of the current microservice application includes: Determine the number of microservice applications in the next level of the current microservice application, and calculate the time usage ratio of each microservice application in the next level based on the number of microservice applications in the next level and the weight of each microservice application in the next level; The timeout time of each microservice application in the next layer is calculated according to the timeout time of the current microservice application and the time usage ratio of each microservice application in the next layer of the current microservice application.
10. The terminal for configuring a request timeout according to claim 6, wherein: After step S2, the method further includes: The request link is stored in a cache. When the same external request is received, the corresponding request link is retrieved from the cache, and a corresponding timeout period is configured for each microservice application in the request link.