Service calling method and device, electronic equipment and storage medium

By intercepting the service call request and determining the timeout time, and if the conditions are not met, the timeout process is performed, the invalid call problem of inter-service calls in the prior art is solved, the service load is reduced and the response efficiency is improved.

CN119211368AActive Publication Date: 2024-12-27BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411335131.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2024-12-27
Estimated Expiration
2044-09-24

AI Technical Summary

Technical Problem

When setting the timeout timeout of inter-service calls, the prior art cannot effectively deal with the increase in time consumption caused by network reasons and the invalid calls caused by multi-service serial calls, resulting in wasted waiting time and increased invalid load.

Method used

By intercepting the call request, we judge whether the timeout time meets the specific conditions. If it is not met, the request timeout process will be performed to avoid invalid calls; when the called service receives the request, if the timeout timeout does not meet the conditions, the request timeout response will be returned to avoid invalid processing.

Benefits of technology

It effectively avoids invalid calls and processing, reduces the invalid load of services, and improves the response efficiency of service calls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119211368A_ABST
    Figure CN119211368A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a service calling method and device, electronic equipment and a storage medium. The service calling method comprises the following steps: after a calling request sent by a calling service to a called service is intercepted, obtaining a timeout duration of the calling request, and judging whether the timeout duration meets a first condition or not; when the first condition is not met, controlling the calling service to perform request timeout processing; and when the first condition is met, controlling the calling service to send a calling request to the called service. According to the embodiment of the invention, invalid calling can be avoided, and invalid loads of services are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a service calling method, device, electronic device and storage medium. Background Art

[0002] In the current network architecture system, calling between services is a common scenario, which involves communication and collaboration between different services. The timeout period for calling between services is an important configuration. The timeout period refers to the maximum time to wait for a response during the calling process between services. By setting the timeout period, you can protect the service and ensure the stability and predictability of the system.

[0003] Currently, the timeout period for service-to-service calls is usually set based on experience or historical data analysis. However, the timeout period set in the above way is not reasonable in some cases. For example, due to network reasons, the time consumption between services increases, resulting in timeouts, or serial calls between multiple services cause timeouts when the request reaches the intermediate link. In these cases, the service will not stop calling the downstream service until the timeout period is reached. However, the calls in these cases are invalid, which leads to a waste of waiting time and increases the invalid load of the service. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a service calling method, device, electronic device and storage medium to avoid invalid calls and reduce the invalid load of services. The specific technical solution is as follows:

[0005] In a first aspect of the present invention, a service calling method is first provided, comprising:

[0006] After intercepting a call request sent by the calling service to the called service, obtaining a timeout duration of the call request, and determining whether the timeout duration satisfies a first condition;

[0007] When the timeout duration does not satisfy the first condition, controlling the calling service to perform request timeout processing;

[0008] When the timeout period meets the first condition, the calling service is controlled to send the calling request to the called service.

[0009] Optionally, the method further comprises:

[0010] After intercepting the call request received by the called service, obtaining the timeout duration of the call request, and determining whether the timeout duration satisfies the second condition;

[0011] When the timeout period does not satisfy the second condition, controlling the called service to return a request timeout response to the calling service;

[0012] When the timeout period meets the second condition, the called service is controlled to process the calling request.

[0013] Optionally, determining whether the timeout duration satisfies a first condition includes:

[0014] When the calling service is a first type calling service, obtaining the historical request response duration of the called service; the first type calling service refers to the calling service that initially sends the calling request;

[0015] When the historical request response duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the first condition;

[0016] When the historical request response duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the first condition.

[0017] Optionally, determining whether the timeout duration satisfies a first condition includes:

[0018] When the calling service is a second type calling service, obtaining the historical request response duration of the called service, the starting sending time point of the calling request, and the forwarding sending time point when the calling service sends the calling request; the second type calling service refers to the calling service that receives and forwards the calling request;

[0019] Calculate a first duration obtained by subtracting the forwarding sending time point from the starting sending time point, and calculate a second duration obtained by adding the first duration to the historical request response duration;

[0020] When the second duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the first condition;

[0021] When the second duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the first condition.

[0022] Optionally, obtaining the historical request response duration of the called service includes:

[0023] Obtaining multiple request response durations of the called service within a recent preset time period;

[0024] The multiple request response time durations are sorted in ascending order, and the Nth request response time duration after sorting is used as the historical request response time duration of the called service, where N is a preset positive integer.

[0025] Optionally, determining whether the timeout duration satisfies a second condition includes:

[0026] Obtain the historical request processing time of the called service, the time point at which the called service receives the calling request, and the starting sending time point of the calling request;

[0027] Calculate a third duration obtained by subtracting the receiving time point from the starting sending time point, and calculate a fourth duration obtained by adding the third duration to the historical request processing duration;

[0028] When the fourth duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the second condition;

[0029] When the fourth duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the second condition.

[0030] Optionally, controlling the calling service to perform request timeout processing includes:

