Method and device for setting interface calling timeout time
By obtaining interface call-related information from the service registration center, calculating and setting the target timeout time, the problem of inaccurate interface timeout time configuration in the existing technology is solved, and the service availability and system stability are improved.
Patent Information
- Application Number
- CN202311140651.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-05
- Publication Date
- 2025-03-07
AI Technical Summary
When configuring the interface timeout time, the prior art often sets it with default value or experience value, resulting in too long or too short time, causing system problems and affecting service availability and system stability.
By obtaining the interface call related information of each service from the service registration center, including interface call statistics and timeout time configuration policy, the target timeout time of each service is calculated, and the interface call timeout time is automatically set.
It realizes reasonable, accurate calculation and simple configuration of interface call timeout time, ensuring service availability and improving the stability of the service system.
Smart Images

Figure CN119583518A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for setting an interface call timeout period. Background Art
[0002] With the continuous development of the Internet platform, a project involves more and more service functions, the service monomer is getting larger and larger, and the hidden dangers brought by the deployment of the monomer service are becoming more and more serious. As a result, the monomer service is decomposed into several small application services for independent deployment, and the monomer service is implemented by calling the interface of these small application services. However, more complex functions often call more than a dozen other service interfaces, and each interface needs to be configured with an independent timeout. If the interface method is unstable, developers need to set the specific timeout time for each interface. Once the timeout time is configured to be too long or too short, it will cause system problems, which will cost a lot of manpower and material costs, and is not conducive to business adjustments and system upgrades.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] At present, when configuring the interface timeout, most people use the default timeout as the standard, or set a time threshold based on development experience. If the timeout is configured too long, the waiting time will be longer when the call times out and retries multiple times, which will trigger a chain reaction and cause the service to be unavailable; if the timeout is configured too short, once the network traffic increases, the service will be unavailable because there is no quick response. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for setting an interface call timeout period, which can achieve reasonable and accurate calculation and simple configuration of the interface call timeout period, thereby ensuring service availability and improving the stability of the service system.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for setting an interface call timeout period is provided, comprising:
[0007] In response to a request for setting an interface call timeout, obtaining interface call related information of each registered service from a service registration center, the interface call related information including interface call statistics and a timeout configuration policy;
[0008] Calculate the target timeout time of each service according to the interface call statistics and timeout configuration strategy of each service;
[0009] According to the target timeout time of each service, the interface call timeout time of each service registered in the service registration center is set.
[0010] Optionally, the interface call related information also includes the current timeout time; according to the target timeout time of each service, the interface call timeout time of each service registered in the service registration center is set, including: according to the target timeout time of each service, the current timeout time of each service registered in the service registration center is modified to set the interface call timeout time of each service registered in the service registration center.
[0011] Optionally, the timeout configuration policy is provided by the service provider when the service provider registers the service with the service registration center, and the service provider also provides an initial timeout.
[0012] Optionally, the interface call timeout time of each service registered in the service registration center is set according to the target timeout time of each service, including: modifying the configuration information of the service registration center according to the target timeout time of each service, and the service registration center sends the configuration information to the service providers corresponding to each service to set the interface call timeout time of each service registered in the service registration center.
[0013] Optionally, obtaining interface call related information of each registered service from the service registration center includes: obtaining interface call related information of each registered service from the service registration center through a pre-implemented service registration center hook method.
[0014] Optionally, the request to set the interface call timeout period is triggered by a set timer task; obtaining interface call related information of each registered service from the service registration center includes: asynchronously obtaining interface call related information of each registered service from the service registration center.
[0015] Optionally, the interface call statistics include the number of interface calls, the interface call time and the duration of each interface call; the timeout configuration strategy is determined by obtaining the data distribution through statistical analysis of the interface call statistics; the timeout configuration strategy includes: average value strategy, weighted average value strategy, maximum time strategy, median strategy, standard deviation strategy and normal distribution strategy; among which, the average value strategy, the weighted average value strategy and the maximum time strategy are applicable to the situation where the data distribution is relatively uniform; the median strategy is applicable to the situation where there are outliers in the data distribution and the data discrete rate does not exceed the set threshold; the standard deviation strategy is applicable to the situation where the data discrete rate in the data distribution exceeds the set threshold; the normal distribution strategy is applicable to the situation where the data distribution conforms to the normal distribution.
[0016] According to another aspect of an embodiment of the present invention, a device for setting an interface call timeout period is provided, comprising:
[0017] A call information acquisition module, used to obtain interface call related information of each registered service from a service registration center in response to a request for setting an interface call timeout, wherein the interface call related information includes interface call statistics and a timeout configuration strategy;
[0018] A timeout calculation module is used to calculate the target timeout of each service according to the interface call statistics and timeout configuration strategy of each service;
[0019] The timeout setting module is used to set the interface call timeout of each service registered in the service registration center according to the target timeout of each service.
[0020] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for setting the interface call timeout period provided in an embodiment of the present invention.
[0021] According to another aspect of an embodiment of the present invention, a computer readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for setting an interface call timeout period provided in an embodiment of the present invention is implemented.
[0022] One embodiment of the above invention has the following advantages or beneficial effects: by responding to a request to set the interface call timeout, the interface call related information of each registered service is obtained from the service registration center, and the interface call related information includes interface call statistics and timeout configuration strategy; the target timeout of each service is calculated according to the interface call statistics and timeout configuration strategy of each service; the technical solution of setting the interface call timeout of each service registered in the service registration center according to the target timeout of each service does not need to manually maintain the interface call timeout of each service, and the optimal interface target timeout can be calculated based on the collected interface call statistics of each service and the timeout configuration strategy of each service, and asynchronously pushed to the service registration center, and pushed to the service provider by the service registration center to modify the configuration. The reasonable and accurate calculation and simple configuration of the interface call timeout are realized, thereby ensuring the service availability and improving the stability of the service system.
[0023] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0025] Figure 1 1 is a schematic diagram of the main steps of a method for setting an interface call timeout period according to an embodiment of the present invention;
[0026] Figure 2 It is a schematic diagram of the process of setting the interface call timeout period according to an embodiment of the present invention;
[0027] Figure 3 1 is a schematic diagram of main modules of a device for setting an interface call timeout period according to an embodiment of the present invention;
[0028] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0029] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0031] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution disclosed in the present invention are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.
[0032] In the prior art, for the interconnected upstream and downstream service interfaces, the default timeout is usually used or a timeout is set based on experience. However, this will result in the timeout being inaccurate. If the timeout is set too long, the call will time out and the waiting time will be longer during multiple retries, thus triggering a chain reaction and causing the service to be unavailable. If the timeout is set too short, once the network traffic increases, the service will be unavailable due to the lack of a quick response. Therefore, how to set a reasonable and accurate interface call timeout is a key issue in ensuring service availability and improving the stability of the service system.
[0033] In order to solve the above-mentioned technical problems existing in the prior art, the present invention provides a method for setting an interface call timeout period, which can calculate the timeout period of each service interface according to the interface call statistics data and timeout configuration strategy of each service interface, and then set the interface call timeout period of each service, thereby setting a reasonable and accurate interface call timeout period, ensuring service availability and improving service system stability.
[0034] Specifically, an embodiment of the present invention provides a method for dynamically setting and recommending a configuration timeout time through a timeout time setting component in a scenario where services configure a timeout time by calling a configuration timeout time in a microservice system, thereby achieving the following objectives:
[0035] 1) Through the timeout setting component, you can intuitively see the call data of all service providers or servers registered in the registration center, and you can intuitively modify the timeout of a service. There is no need to manually change the configuration of the corresponding service interface in the project. You only need to modify it in the timeout setting component to take effect;
[0036] 2) Collect the time consumed by each interface call of all services, and calculate the optimal timeout time based on the corresponding rules of the collected data according to the policy configuration. The optimal timeout time configuration is automatically sent to the corresponding service interface configuration, without the need to manually maintain the timeout time of each interface.
[0037] Figure 1 FIG. 1 is a schematic diagram of the main steps of a method for setting an interface call timeout period according to an embodiment of the present invention. Figure 1 As shown, the method for setting the interface call timeout period in the embodiment of the present invention mainly includes the following steps S101 to S103.
[0038] Step S101: in response to a request for setting an interface call timeout, obtaining interface call related information of each registered service from a service registration center, the interface call related information including interface call statistics and timeout configuration policy.
[0039] According to an embodiment of the present invention, the timeout configuration policy is provided by the service provider when the service provider registers the service with the service registration center, and the service provider also provides an initial timeout. When the service provider (such as a server with a service deployed) starts, it will register the service it provides with the service registration center, and will provide the corresponding timeout configuration policy and initial timeout. Generally, the initial timeout is the default value. If the initial timeout is not set, a default initial timeout is set according to the microservice framework corresponding to the service provider. For example, if the microservice framework is dubbo (an open source distributed service framework), its default initial timeout is 3 seconds.
[0040] After startup, the service consumer or service caller will subscribe to the service they need from the service registration center, and pull the timeout configuration policy and initial timeout of the corresponding subscribed service to the local. The service registration center and the service consumer establish a connection through heartbeat, and the relevant information of the registered service can be pushed to the service consumer through a persistent connection.
[0041] The service provider and the service consumer will collect the relevant information of each service call and assemble it into interface call statistics, and then send the interface call statistics to the service registration center at regular intervals. Afterwards, the interface call timeout setting device (i.e., interface call timeout setting component) provided by the embodiment of the present invention will obtain the interface call statistics from the service registration center for calculating the interface call timeout.
[0042] According to an embodiment of the present invention, obtaining the interface call related information of each registered service from the service registration center may specifically include: obtaining the interface call related information of each registered service from the service registration center through a pre-implemented service registration center hook method. For each service registration center, the interface call timeout setting device of the present invention will implement a hook method, and access the extended function of the service registration center through the hook method to obtain the interface call related information of each service registered by the service registration center. In an embodiment of the present invention, the service registration center takes Nacos (microservice platform framework) and Zookeeper (distributed application coordination service software) as examples, and Nacos provides Metrics extension points to access the registration center to obtain interface call configuration statistics, etc. Zookeeper's running special node information monitoring information includes, for example, special nodes such as / zookeeper / quota, / zookeeper / config, / zookeeper / proc, and / zookeeper / server. Among them, the / zookeeper / quota node is used to limit the size of a node and its child nodes, and the quota quota of the node can be set. Once the quota is exceeded, data can no longer be written. The / zookeeper / config node is used to store Zookeeper configuration information, such as tickTime, dataDir and other parameters. Administrators can dynamically change Zookeeper configuration by modifying this node. The / zookeeper / proc node is a node inside Zookeeper, which is used to store information about the Zookeeper process, such as pid, status, etc. The / zookeeper / server node is used to store the address information of each server in the Zookeeper cluster. When the client needs to connect to the Zookeeper cluster, it will first obtain the addresses of all servers in the cluster from this node and try to connect to one of them. Through the above service registry extension point function, the asynchronous task obtains the interface call statistics collected by the service registry (most service registries have extended hook methods to implement the call and configuration of the acquisition interface).
[0043] According to another embodiment of the present invention, a request to set an interface call timeout is triggered by a set timer task, so the interface call timeout can be calculated regularly and the interface call timeout can be set. Obtaining information related to interface calls of each registered service from a service registration center can specifically include: asynchronously obtaining information related to interface calls of each registered service from a service registration center. In an embodiment of the present invention, a device for setting an interface call timeout can asynchronously collect information related to interface calls of each service registered by a service registration center regularly to set an interface call timeout.
[0044] Step S102: Calculate the target timeout time of each service according to the interface call statistics of each service and the timeout time configuration policy.
[0045] According to one of the embodiments of the present invention, the interface call statistics include the number of interface calls, the interface call time, and the duration of each interface call, etc. According to an embodiment of the present invention, the timeout configuration policy of each service interface is provided when the service is registered, and is specifically set by the user. Among them, the timeout configuration policy is determined by the data distribution obtained by statistically analyzing the interface call statistics. When setting the timeout configuration policy for each service, the user can obtain the data distribution by analyzing the interface call statistics of the service, and then determine the timeout configuration policy to be set according to the analysis requirements. Here, for each service, when determining its corresponding timeout configuration policy, the interface call statistics used are, for example, the interface call statistics of the service interface in the past month.
[0046] In an embodiment of the present invention, the timeout configuration strategy may include, for example: average value strategy, weighted average value strategy, maximum time strategy, median strategy, standard deviation strategy and normal distribution strategy, etc. Among them, the average value strategy, the weighted average value strategy and the maximum time strategy are applicable to the case where the data distribution is relatively uniform; the median strategy is applicable to the case where there are outliers in the data distribution and the data discrete rate does not exceed the set threshold; the standard deviation strategy is applicable to the case where the data discrete rate in the data distribution exceeds the set threshold; the normal distribution strategy is applicable to the case where the data distribution conforms to the normal distribution.
[0047] The average value strategy is to calculate the average time taken for each call of all interfaces by adding up the time taken for each call of all interfaces and dividing it by the number of interface calls. This strategy is suitable for situations where the data distribution of the time taken for each call of the interface is relatively uniform. The average call time taken can objectively reflect the average time taken for the call of this interface and is relatively easy to understand and use. In addition, if some outliers need to be removed, some significantly deviated data can also be excluded before calculating the average value to reduce the impact of outliers on the results. It should be noted that this strategy is aimed at the statistics of the call time of the same interface in the same scenario. If the scenario changes, such as load changes, concurrency changes, etc., it will affect the calculation results. Therefore, it is necessary to collect and calculate data in specific scenarios, and it needs to be adjusted and optimized continuously. Here, the data is the time taken for each call of the interface.
[0048] The weighted average strategy is to multiply each value by the corresponding weight, then add up the total value and divide it by the total number of units. Specifically, the time taken for each call of all interfaces can be added up and divided by the data to find the reciprocal, and then the average of the reciprocals can be found. When it is necessary to obtain the average ratio between a set of data, the weighted average is a common method, which is suitable for calculating the amount of tasks completed in the actual unit time, etc. Here, the data is the time taken for each call of the interface.
[0049] The longest time strategy is: divide the length of the confidence interval by 2 to get half of the confidence interval, that is, the radius of the confidence interval; then, add the average response time to this radius to get the longest timeout. This longest timeout can be used as the starting point of the timeout, and then gradually reduced according to the actual situation, and continuously adjusted to achieve optimal performance. The confidence interval indicates how much confidence can be given that the following true value is within a certain range. A common method of calculating a confidence interval is to use a t distribution, with the following formula:
[0050] CI=x_mean+t(alpha / 2,n-1)*s / sqrt(n),
[0051] Where CI is the length of the confidence interval, x_mean is the average response time, t(alpha / 2,n-1) is the upper quantile of the t distribution, s is the sample standard deviation, sqrt(n) is the square root of the number of samples, and alpha is the required confidence level. This upper quantile can usually be found in the t distribution table. Here, the sample is the time taken for each call to the interface.
[0052] The median strategy is to arrange the data from small to large and take the average of one or two numbers in the middle as the median. This method is suitable for situations where there are outliers in the data. Here, the data is the time taken for each interface call.
[0053] The standard deviation strategy is used to describe the degree to which the average value of the data deviates from the overall average value. The larger the standard deviation, the more dispersed or discrete the data is. This method is suitable for scenarios where the data span and distribution of the timeout period need to be considered. According to the standard deviation formula:
[0054] s=sqrt(sum((x-x_mean) 2 ) / (n-1)),
[0055] Among them, s is the standard deviation of the time taken for each interface call, x is the time taken for each interface call, x_mean is the average time taken for each interface call, and n is the number of interface calls.
[0056] The normal distribution strategy can be used to determine the percentage of data within a certain standard deviation of the average value of the data set at the timeout time, which helps determine whether there is abnormal data and calculate the optimal time range. Here, the data is the time taken for each call of the interface. The specific steps are as follows:
[0057] (1) Calculate the mean and standard deviation, assuming that the mean is μ and the standard deviation is σ;
[0058] (2) For each data point, calculate its difference from the mean (i.e., z-score), z-score = (x-μ) / σ;
[0059] (3) Use a normal distribution table (also called a Z-score table) to find the percentage corresponding to the z-score;
[0060] (4) Find the position corresponding to the percentage on the normal distribution table. For example, if you want to find 95% of the data distributed around the mean, you need to find the data point within ±1.96σ of the mean (because in a normal distribution, about 95% of the data are concentrated within ±1.96σ of the mean);
[0061] (5) Based on the above steps, the optimal timeout duration range can be obtained, which is usually defined as the mean value plus or minus a certain number of standard deviations to avoid the influence of extreme values.
[0062] The normal distribution strategy is only applicable to normally distributed data sets. If the data set does not satisfy the normal distribution, other strategies need to be used.
[0063] The above are several timeout configuration strategies commonly used in the embodiments of the present invention. Corresponding calculations can be performed according to the above strategies. Of course, there are other strategies. The applicable strategy can be specifically selected in combination with data distribution and analysis requirements. The present invention does not limit this.
[0064] In an embodiment of the present invention, the device for setting the interface call timeout can periodically and asynchronously collect interface call related information of each service registered by the service registration center, and calculate the target timeout of each service in combination with the timeout configuration strategy corresponding to each service, and set the interface call timeout.
[0065] Step S103: according to the target timeout time of each service, the interface call timeout time of each service registered in the service registration center is set.
[0066] According to one embodiment of the present invention, the interface call related information also includes the current timeout time. The interface call timeout time setting device periodically obtains the interface call related information of each registered service from the service registration center, including the current timeout time of each service. And, according to the target timeout time of each service, the interface call timeout time of each service registered in the service registration center is set, which may specifically include: according to the target timeout time of each service, the current timeout time of each service registered in the service registration center is modified to set the interface call timeout time of each service registered in the service registration center. By modifying the current timeout time according to the target timeout time, the interface call timeout time of each service registered in the service registration center can be set.
[0067] According to another embodiment of the present invention, the interface call timeout time of each service registered in the service registration center is set according to the target timeout time of each service, which may specifically include: modifying the configuration information of the service registration center according to the target timeout time of each service, and the service registration center sends the configuration information to the service provider corresponding to each service to set the interface call timeout time of each service registered in the service registration center. The interface call timeout setting device of the embodiment of the present invention can modify the timeout time of each service in the configuration information of the service registration center, and then the service registration center will push the modified configuration information to the service provider corresponding to each service, as well as to the service consumer or service caller.
[0068] According to the embodiment of the present invention, in the system environment of microservice architecture, the timeout of each interface call of microservice does not need manual maintenance. It can introduce a setting device for interface call timeout, asynchronously collect interface call statistics of each service collected by the service registration center, asynchronously analyze and count the call time of each service interface, and calculate the optimal interface target timeout according to the timeout configuration strategy configured by the user, asynchronously push it to the service registration center, and the service registration center pushes it to the service provider to modify the configuration. The reasonable and accurate calculation and simple configuration of the interface call timeout are realized, thereby ensuring the service availability and improving the stability of the service system.
[0069] Figure 2 FIG. 1 is a flow chart of setting the interface call timeout period according to an embodiment of the present invention. Figure 2 As shown, in one embodiment of the present invention, the interface calls the timeout setting system, when performing the timeout setting, mainly includes the following process steps:
[0070] Step 1: Start registration: When the service provider starts, it registers the service it provides with the service registration center and provides its own timeout configuration policy and current timeout. At this time, the service registration center establishes a heartbeat connection with the service provider to exchange data through a persistent connection;
[0071] Step 2: Subscribe to services and pull configurations: The service consumer starts, subscribes to the services it needs from the service registry, and pulls the relevant configuration information of the subscribed services (including the timeout configuration policy and the current timeout) to the local computer. At this point, the service registry establishes a heartbeat connection with the service consumer to exchange data through a persistent connection.
[0072] Step 3, establishing a heartbeat connection: the service registration center establishes a heartbeat connection with the interface call timeout setting device to perform data interaction through a long connection;
[0073] Step 4: Send interface call statistics: The service consumer and the service provider periodically send the interface call statistics recorded in the memory to the service registration center. In the process of the service consumer making an interface call to the service provider, the service consumer and the service provider will record the interface call data in real time, such as the call time, interface response time, and the duration of the interface call, and obtain the interface call statistics by statistics;
[0074] Step 5, data collection and recording: the interface call timeout setting device uses the pre-implemented service registration center hook method to asynchronously collect and record the interface call statistics uploaded by the interface to the service registration center and the timeout configuration strategy and current timeout time of each registered service through a scheduled task;
[0075] Step 6, target timeout calculation: The interface call timeout setting device calculates the target timeout of each service according to the timeout configuration strategy of each service and the interface call statistics. At the same time, all interface call statistics are also visualized so that the user can manually adjust the interface timeout according to the interface call statistics;
[0076] Step 7, configuration information change: push the target timeout of each service to the service registry so that the service registry changes its configuration information, or change the configuration information of the service registry according to the target timeout of each service through the hook method;
[0077] Step 8: Configuration information push: The service registration center pushes the changed configuration information to the service provider and service consumer;
[0078] Step 9: Modify the interface call timeout: The service provider modifies its interface call timeout according to the changed configuration information.
[0079] Figure 3 Schematic diagram of the main modules of the device for setting the interface call timeout according to an embodiment of the present invention. Figure 3 As shown, the device 300 for setting the interface call timeout period according to the embodiment of the present invention mainly includes a call information acquisition module 301 , a timeout period calculation module 302 and a timeout period setting module 303 .
[0080] The call information acquisition module 301 is used to obtain the interface call related information of each registered service from the service registration center in response to the request for setting the interface call timeout, wherein the interface call related information includes interface call statistics and timeout configuration strategy;
[0081] A timeout calculation module 302 is used to calculate the target timeout of each service according to the interface call statistics and timeout configuration strategy of each service;
[0082] The timeout setting module 303 is used to set the interface call timeout of each service registered in the service registration center according to the target timeout of each service.
[0083] According to one embodiment of the present invention, the interface call related information also includes the current timeout period; the timeout period setting module 303 can also be used to modify the current timeout period of each service registered in the service registration center according to the target timeout period of each service, so as to set the interface call timeout period of each service registered in the service registration center.
[0084] According to another embodiment of the present invention, the timeout configuration policy is provided by the service provider when the service provider registers the service with the service registration center, and the service provider also provides an initial timeout.
[0085] According to another embodiment of the present invention, the timeout setting module 303 can also be used to: modify the configuration information of the service registration center according to the target timeout of each service, and the service registration center sends the configuration information to the service providers corresponding to each service to set the interface call timeout of each service registered in the service registration center.
[0086] According to another embodiment of the present invention, the call information acquisition module 301 may also be used to: obtain interface call related information of each registered service from the service registration center through a pre-implemented service registration center hook method.
[0087] According to another embodiment of the present invention, the request to set the interface call timeout period is triggered by a set timer task; the call information acquisition module 301 can also be used to: asynchronously obtain interface call related information of each registered service from the service registration center.
[0088] According to another embodiment of the present invention, the interface call statistics include the number of interface calls, the interface call time and the duration of each interface call; the timeout configuration strategy is determined by obtaining a data distribution through statistical analysis of the interface call statistics; the timeout configuration strategy includes: an average value strategy, a weighted average value strategy, a maximum time strategy, a median strategy, a standard deviation strategy and a normal distribution strategy; wherein the average value strategy, the weighted average value strategy and the maximum time strategy are applicable to situations where the data distribution is relatively uniform; the median strategy is applicable to situations where outliers exist in the data distribution and the data discrete rate does not exceed a set threshold; the standard deviation strategy is applicable to situations where the data discrete rate in the data distribution exceeds a set threshold; the normal distribution strategy is applicable to situations where the data distribution conforms to the normal distribution.
[0089] According to the technical solution of the embodiment of the present invention, by responding to the setting request for the interface call timeout, the interface call related information of each registered service is obtained from the service registration center, and the interface call related information includes interface call statistics and timeout configuration strategy; the target timeout of each service is calculated according to the interface call statistics and timeout configuration strategy of each service; according to the target timeout of each service, the technical solution of setting the interface call timeout of each service registered in the service registration center does not need to manually maintain the interface call timeout of each service. Based on the collected interface call statistics of each service and the timeout configuration strategy of each service, the optimal interface target timeout can be calculated and asynchronously pushed to the service registration center, and then pushed to the service provider by the service registration center to modify the configuration. The reasonable and accurate calculation and simple configuration of the interface call timeout are realized, thereby ensuring the service availability and improving the stability of the service system.
[0090] Figure 4 An exemplary system architecture 400 is shown to which the method for setting the interface call timeout period or the device for setting the interface call timeout period according to the embodiments of the present invention can be applied.
[0091] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0092] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0093] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0094] Server 405 may be a server that provides various services, such as a background management server that provides support for websites browsed by users using terminal devices 401, 402, and 403 (for example only). The background management server may respond to the received request for setting the interface call timeout and other data, obtain the interface call related information of each registered service from the service registration center, the interface call related information including interface call statistics and timeout configuration policy; calculate the target timeout of each service according to the interface call statistics and timeout configuration policy of each service; set the interface call timeout of each service registered in the service registration center according to the target timeout of each service, and feed back the processing result (such as the target timeout - for example only) to the terminal device.
[0095] It should be noted that the method for setting the interface call timeout period provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the device for setting the interface call timeout period is generally set in the server 405 .
[0096] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0097] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 5 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0098] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0099] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0100] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0101] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0102] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0103] The units or modules involved in the embodiments of the present invention may be implemented in software or hardware. The units or modules described may also be provided in a processor, for example, may be described as: a processor including a call information acquisition module, a timeout calculation module, and a timeout setting module. The names of these units or modules do not, in certain cases, constitute limitations on the units or modules themselves, for example, the timeout calculation module may also be described as "a module for calculating the target timeout of each service according to the interface call statistics and the timeout configuration policy of each service".
[0104] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: in response to a request to set an interface call timeout, obtaining interface call related information of each registered service from a service registration center, the interface call related information including interface call statistics and timeout configuration strategy; calculating the target timeout of each service according to the interface call statistics and timeout configuration strategy of each service; setting the interface call timeout of each service registered in the service registration center according to the target timeout of each service.
[0105] According to the technical solution of the embodiment of the present invention, by responding to the setting request for the interface call timeout, the interface call related information of each registered service is obtained from the service registration center, and the interface call related information includes interface call statistics and timeout configuration strategy; the target timeout of each service is calculated according to the interface call statistics and timeout configuration strategy of each service; according to the target timeout of each service, the technical solution of setting the interface call timeout of each service registered in the service registration center does not need to manually maintain the interface call timeout of each service. Based on the collected interface call statistics of each service and the timeout configuration strategy of each service, the optimal interface target timeout can be calculated and asynchronously pushed to the service registration center, and then pushed to the service provider by the service registration center to modify the configuration. The reasonable and accurate calculation and simple configuration of the interface call timeout are realized, thereby ensuring the service availability and improving the stability of the service system.
[0106] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for setting an interface call timeout, characterized in that: include: In response to a request for setting an interface call timeout, obtaining interface call related information of each registered service from a service registration center, the interface call related information including interface call statistics and a timeout configuration policy; Calculate the target timeout time of each service according to the interface call statistics and timeout configuration strategy of each service; According to the target timeout time of each service, the interface call timeout time of each service registered in the service registration center is set.
2. The method according to claim 1, characterized in that The interface call related information also includes the current timeout time; According to the target timeout time of each service, the interface call timeout time of each service registered in the service registration center is set, including: According to the target timeout time of each service, the current timeout time of each service registered in the service registration center is modified to set the interface call timeout time of each service registered in the service registration center.
3. The method according to claim 1 or 2, characterized in that: The timeout configuration policy is provided by the service provider when the service provider registers the service with the service registration center, and the service provider also provides an initial timeout.
4. The method according to claim 1, characterized in that: According to the target timeout time of each service, the interface call timeout time of each service registered in the service registration center is set, including: According to the target timeout period of each service, the configuration information of the service registration center is modified, and the service registration center sends the configuration information to the service providers corresponding to each service to set the interface call timeout period of each service registered in the service registration center.
5. The method according to claim 1, characterized in that Obtain information about the interface calls of each registered service from the service registration center, including: Through the pre-implemented service registration center hook method, the interface call related information of each registered service is obtained from the service registration center.
6. The method according to claim 1, characterized in that The request to set the interface call timeout period is triggered by a set timer task; Obtain information about the interface calls of each registered service from the service registration center, including: Asynchronously obtains interface call related information of each registered service from the service registration center.
7. The method according to claim 1, characterized in that The interface call statistics include the number of interface calls, the interface call time and the duration of each interface call; The timeout configuration strategy is determined by a data distribution obtained by statistically analyzing the interface call statistical data; The timeout configuration strategies include: average value strategy, weighted average value strategy, maximum time strategy, median strategy, standard deviation strategy and normal distribution strategy; wherein, The average value strategy, the weighted average value strategy and the maximum time strategy are applicable to the case where data distribution is relatively uniform; The median strategy is applicable to the case where there are outliers in the data distribution and the data dispersion rate does not exceed the set threshold; The standard deviation strategy is applicable to the case where the data dispersion rate in the data distribution exceeds the set threshold; The normal distribution strategy is applicable to the case where the data distribution conforms to the normal distribution.
8. A device for setting an interface call timeout, characterized in that: include: A call information acquisition module, used to obtain interface call related information of each registered service from a service registration center in response to a request for setting an interface call timeout, wherein the interface call related information includes interface call statistics and a timeout configuration strategy; A timeout calculation module is used to calculate the target timeout of each service according to the interface call statistics and timeout configuration strategy of each service; The timeout setting module is used to set the interface call timeout of each service registered in the service registration center according to the target timeout of each service.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Overtime setting method and system for dynamically adjusting static threshold based on EMA algorithm
CN121210176A