[0031] When the calling service is a first type calling service, controlling the calling service to send a timeout duration adjustment notification to a designated user; the first type calling service is a calling service that initially sends the calling request;

[0032] When the calling service is a second type calling service, the calling service is controlled to return a request timeout response to its upstream calling service; the second type calling service refers to a calling service that receives and forwards the calling request.

[0033] In a second aspect of the present invention, a service invocation device is provided, comprising:

[0034] A first judgment module is used to obtain a timeout duration of the calling request after intercepting the calling service sending the calling service to the called service, and judge whether the timeout duration satisfies a first condition;

[0035] A first control module, configured to control the calling service to perform request timeout processing when the timeout duration does not meet the first condition;

[0036] The second control module is used to control the calling service to send the calling request to the called service when the timeout period meets the first condition.

[0037] Optionally, the device further comprises:

[0038] A second judgment module is used to obtain a timeout duration of the calling request after intercepting the calling request received by the called service, and judge whether the timeout duration satisfies a second condition;

[0039] A third control module, configured to control the called service to return a request timeout response to the calling service when the timeout duration does not satisfy the second condition;

[0040] The fourth control module is used to control the called service to process the calling request when the timeout period meets the second condition.

[0041] Optionally, the first determination module includes:

[0042] A first acquisition unit is used to acquire the historical request response duration of the called service when the calling service is a first type calling service; the first type calling service is the calling service that initially sends the calling request;

[0043] A first determination unit is configured to determine that the timeout period satisfies the first condition when the historical request response period is less than or equal to the timeout period; and to determine that the timeout period does not satisfy the first condition when the historical request response period is greater than the timeout period.

[0044] Optionally, the first determination module includes:

[0045] A second acquisition unit is used to acquire, when the calling service is a second type calling service, the historical request response duration of the called service, the starting sending time point of the calling request, and the forwarding sending time point of the calling service sending the calling request; the second type calling service refers to the calling service that receives and forwards the calling request;

[0046] A first calculation unit is used to calculate a first duration obtained by subtracting the forwarding sending time point from the starting sending time point, and calculate a second duration obtained by adding the first duration to the historical request response duration;

[0047] A second determining unit is configured to determine that the timeout duration satisfies the first condition when the second duration is less than or equal to the timeout duration; and to determine that the timeout duration does not satisfy the first condition when the second duration is greater than the timeout duration.

[0048] Optionally, the first acquisition unit is specifically used to obtain multiple request response durations of the called service within a recent preset time period; sort the multiple request response durations in ascending order, and take the sorted Nth request response duration as the historical request response duration of the called service, where N is a preset positive integer.

[0049] Optionally, the second judgment module includes:

[0050] A third acquisition unit is used to acquire the historical request processing time of the called service, the receiving time point of the called service receiving the calling request, and the starting sending time point of the calling request;

[0051] A second calculation unit is used to calculate a third duration obtained by subtracting the receiving time point from the starting sending time point, and calculate a fourth duration obtained by adding the third duration to the historical request processing duration;

[0052] A third determining unit is configured to determine that the timeout duration satisfies the second condition when the fourth duration is less than or equal to the timeout duration; and to determine that the timeout duration does not satisfy the second condition when the fourth duration is greater than the timeout duration.

[0053] Optionally, the first control module includes:

[0054] a notification unit, configured to control the calling service to send a timeout duration adjustment notification to a designated user when the calling service is a first type of calling service; the first type of calling service is a calling service that initially sends the calling request;

[0055] The response unit is used to control the calling service to return a request timeout response to its upstream calling service when the calling service is a second type calling service; the second type calling service refers to the calling service that receives and forwards the calling request.

[0056] In another aspect of the implementation of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; the memory is used to store computer programs; and the processor is used to implement any of the above-mentioned service calling methods when executing the program stored in the memory.

[0057] In another aspect of the present invention, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed, the computer implements any of the above-mentioned service calling methods.

[0058] In another aspect of the present invention, a computer program product including instructions is provided, which, when executed on a computer, enables the computer to implement any of the above-mentioned service calling methods.

[0059] The service calling method, device, electronic device and storage medium provided by the embodiments of the present invention intercept the calling request sent by the calling service. Before the calling service sends the calling request to the called service, if the timeout duration of the calling request does not meet the first condition, the calling request will no longer be sent to the called service, and the request timeout processing will be performed, thereby avoiding invalid calls and reducing the invalid load of the service. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0061] Figure 1 The present invention is a flowchart of a method for invoking a service in an embodiment of the present invention.

[0062] Figure 2 The present invention is a flowchart of another method for invoking a service in an embodiment of the present invention.

[0063] Figure 3 The figure is a flow chart of a service calling process in an embodiment of the present invention.

[0064] Figure 4 The figure is a structural block diagram of a service calling device in an embodiment of the present invention.

[0065] Figure 5 The figure is a structural block diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0066] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0067] The service calling method in the embodiment of the present invention can be applied to scenarios such as calling between two services or serial calling between multiple services.

[0068] The service calling method in the embodiment of the present invention can be executed by a component set in the service, which intercepts the calling request and determines the timeout period, and then determines whether the service continues to send or process the calling request.

[0069] Figure 1 The present invention is a flowchart of a method for invoking a service in an embodiment of the present invention.

[0070] like Figure 1 As shown, the service calling method may include the following steps:

[0071] Step 101, after intercepting a call request sent by the calling service to the called service, obtain the timeout duration of the call request and determine whether the timeout duration meets the first condition. If not, execute step 102; if yes, execute step 103.

[0072] When the service where the component is located is used as a calling service, the component can intercept the calling request sent by the calling service before the calling service sends the calling request and before the calling request is sent to the called service.

[0073] Since it is necessary to determine whether to continue sending the call request to the called service based on the timeout duration of the call request, the component can obtain the timeout duration of the call request after intercepting the call request sent by the calling service.

[0074] Among them, the timeout period of the call request can be pre-set by a designated user (such as an administrator, etc.), and the timeout period of the call request sent by the calling service to different called services can be the same or different. It can be set according to actual needs, and this embodiment does not impose any restrictions on this.

[0075] Exemplarily, when the calling service generates a calling request, the calling request may carry information such as the timeout duration of the calling request. Therefore, after intercepting the calling request sent by the calling service, the component may parse the calling request to obtain information such as the timeout duration of the calling request.

[0076] Since it takes a certain amount of time for the called service to respond to the call request, the component can determine whether the timeout period satisfies the first condition after obtaining the timeout period of the call request. The determination process of whether the timeout period satisfies the first condition will be described in detail in the following embodiments.

[0077] Step 102: When the timeout period does not satisfy the first condition, control the calling service to perform request timeout processing.

[0078] When the component determines that the timeout period does not meet the first condition, it believes that there is a high probability that the calling request will time out. Therefore, the calling service no longer continues to send the calling request to the called service, and the component controls the calling service to perform request timeout processing.

[0079] In implementation, the component may send a notification to the calling service where it is located that the timeout duration does not satisfy the first condition. After receiving the notification that the timeout duration does not satisfy the first condition, the calling service performs request timeout processing.

[0080] Step 103: When the timeout period satisfies the first condition, control the calling service to send the calling request to the called service.

[0081] When the component determines that the timeout period meets the first condition, it believes that the call request is likely to succeed, so it controls the calling service to send the call request to the called service so that the called service can perform subsequent processing on the call request.

[0082] In implementation, the component may send a notification to the calling service that the timeout period meets the first condition. After receiving the notification that the timeout period meets the first condition, the calling service sends the calling request to the called service.

[0083] In an embodiment of the present invention, by intercepting the call request sent by the calling service, before the calling service sends the call request to the called service, if the timeout duration of the call request does not meet the first condition, the call request will no longer be sent to the called service, and the request timeout processing will be performed, thereby avoiding invalid calls and reducing the invalid load of the service.

[0084] Figure 2 The present invention is a flowchart of another method for invoking a service in an embodiment of the present invention.

[0085] like Figure 2 As shown, the service calling method may include the following steps:

[0086] Step 201, after intercepting a call request sent by the calling service to the called service, obtain the timeout duration of the call request and determine whether the timeout duration meets the first condition. If not, execute step 202; if yes, execute step 203.

[0087] Considering that the calling service may be a first type calling service or a second type calling service, different methods are used to determine whether the timeout duration satisfies the first condition for the first type calling service and the second type calling service.

[0088] The first type of calling service refers to the service that initially sends the calling request; the second type of calling service refers to the calling service that receives and forwards the calling request, specifically, the service that receives the calling request sent by its upstream calling service and forwards the calling request to its downstream called service. For example, in the service calling process, the service calling sequence is service 1 calling service 2, and service 2 calling service 3, then service 1 is the first type of calling service, and service 2 is the second type of calling service.

[0089] Exemplarily, when the calling service is a first type of calling service, the process of determining whether the timeout period satisfies the first condition may include: obtaining the historical request response period of the called service; when the historical request response period is less than or equal to the timeout period, determining that the timeout period satisfies the first condition; when the historical request response period is greater than the timeout period, determining that the timeout period does not satisfy the first condition. In this way, based on the comparison between the historical request response period of the called service and the timeout period of the calling request, it can accurately reflect whether the called service can complete the response to the calling request before the timeout period of the calling request is reached, and the judgment result is more accurate.

[0090] In the calling service, the request response time of the called service when the calling service calls the called service in history can be recorded, so the historical request response time of the called service can be obtained according to these recorded request response times.

[0091] Exemplarily, the process of obtaining the historical request response duration of the called service may include: obtaining multiple request response durations of the called service within the most recent preset time period; sorting the multiple request response durations in ascending order, and taking the Nth request response duration after sorting as the historical request response duration of the called service, where N is a preset positive integer. The historical request response duration selected in this way can more accurately represent the request response status of the called service. The specific values ​​of the above-mentioned preset time period and N can be set according to actual needs, and this embodiment does not impose any restrictions on this.

[0092] For example, the P999 value can be used as the historical request response time of the called service. The P999 value represents that the request response time of 99.9% of the calling requests does not exceed this value. Therefore, 1000 request response times within the most recent preset time period (such as 5 minutes, etc.) can be obtained; the 1000 request response times are sorted in ascending order, and the 999th (i.e., 99.9% position) request response time after sorting is used as the historical request response time of the called service.

[0093] Exemplarily, when the calling service is a second type of calling service, the process of determining whether the timeout period satisfies the first condition may include: obtaining the historical request response period of the called service, the starting sending time point of the calling request, and the forwarding sending time point when the calling service sends the calling request; calculating a first period obtained by subtracting the forwarding sending time point from the starting sending time point, and calculating a second period obtained by adding the first period to the historical request response period; when the second period is less than or equal to the timeout period, determining that the timeout period satisfies the first condition; when the second period is greater than the timeout period, determining that the timeout period does not satisfy the first condition.

[0094] For the process of obtaining the historical request response time of the called service, reference may be made to the relevant content above, and this embodiment will not be discussed in detail here.

[0095] Exemplarily, when the component intercepts the call request sent by the first type of call service, it can record the current time point as the starting sending time point of the call request, and add the starting sending time point of the call request and other information in the call request. Therefore, the starting sending time point of the call request and other information can be obtained by parsing the call request.

[0096] Exemplarily, when the component intercepts the call request sent by the second type of call service, it can record the current time point as the forwarding sending time point of the call request.

[0097] Among them, the first duration obtained by subtracting the forwarding sending time point from the starting sending time point refers to the time consumed from the time when the call request is sent by the first type of call service to the time when it is sent by the second type of call service. The second duration obtained by adding the first duration to the historical request response duration refers to the time consumed from the time when the call request is sent by the first type of call service to the time when it is sent by the current second type of call service, plus the historical request response duration of the called service. Therefore, the second duration can represent the total time that will pass from the initial sending of the call request to the completion of the response by the called service. In this way, based on the comparison of the total time that will pass from the initial sending of the call request to the completion of the response by the called service and the timeout duration of the call request, it can accurately reflect whether the called service can complete the response to the call request before reaching the timeout duration of the call request, and the judgment result is more accurate.

[0098] Step 202: When the timeout period does not satisfy the first condition, the calling service is controlled to perform request timeout processing. Considering that the calling service may be a first type calling service or a second type calling service, the calling service is controlled to perform request timeout processing in different ways for the first type calling service and the second type calling service.

[0099] Exemplarily, when the calling service is a first type of calling service, the calling service may be controlled to send a timeout duration adjustment notification to a designated user (such as an administrator, etc.) so that the designated user may adjust the timeout duration in a timely manner.

[0100] The timeout adjustment notification may include information such as the timeout of the call request, the historical request response time of the called service, etc. The designated user may adjust the timeout of the call request according to the actual situation based on the timeout adjustment notification, such as adjusting the timeout of the call request to be greater than the historical request response time of the called service, etc.

[0101] Exemplarily, when the calling service is a second type calling service, the calling service can be controlled to return a request timeout response to its upstream calling service, so that the calling service no longer continues to process the calling request, thereby reducing invalid load.

[0102] If the calling service that receives the request timeout response still has an upstream calling service, the calling service returns the request timeout response to the upstream calling service in sequence until the request timeout response is returned to the first type calling service. After receiving the request timeout response, the first type calling service may issue a timeout adjustment notification to a designated user (such as an administrator, etc.). The designated user may adjust the timeout of the calling request according to the actual situation based on the timeout adjustment notification.

[0103] Step 203, when the timeout period meets the first condition, control the calling service to send the calling request to the called service. Step 204, after intercepting the calling request received by the called service, obtain the timeout period of the calling request and determine whether the timeout period meets the second condition. If not, execute step 205; if yes, execute step 206.

[0104] When the service where the component is located serves as a called service, the component can intercept the call request received by the called service when the called service receives the call request.

[0105] Since it is necessary to determine whether the called service continues to process the call request based on the timeout duration of the call request, the component can obtain the timeout duration of the call request after intercepting the call request received by the called service.

[0106] Exemplarily, when the calling service generates a calling request, the calling request may carry information such as the timeout duration of the calling request. Therefore, after intercepting the calling request received by the called service, the component may parse the calling request to obtain information such as the timeout duration of the calling request.

[0107] Since it takes a certain amount of time for the called service to process the calling request, after obtaining the timeout duration of the calling request, the component can determine whether the timeout duration satisfies the second condition.

[0108] Exemplarily, the process of determining whether the timeout period satisfies the second condition may include: obtaining the historical request processing time of the called service, the receiving time point when the called service receives the calling request, and the starting sending time point of the calling request; calculating a third time point obtained by subtracting the receiving time point from the starting sending time point, and calculating a fourth time point obtained by adding the third time point to the historical request processing time point; when the fourth time point is less than or equal to the timeout period, determining that the timeout period satisfies the second condition; when the fourth time point is greater than the timeout period, determining that the timeout period does not satisfy the second condition.

[0109] In the called service, the called service can record the request processing time of the called service in the history of processing the call request sent by the calling service, so the historical request processing time of the called service can be obtained based on these recorded request processing times.

[0110] Exemplarily, the process of obtaining the historical request processing time of the called service may include: obtaining multiple request processing times of the called service within a recent preset time period; and taking the average of the multiple request processing times as the historical request processing time of the called service.

[0111] Exemplarily, when a component intercepts a call request received by a called service, the component may record the current time point as the receiving time point when the called service receives the call request.

[0112] Exemplarily, when the component intercepts the call request sent by the first type of call service, it can record the current time point as the starting sending time point of the call request, and add the starting sending time point of the call request and other information in the call request. Therefore, the starting sending time point of the call request and other information can be obtained by parsing the call request.

[0113] Among them, the third duration obtained by subtracting the receiving time point from the starting sending time point refers to the time consumed from the time when the call request is sent by the first type of call service to the time when it is received by the called service. The fourth duration obtained by adding the third duration to the historical request processing duration refers to the time consumed from the time when the call request is sent by the first type of call service to the time when it is received by the called service, plus the historical request processing duration of the called service. Therefore, the fourth duration can represent the total time that will pass from the initial sending of the call request to the completion of processing by the called service. In this way, based on the comparison of the total time that will pass from the initial sending of the call request to the completion of processing by the called service and the timeout duration of the call request, it can accurately reflect whether the called service can complete the processing of the call request before reaching the timeout duration of the call request, and the judgment result is more accurate.

[0114] Step 205: When the timeout period does not satisfy the second condition, control the called service to return a request timeout response to the calling service.

[0115] When the component determines that the timeout period does not meet the second condition, it considers that the call request is likely to time out, so the called service no longer continues to process the call request, and the component controls the called service to return a request timeout response to the calling service.

[0116] In implementation, the component may send a notification to the called service that the timeout period does not satisfy the second condition. After receiving the notification that the timeout period does not satisfy the second condition, the called service returns a request timeout response to the calling service.

[0117] If the calling service that receives the request timeout response still has an upstream calling service, the calling service returns the request timeout response to the upstream calling service in sequence until the request timeout response is returned to the first type calling service. After receiving the request timeout response, the first type calling service may issue a timeout adjustment notification to a designated user (such as an administrator, etc.). The designated user may adjust the timeout of the calling request according to the actual situation based on the timeout adjustment notification.

[0118] Step 206: When the timeout period satisfies the second condition, control the called service to process the calling request.

[0119] When the component determines that the timeout period meets the second condition, it believes that there is a high probability that the call request will succeed, and therefore controls the called service to process the call request.

[0120] In implementation, the component may send a notification to the called service that the timeout period satisfies the second condition. After receiving the notification that the timeout period satisfies the second condition, the called service processes the call request.

[0121] After the called service completes processing the call request, if there is no downstream called service of the called service, the called service will return the call request processing result to the calling service; if there is a downstream called service of the called service, the called service will continue to send the call request to the downstream called service as the calling service, so that the component intercepts the call request sent by the calling service and repeats the above steps 201 to 206.

[0122] In an embodiment of the present invention, on the basis of controlling the calling service, control over the called service is further added. By intercepting the calling request received by the called service, before the called service processes the calling request, if the timeout duration of the calling request does not meet the second condition, the called service will no longer process the calling request and will promptly return a request timeout response to the calling service, thereby avoiding invalid processing of the calling request, improving the response efficiency of the service call, and reducing the invalid load of the service.

[0123] Figure 3 The figure is a flow chart of a service calling process in an embodiment of the present invention. Figure 3 In the example, service A is a first type calling service.

[0124] like Figure 3 As shown, the service call process may include:

[0125] (1) Service A prepares to call service B and sends a call request to service B. The component of service A intercepts the call request sent by service A.

[0126] (2) The component of service A obtains the timeout duration of the call request, the starting time of the call request, and the historical request response duration of service B.

[0127] (3) The component of service A determines whether the timeout period of the call request is sufficient.

[0128] That is, it is determined whether the timeout duration of the call request satisfies the first condition.

[0129] Specifically, compare the timeout duration of the call request with the historical request response duration of service B. When the historical request response duration of service B is less than or equal to the timeout duration of the call request, it is determined that the timeout duration of the call request is sufficient (that is, the first condition is met). When the historical request response duration of service B is greater than the timeout duration of the call request, it is determined that the timeout duration of the call request is insufficient (that is, the first condition is not met).

[0130] (4) If the timeout period of the call request is insufficient, service A sends a timeout adjustment notification to the designated user.

[0131] (5) If the timeout period of the call request is sufficient, service A sends a call request to service B.

[0132] (6) Service B receives the call request sent by Service A, and the component of Service B intercepts the call request received by Service B.

[0133] (7) The component of service B determines whether the timeout period of the call request is sufficient.

[0134] That is, it is determined whether the timeout duration of the call request satisfies the second condition.

[0135] Specifically, obtain the historical request processing duration of service B, the receiving time point when service B receives the call request, and the starting sending time point of the call request, calculate the third duration obtained by subtracting the receiving time point from the starting sending time point, calculate the fourth duration obtained by adding the third duration to the historical request processing duration, compare the timeout duration of the call request with the fourth duration, and when the fourth duration is less than or equal to the timeout duration of the call request, determine that the timeout duration of the call request is sufficient (that is, the second condition is met); when the fourth duration is greater than the timeout duration of the call request, determine that the timeout duration of the call request is insufficient (that is, the second condition is not met).

[0136] (8) If the timeout period of the call request is insufficient, service B returns a request timeout response to service A.

[0137] (9) If the timeout period of the call request is sufficient, service B processes the internal logic of the interface of the call request.

[0138] (10) Service B processes the call request and sends it to service C. The component of service B intercepts the call request sent by service B.

[0139] (11) The component of service B determines whether the timeout period of the call request is sufficient.

[0140] Specifically, obtain the forwarding sending time point when service B sends the call request, and the starting sending time point of the call request, calculate the fifth time duration obtained by subtracting the forwarding sending time point from the starting sending time point, compare the timeout time of the call request with the fifth time duration, and when the fifth time duration is less than or equal to the timeout time of the call request, determine that the timeout time of the call request is sufficient; when the fifth time duration is greater than the timeout time of the call request, determine that the timeout time of the call request is insufficient.

[0141] (12) If the timeout period of the call request is insufficient, service B returns a request timeout response to service A.

[0142] (13) If the timeout period of the call request is sufficient, the component of service B obtains the historical request response time of service C, the forwarding time point when service B sends the call request, the starting time point when the call request is sent, and the timeout period of the call request.

[0143] (14) The component of service B determines whether the timeout period of the call request is sufficient.

[0144] That is, it is determined whether the timeout duration of the call request satisfies the first condition.

[0145] Specifically, a first duration is calculated by subtracting the forwarding sending time point from the starting sending time point, and a second duration is calculated by adding the first duration to the historical request response duration of service C; when the second duration is less than or equal to the timeout duration of the call request, it is determined that the timeout duration of the call request is sufficient (that is, the first condition is met); when the second duration is greater than the timeout duration of the call request, it is determined that the timeout duration of the call request is insufficient (that is, the first condition is not met).

[0146] (15) If the timeout period of the call request is insufficient, service B returns a request timeout response to service A.

[0147] (16) If the timeout period of the call request is sufficient, service B sends a call request to service C.

[0148] (17) The internal processing logic of service C is the same as the internal processing logic of service B.

[0149] (18) After service C completes processing the call request, it returns the call request processing result to service B.

[0150] (19) Service B returns the call request processing result to service A.

[0151] The following is an introduction to the service calling process through a specific example.

[0152] Service A is ready to call service B at time t1, and the timeout duration is set to m. The P999 value of the request response duration of service A calling service B in the past 5 minutes is x. If x is greater than m, then this call request is likely to time out, and a request timeout response can be directly returned, and the administrator can be reminded to adjust the timeout duration. If x is less than or equal to m, then this call request is likely to succeed, assuming that x is less than or equal to m. The time when service B receives the call request from service A is t2. The network time consumed between service A and service B for this call request is t2-t1, and the average request processing duration of service B in the past 5 minutes is n. If t2-t1+n is greater than m, a request timeout response is returned in advance. If t2-t1+n is less than or equal to m, the internal logic of the service B interface is continued to process the call request. The time when service B completes the call request is t3. At this time, service B is ready to call service C. The P999 value of the request response duration of service B calling service C in the past 5 minutes is y. If t3-t1+y is greater than m, a request timeout response is returned. If t3-t1+y is less than or equal to m, then continue to call service N. The subsequent interface call logic is similar and will not be repeated here.

[0153] In the embodiment of the present invention, it can be dynamically determined whether to directly return a request timeout response or continue processing for a call request, which greatly saves invalid waiting time, improves response time, and reduces invalid load on the machine.

[0154] Figure 4 The figure is a structural block diagram of a service calling device in an embodiment of the present invention.

[0155] like Figure 4 As shown, the service calling device may include the following modules:

[0156] The first judgment module 301 is used to obtain the timeout duration of the calling request after intercepting the calling service sending the calling service to the called service, and judge whether the timeout duration meets the first condition;

[0157] A first control module 302, configured to control the calling service to perform request timeout processing when the timeout duration does not satisfy the first condition;

[0158] The second control module 303 is used to control the calling service to send the calling request to the called service when the timeout period meets the first condition.

[0159] Optionally, the device further comprises:

[0160] A second judgment module is used to obtain a timeout duration of the calling request after intercepting the calling request received by the called service, and judge whether the timeout duration satisfies a second condition;

[0161] A third control module, configured to control the called service to return a request timeout response to the calling service when the timeout duration does not satisfy the second condition;

[0162] The fourth control module is used to control the called service to process the calling request when the timeout period meets the second condition.

[0163] Optionally, the first determining module 301 includes:

[0164] A first acquisition unit is used to acquire the historical request response duration of the called service when the calling service is a first type calling service; the first type calling service is the calling service that initially sends the calling request;

[0165] A first determination unit is configured to determine that the timeout period satisfies the first condition when the historical request response period is less than or equal to the timeout period; and to determine that the timeout period does not satisfy the first condition when the historical request response period is greater than the timeout period.

[0166] Optionally, the first determining module 301 includes:

[0167] A second acquisition unit is used to acquire, when the calling service is a second type calling service, the historical request response duration of the called service, the starting sending time point of the calling request, and the forwarding sending time point of the calling service sending the calling request; the second type calling service refers to the calling service that receives and forwards the calling request;

[0168] A first calculation unit is used to calculate a first duration obtained by subtracting the forwarding sending time point from the starting sending time point, and calculate a second duration obtained by adding the first duration to the historical request response duration;

[0169] A second determining unit is configured to determine that the timeout duration satisfies the first condition when the second duration is less than or equal to the timeout duration; and to determine that the timeout duration does not satisfy the first condition when the second duration is greater than the timeout duration.

[0170] Optionally, the first acquisition unit is specifically used to obtain multiple request response durations of the called service within a recent preset time period; sort the multiple request response durations in ascending order, and take the sorted Nth request response duration as the historical request response duration of the called service, where N is a preset positive integer.

[0171] Optionally, the second judgment module includes:

[0172] A third acquisition unit is used to acquire the historical request processing time of the called service, the receiving time point of the called service receiving the calling request, and the starting sending time point of the calling request;

[0173] A second calculation unit is used to calculate a third duration obtained by subtracting the receiving time point from the starting sending time point, and calculate a fourth duration obtained by adding the third duration to the historical request processing duration;

[0174] A third determining unit is configured to determine that the timeout duration satisfies the second condition when the fourth duration is less than or equal to the timeout duration; and to determine that the timeout duration does not satisfy the second condition when the fourth duration is greater than the timeout duration.

[0175] Optionally, the first control module 302 includes:

[0176] a notification unit, configured to control the calling service to send a timeout duration adjustment notification to a designated user when the calling service is a first type of calling service; the first type of calling service is a calling service that initially sends the calling request;

[0177] The response unit is used to control the calling service to return a request timeout response to its upstream calling service when the calling service is a second type calling service; the second type calling service refers to the calling service that receives and forwards the calling request.

[0178] In an embodiment of the present invention, by intercepting the call request sent by the calling service, before the calling service sends the call request to the called service, if the timeout period of the call request does not meet the first condition, the call request will no longer be sent to the called service, and request timeout processing will be performed, thereby avoiding invalid calls; by intercepting the call request received by the called service, before the called service processes the call request, if the timeout period of the call request does not meet the second condition, the called service will no longer process the call request, and will promptly return a request timeout response to the calling service, thereby avoiding invalid processing of the call request, improving the response efficiency of service calls, and reducing the invalid load of the service.

[0179] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 401 , a communication interface 402 , a memory 403 and a communication bus 404 , wherein the processor 401 , the communication interface 402 , and the memory 403 communicate with each other via the communication bus 404 .

[0180] Memory 403, used for storing computer programs;

[0181] The processor 401 is used to execute the program stored in the memory 403 to implement the following steps:

[0182] After intercepting a call request sent by the calling service to the called service, obtaining a timeout duration of the call request, and determining whether the timeout duration satisfies a first condition;

[0183] When the timeout duration does not satisfy the first condition, controlling the calling service to perform request timeout processing;

[0184] When the timeout period meets the first condition, the calling service is controlled to send the calling request to the called service.

[0185] Optionally, the method further comprises:

[0186] After intercepting the call request received by the called service, obtaining the timeout duration of the call request, and determining whether the timeout duration satisfies the second condition;

[0187] When the timeout period does not satisfy the second condition, controlling the called service to return a request timeout response to the calling service;

[0188] When the timeout period meets the second condition, the called service is controlled to process the calling request.

[0189] Optionally, determining whether the timeout duration satisfies a first condition includes:

[0190] When the calling service is a first type calling service, obtaining the historical request response duration of the called service; the first type calling service refers to the calling service that initially sends the calling request;

[0191] When the historical request response duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the first condition;

[0192] When the historical request response duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the first condition.

[0193] Optionally, determining whether the timeout duration satisfies a first condition includes:

[0194] When the calling service is a second type calling service, obtaining the historical request response duration of the called service, the starting sending time point of the calling request, and the forwarding sending time point when the calling service sends the calling request; the second type calling service refers to the calling service that receives and forwards the calling request;

[0195] Calculate a first duration obtained by subtracting the forwarding sending time point from the starting sending time point, and calculate a second duration obtained by adding the first duration to the historical request response duration;

[0196] When the second duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the first condition;

[0197] When the second duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the first condition.

[0198] Optionally, obtaining the historical request response duration of the called service includes:

[0199] Obtaining multiple request response durations of the called service within a recent preset time period;

[0200] The multiple request response time durations are sorted in ascending order, and the Nth request response time duration after sorting is used as the historical request response time duration of the called service, where N is a preset positive integer.

[0201] Optionally, determining whether the timeout duration satisfies a second condition includes:

[0202] Obtain the historical request processing time of the called service, the time point at which the called service receives the calling request, and the starting sending time point of the calling request;

[0203] Calculate a third duration obtained by subtracting the receiving time point from the starting sending time point, and calculate a fourth duration obtained by adding the third duration to the historical request processing duration;

[0204] When the fourth duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the second condition;

[0205] When the fourth duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the second condition.

[0206] Optionally, controlling the calling service to perform request timeout processing includes:

[0207] When the calling service is a first type calling service, controlling the calling service to send a timeout duration adjustment notification to a designated user; the first type calling service is a calling service that initially sends the calling request;

[0208] When the calling service is a second type calling service, the calling service is controlled to return a request timeout response to its upstream calling service; the second type calling service refers to a calling service that receives and forwards the calling request.

[0209] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0210] The communication interface is used for communication between the above terminal and other devices.

[0211] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0212] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0213] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the instructions are executed on a computer, the computer implements the service calling method described in any one of the above embodiments.

[0214] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is executed on a computer, the computer implements the service calling method described in any one of the above embodiments.

[0215] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0216] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0217] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0218] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A service calling method, characterized in that: include: After intercepting a call request sent by the calling service to the called service, obtaining a timeout duration of the call request, and determining whether the timeout duration satisfies a first condition; When the timeout duration does not satisfy the first condition, controlling the calling service to perform request timeout processing; When the timeout period meets the first condition, the calling service is controlled to send the calling request to the called service.

2. The method according to claim 1, characterized in that: The method further comprises: After intercepting the call request received by the called service, obtaining the timeout duration of the call request, and determining whether the timeout duration satisfies the second condition; When the timeout period does not satisfy the second condition, controlling the called service to return a request timeout response to the calling service; When the timeout period meets the second condition, the called service is controlled to process the calling request.

3. The method according to claim 1, characterized in that Determining whether the timeout period satisfies the first condition includes: When the calling service is a first type calling service, obtaining the historical request response duration of the called service; the first type calling service refers to the calling service that initially sends the calling request; When the historical request response duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the first condition; When the historical request response duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the first condition.

4. The method according to claim 1, characterized in that: Determining whether the timeout period satisfies the first condition includes: When the calling service is a second type calling service, obtaining the historical request response duration of the called service, the starting sending time point of the calling request, and the forwarding sending time point when the calling service sends the calling request; the second type calling service refers to the calling service that receives and forwards the calling request; Calculate a first duration obtained by subtracting the forwarding sending time point from the starting sending time point, and calculate a second duration obtained by adding the first duration to the historical request response duration; When the second duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the first condition; When the second duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the first condition.

5. The method according to claim 3 or 4, characterized in that: Get the historical request response time of the called service, including: Obtaining multiple request response times of the called service within a recent preset time period; The multiple request response time durations are sorted in ascending order, and the Nth request response time duration after sorting is used as the historical request response time duration of the called service, where N is a preset positive integer.

6. The method according to claim 2, characterized in that Determining whether the timeout duration satisfies the second condition includes: Obtain the historical request processing time of the called service, the time point at which the called service receives the calling request, and the starting sending time point of the calling request; Calculate a third duration obtained by subtracting the receiving time point from the starting sending time point, and calculate a fourth duration obtained by adding the third duration to the historical request processing duration; When the fourth duration is less than or equal to the timeout duration, determining that the timeout duration satisfies the second condition; When the fourth duration is greater than the timeout duration, it is determined that the timeout duration does not satisfy the second condition.

7. The method according to claim 1, characterized in that Controlling the calling service to perform request timeout processing, including: When the calling service is a first type calling service, controlling the calling service to send a timeout duration adjustment notification to a designated user; the first type calling service is a calling service that initially sends the calling request; When the calling service is a second type calling service, the calling service is controlled to return a request timeout response to its upstream calling service; the second type calling service refers to a calling service that receives and forwards the calling request.

8. A service calling device, characterized in that: include: A first judgment module is used to obtain a timeout duration of the calling request after intercepting the calling service sending the calling service to the called service, and judge whether the timeout duration satisfies a first condition; A first control module, configured to control the calling service to perform request timeout processing when the timeout duration does not meet the first condition; The second control module is used to control the calling service to send the calling request to the called service when the timeout period meets the first condition.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method according to any one of claims 1 to 7 when executing a program stored in a memory.

10. A computer-readable storage 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

Patent Citations

  • Service timeout management method and device

    CN113783822A

  • Request timeout detection method and device, equipment and storage medium

    CN114661510A

  • Service calling method and device, electronic equipment and storage medium

    CN115495256A

  • Method and device for controlling online and offline of micro service, and storage medium

    CN116521387A

  • Remote procedure call control method, device and equipment and computer storage medium

    CN117201570A