Time management method and apparatus, microservice system, and computing device cluster
By employing a non-intrusive time management method, and utilizing a Java agent to obtain and transmit the timestamps and remaining time of communication requests, the problem of independence and cross-architecture transmission of timeout detection in microservice architectures is solved, achieving efficient timeout detection and task management.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2026-03-26
AI Technical Summary
In existing microservice architectures, microservices cannot independently detect whether the computing task corresponding to a communication request has timed out, and timeout status cannot be effectively detected when transmitting data between different microservice architectures.
A non-intrusive time management approach is adopted, using tools such as Java agents to obtain the timestamps, remaining time, and execution time of communication requests, enabling each microservice to independently detect timeouts and transmit time data between different microservice architectures.
Each microservice can independently detect whether its own computation task has timed out, avoiding unnecessary computation, improving system efficiency, and maintaining the continuity of timeout detection across different microservice architectures.
Smart Images

Figure CN2025090987_26032026_PF_FP_ABST
Abstract
Description
Time management method, device, microservice system and computing device cluster
[0001] The present application claims priority to the Chinese patent application No. 202411302993.8, filed on September 18, 2024, and entitled "Time management method, device, microservice system and computing device cluster", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the technical field of microservices, and in particular to a time management method, device, microservice system and computing device cluster. BACKGROUND
[0003] Timeout setting refers to setting the timeout time of an operation or connection in software or network applications. In software development or network configuration, timeout setting can be used to limit the maximum waiting time of an operation or connection to avoid wasting system resources or poor user experience due to long waiting time. SUMMARY
[0004] To solve the above problems, the embodiments of the present application provide a time management method, which can enable each microservice to independently detect whether the execution of a computing task corresponding to a communication request is timed out. In addition, the present application also provides a time management device, a microservice system and a computing device cluster corresponding to the time management method.
[0005] To this end, the embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, the embodiments of the present application provide a time management method, a microservice system includes a plurality of microservices, the plurality of microservices includes a first microservice, the method is executed by the first microservice, and the method includes: obtaining a communication carrier of a first communication request; the communication carrier includes a first timestamp, a first remaining time and a first execution time; the first timestamp is the sending time of the first communication request; the first remaining time is determined according to the total execution time set by the first communication request; the first execution time is the predicted time for the first microservice to process a computing task corresponding to the first communication request; determining whether the first microservice is timed out after completing the computing task corresponding to the first communication request according to the first timestamp, a second timestamp, the first remaining time and the first execution time; the second timestamp is the time when the first microservice receives the first communication request.
[0007] In this embodiment, after receiving the first communication request, the first microservice can call a tool such as a java agent to obtain the time of sending the communication carrier record, the remaining time and the execution time of the microservice from the first communication request in a non-intrusive manner, and then detect whether the remaining time carried by the communication carrier is less than the communication time of receiving the first communication request and the time of executing the corresponding computing task of the first communication request, so as to realize that the first microservice can independently detect whether the execution of the corresponding computing task of the first communication request is timed out.
[0008] In an embodiment, before obtaining the communication carrier of the first communication request, the method further comprises: receiving the first communication request sent by the client or the second microservice; the plurality of microservices further comprise the second microservice, and the first microservice and the second microservice belong to microservices in at least one microservice architecture.
[0009] In this embodiment, the first microservice can receive the first communication request sent by the microservice of different microservice architecture, realize the transmission of the first communication request between the microservices of different architectures, and still detect whether the communication request is timed out.
[0010] In an embodiment, the method further comprises: based on the first timestamp, the second timestamp, the first remaining time and the first execution time, determining whether the first microservice is timed out after completing the corresponding computing task of the first communication request, specifically comprising: based on the first timestamp, the second timestamp and the first remaining time, detecting whether the communication time of the first communication request is timed out; in the case that the communication time of the first communication request is not timed out, based on the first remaining time, the communication time of the first communication request and the first execution time, determining whether the first microservice is timed out after completing the corresponding computing task of the first communication request.
[0011] In this embodiment, the first microservice can determine the communication time of receiving the communication request and the execution time of executing the corresponding computing task of the first communication request based on the sending time of the first communication request, the current time, the remaining time after the execution of the communication request and the predicted execution time of the first microservice, and then detect whether the execution of the corresponding task of the first communication request is timed out according to the communication time and the execution time, so as to realize that the first microservice can independently detect whether the execution of the corresponding task of the communication request is timed out.
[0012] In an embodiment, the detecting whether the communication time of the first communication request is overdue based on the first timestamp, the second timestamp and the first remaining time specifically comprises: obtaining the communication time of the first communication request according to the difference between the first timestamp and the second timestamp; obtaining a second remaining time according to the difference between the first remaining time and the communication time of the first communication request; detecting whether the second remaining time is less than 0, and determining that the communication time of the first communication request is not overdue when the second remaining time is greater than or equal to 0.
[0013] In this embodiment, the first microservice method can avoid the first microservice continuing to execute the computing task corresponding to the first communication request when the first microservice has been overdue upon receiving the first communication request, so as to reduce unnecessary computing amount.
[0014] In an embodiment, the determining whether the first microservice is overdue after completing the computing task corresponding to the first communication request based on the first remaining time, the communication time of the first communication request and the first execution time specifically comprises: detecting whether a second remaining time is less than the first execution time; and determining that the first microservice is not overdue after completing the computing task corresponding to the first communication request when the second remaining time is greater than or equal to the first execution time.
[0015] In an embodiment, the method further comprises: obtaining a third timestamp; the third timestamp is the time after the first microservice completes the computing task corresponding to the first communication request; obtaining the computing time of the first microservice according to the second timestamp and the third timestamp; the computing time of the first microservice is the time for the first microservice to complete the computing task corresponding to the first communication request; obtaining a third remaining time according to the second remaining time and the second execution time; the third remaining time is the time for other microservices after the first microservice to execute the computing task corresponding to the first communication request.
[0016] In this embodiment, after the first microservice completes the computing task corresponding to the first communication request, the first microservice can subtract the communication time and the actual execution time from the remaining time in the communication carrier to obtain the remaining time for the subsequent microservice to execute the communication request, so that the subsequent other microservices can detect whether the task corresponding to the communication request is overdue after receiving the communication request.
[0017] In an embodiment, the method further comprises: obtaining a fourth residual time; the fourth residual time is a residual time recorded in the configuration center or the configuration file after the first microservice performs a computing task corresponding to the first communication request; selecting a residual time with a shorter time from the third residual time and the fourth residual time, and determining whether the third microservice is overtime after completing the computing task corresponding to the first communication request according to the selected residual time and a second execution time; the second execution time is a computing time of the third microservice, and the plurality of microservices comprises the third microservice, and the third microservice is a microservice receiving the first communication request forwarded by the first microservice.
[0018] In this embodiment, the first microservice can compare the predicted execution time of the next microservice with the residual time of the next microservice performing the computing task corresponding to the communication request, so as to avoid the case that the predicted execution time of the next microservice is less than the residual time, and continue to forward the communication request, thereby reducing the computing amount of the first microservice.
[0019] In an embodiment, the method further comprises: in the case that the third microservice is not overtime after completing the computing task corresponding to the communication request, obtaining a communication carrier of a second communication request according to the third timestamp, the third residual time and the second execution time, wherein the communication carrier of the second communication request comprises the third timestamp, the third residual time and the second execution time; and sending the second communication request to the third microservice.
[0020] In this embodiment, in the case that the first microservice determines that the execution of the first communication request corresponding to the computing task is not overtime, the first microservice can record the time of sending the communication request, the residual time and the execution time of the microservice in the communication carrier in the communication request in a non-intrusive manner, so that the time data can be transmitted among the microservices in different microservice architectures along with the communication request, thereby realizing the transmission of the communication request among the microservices in different architectures, and still enabling each microservice to detect whether the communication request is overtime.
[0021] In a second aspect, an embodiment of the present application provides a time management apparatus, comprising: a first processing unit configured to obtain a communication carrier of a first communication request; the communication carrier comprising a first timestamp, a first remaining time and a first execution time; the first timestamp being a sending time of the first communication request; the first remaining time being determined according to a total execution time set by the first communication request; the first execution time being a predicted time for the first microservice to process a computing task corresponding to the first communication request; determining whether the first microservice is overtime after completing the computing task corresponding to the first communication request according to the first timestamp, a second timestamp, the first remaining time and the first execution time; and the second timestamp being a time when the first microservice receives the first communication request.
[0022] In an embodiment, the first processing unit is further configured to receive the first communication request sent by a client or a second microservice before obtaining the communication carrier of the first communication request; the plurality of microservices further comprises the second microservice, and the first microservice and the second microservice belong to microservices in at least one microservice architecture.
[0023] In an embodiment, the first processing unit is specifically configured to detect whether a communication time of the first communication request is overtime based on the first timestamp, the second timestamp and the first remaining time; and determine whether the first microservice is overtime after completing the computing task corresponding to the first communication request based on the first remaining time, the communication time of the first communication request and the first execution time in a case that the communication time of the first communication request is not overtime.
[0024] In an embodiment, the first processing unit is specifically configured to obtain the communication time of the first communication request according to a difference between the first timestamp and the second timestamp; obtain a second remaining time according to a difference between the first remaining time and the communication time of the first communication request; detect whether the second remaining time is less than 0; and determine that the communication time of the first communication request is not overtime in a case that the second remaining time is greater than or equal to 0.
[0025] In an embodiment, the first processing unit is specifically configured to detect whether the second remaining time is less than the first execution time; and determine that the first microservice is not overtime after completing the computing task corresponding to the first communication request in a case that the second remaining time is greater than or equal to the first execution time.
[0026] In an implementation, the apparatus further comprises a second processing unit configured to: obtain a third timestamp, the third timestamp being a time after the first microservice completes a computing task corresponding to the first communication request; obtain a computing time of the first microservice according to the second timestamp and the third timestamp, the computing time of the first microservice being a time for the first microservice to complete the computing task corresponding to the first communication request; obtain a third residual time according to the second residual time and the second execution time, the third residual time being a time for other microservices after the first microservice to execute the computing task corresponding to the first communication request.
[0027] In an implementation, the second processing unit is further configured to: obtain a fourth residual time, the fourth residual time being a residual time recorded in a configuration center or a configuration file after the first microservice executes the computing task corresponding to the first communication request; select a residual time with a shorter time from the third residual time and the fourth residual time, and determine whether the third microservice is timed out after completing the computing task corresponding to the first communication request according to the selected residual time and a second execution time, the second execution time being a computing time of the third microservice, the plurality of microservices including the third microservice, and the third microservice being a microservice that receives the first communication request forwarded by the first microservice.
[0028] In an implementation, the second processing unit is further configured to, in a case that the third microservice is not timed out after completing the computing task corresponding to the communication request: obtain a communication carrier of a second communication request according to the third timestamp, the third residual time, and the second execution time, the communication carrier of the second communication request including the third timestamp, the third residual time, and the second execution time; and send the second communication request to the third microservice.
[0029] In a third aspect, an embodiment of the present application provides a microservice system, comprising: a plurality of microservices, the plurality of microservices belonging to microservices in at least one microservice architecture; and any one of the plurality of microservices executes the embodiments of each possible implementation of the first aspect.
[0030] In a fourth aspect, an embodiment of the present application provides a computer system, comprising a processing unit and a storage unit; the processing unit of the computer system is configured to execute instructions stored in the processing unit, so that the computer system executes the embodiments of each possible implementation of the first aspect.
[0031] In a fifth aspect, a computer readable storage medium is provided in the embodiments of the present application, and includes computer program instructions. When the computer program instructions are executed by a computer system, the computer system performs the embodiments of each possible implementation of the first aspect.
[0032] In a sixth aspect, a computer program product containing instructions is provided in the embodiments of the present application. The computer program product stores instructions. When the instructions are executed by a computer system, the computer system implements the embodiments of each possible implementation of the first aspect.
[0033] In a seventh aspect, a computing device cluster is provided in the embodiments of the present application, and includes at least one computing device. Each computing device includes a processor and a memory. The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs the embodiments of each possible implementation of the first aspect.
[0034] In an eighth aspect, a computer readable storage medium is provided in the embodiments of the present application, and includes computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the embodiments of each possible implementation of the first aspect.
[0035] In a ninth aspect, a computer program product containing instructions is provided in the embodiments of the present application. The computer program product stores instructions. When the instructions are executed by a computing device cluster, the computing device cluster implements the embodiments of each possible implementation of the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0036] The drawings required for use in the embodiments or prior art description are briefly introduced as follows.
[0037] FIG. 1 is a schematic diagram of a process of executing a communication request by each microservice in a microservice architecture in the related art;
[0038] FIG. 2 is a schematic diagram of a structure of a microservice system provided in the embodiments of the present application;
[0039] FIG. 3 is a schematic diagram of a structure of a time management apparatus provided in the embodiments of the present application;
[0040] FIG. 4 is a schematic diagram of a scenario in which a user uses a microservice system provided in the embodiments of the present application;
[0041] FIG. 5 is a flowchart of a time management method provided in the embodiments of the present application;
[0042] FIG. 6 is a schematic diagram of a structure of a computing device provided in the embodiments of the present application;
[0043] FIG. 7 is an architecture diagram of a computing device cluster according to an embodiment of the present application;
[0044] FIG. 8 is an architecture diagram of another computing device cluster according to an embodiment of the present application. DETAILED DESCRIPTION
[0045] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
[0046] The term "and / or" in the present document is used to describe the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can mean that there are three cases of A alone, A and B together, and B alone. The symbol " / " in the present document represents the relationship of or, for example, A / B represents A or B.
[0047] The terms "first" and "second" and the like in the description and claims of the present document are used to distinguish different objects, and are not used to describe the specific order of the objects. For example, the first response message and the second response message are used to distinguish different response messages, and are not used to describe the specific order of the response messages.
[0048] In the embodiments of the present application, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design presented as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or advantageous than other embodiments or design solutions. Rather, the use of "exemplary" or "for example" is intended to present relevant concepts in a specific manner.
[0049] In the description of the embodiments of the present application, unless otherwise specified, "a plurality of" means two or more, for example, a plurality of processing units means two or more processing units, and the like; a plurality of elements means two or more elements, and the like.
[0050] Before introducing the technical solutions protected by the present application, several professional terms related to the technical solutions protected by the present application are explained in advance, which are as follows:
[0051] Microservice is a software architecture style, which is a small, independent service split from an application. Since each microservice has its own business logic, data storage, and can communicate with each other through a lightweight communication mechanism (such as hypertext transfer protocol (HTTP) application programming interface (API)), each microservice can be developed, deployed and scaled independently. Microservice architecture refers to a plurality of microservices split from an application, and each microservice is connected through a communication interface.
[0052] Configuration center is a tool for managing and distributing configuration information of an application. In a microservice architecture, an application is composed of multiple microservices, and each microservice has its own configuration information. The configuration center can centrally manage the configuration information of each microservice, and when a microservice needs configuration information, the configuration center can deliver the configuration information to the corresponding microservice. Configuration center can be ZooKeeper, Nacos, Etcd, etc.
[0053] Java agent is a small tool for Java application, which can provide the ability to execute functions during the startup and loading of Java application. Java agent can be loaded when Java virtual machine (JVM) starts, and hooked into the life cycle of JVM, which allows Java agent to modify, monitor the behavior of the application before or after class loading. Java agent can monitor, dynamically modify, optimize and enhance existing applications without modifying the source code.
[0054] Next, the technical solutions provided by the present application are introduced.
[0055] Generally, when a user uses an application, the user's corresponding client can send a communication request to the application. A microservice in the application can obtain its own configuration information from the configuration center after receiving the communication request, in order to execute the corresponding computing task in the communication request. After completing the computing task, the microservice can forward the communication request to the next microservice, so that the next microservice executes the corresponding computing task in the communication request, and so on.
[0056] After the last microservice completes the corresponding computing task in the communication request, the last microservice can send a response request to the previous microservice. The previous microservice of the last microservice can continue to send a response request to the previous microservice after receiving the response request, and so on. The first microservice in the application that receives the communication request can send a response request to the client after receiving the response request, so that the client receives the execution result of the application.
[0057] To avoid that the application takes too long to execute the communication request, the client can set the maximum time for the communication request to be executed. After a microservice in the application receives the communication request, the microservice uses a time decrement mechanism to subtract the time carried by the communication request from the communication time of receiving the communication request and the time of executing the corresponding computing task of the communication request to obtain the remaining time. If the microservice receives the communication request, and the time decrement mechanism detects that the remaining time carried by the communication request is less than the communication time of receiving the communication request or less than the time of executing the corresponding computing task of the communication request, the microservice can directly send a failure instruction to the client, indicating that the application cannot execute the communication request within the set maximum time.
[0058] Exemplarily, as shown in FIG. 1, it is assumed that the client sets the maximum time for the communication request to be executed as 600 ms. The communication time between the client and microservice A is 100 ms, the execution time of microservice A for executing the communication request is 250 ms, the communication time between microservice A and microservice B is 50 ms, the execution time of microservice B for executing the communication request is 150 ms, the communication time between microservice B and microservice C is 50 ms, and the execution time of microservice C for executing the communication request is 150 ms.
[0059] After microservice A receives the communication request, microservice A obtains the maximum time 600 ms and the time of sending the communication request by the client from the configuration center. Microservice A can use the time decrement mechanism to subtract the time of sending the communication request by the client from the time of receiving the communication request to obtain the communication time 100 ms. After microservice A completes the corresponding computing task of the communication request, microservice A can subtract the time of receiving the communication request from the current time to obtain the execution time 250 ms of microservice A. Microservice A can subtract the communication time 100 ms and the execution time 250 ms of microservice A from the maximum time 600 ms to obtain the remaining time 350 ms. After microservice A completes the corresponding computing task of the communication request, microservice A forwards the communication request to microservice B. At the same time, microservice A sends the remaining time 350 ms and the time of forwarding the communication request to microservice B to the configuration center.
[0060] Microservice B, after receiving the communication request, obtains the longest time 350 ms and the time when microservice A sends the communication request from the configuration center. Microservice B can utilize the time decrement mechanism to subtract the time when microservice A sends the communication request from the time when the communication request is received, and obtain the communication time 50 ms. After microservice B completes the corresponding computing task of the communication request, microservice B can subtract the time when the communication request is received from the current time to obtain the execution time 150 ms of microservice B. Microservice B can subtract the communication time 50 ms and the execution time 150 ms of microservice B from the remaining time 350 ms to obtain the remaining time 150 ms. After microservice B completes the corresponding computing task of the communication request, microservice B forwards the communication request to microservice C. At the same time, microservice B sends the remaining time 150 ms and the time when the communication request is forwarded to microservice C to the configuration center.
[0061] Microservice C, after receiving the communication request, obtains the longest time 150 ms and the time when microservice B sends the communication request from the configuration center. Microservice C can utilize the time decrement mechanism to subtract the time when microservice B sends the communication request from the time when the communication request is received, and obtain the communication time 50 ms. After microservice C completes the corresponding computing task of the communication request, microservice C can subtract the time when the communication request is received from the current time to obtain the execution time 150 ms of microservice C. Microservice C can subtract the communication time 50 ms and the execution time 150 ms of microservice C from the remaining time 350 ms to obtain a remaining time less than 0. At this time, microservice C cannot execute the communication request, and can send a failure instruction to the client.
[0062] The existing microservice architecture, such as Spring Cloud Feign, Dubbo, gRPC, etc., each microservice needs to utilize the configuration center to cache time data, so as to detect whether the execution of the corresponding computing task of the communication request by the microservice itself is timed out, which causes that each microservice cannot independently execute the time decrement mechanism. In addition, since different microservice architectures have their own configuration centers, the configuration centers cannot transmit time data to each other, so when the communication request is transmitted between the microservices in different microservice architectures, the microservices cannot detect whether the execution of the corresponding computing task of the communication request by the microservice itself is timed out.
[0063] Therefore, the embodiment of the present application provides a micro-service system, and a plurality of micro-services in the system can belong to different micro-service architectures. Each micro-service in the system can call a non-intrusive time management device, such as a java agent, so that each micro-service can use the non-intrusive time management device to obtain the sending time of the communication carrier record, the remaining time and the execution time of the micro-service from the communication request, and then detect whether the remaining time carried by the communication carrier is less than the communication time of receiving the communication request and the time of executing the calculation task corresponding to the communication request, so that each micro-service can independently detect whether the calculation task corresponding to the communication request is timed out.
[0064] In addition, the micro-service can use the non-intrusive time management device to record the sending time of the communication request, the remaining time and the execution time of the micro-service in the communication carrier in the communication request, so that the time data can be transmitted with the communication request in the micro-services in different micro-service architectures, so that the communication request can be transmitted between the micro-services in different architectures, and each micro-service can still detect whether the communication request is timed out.
[0065] FIG. 2 is a structural schematic diagram of a micro-service system provided in the embodiment of the present application. As shown in FIG. 2, the micro-service system 200 can include N micro-services 210 and a configuration center 220. The N micro-services 210 are micro-service 210-1, micro-service 210-2, …, and micro-service 210-N. The N micro-services 210 can belong to micro-services in the same micro-service architecture, or can belong to micro-services in multiple micro-service architectures. The micro-service architecture can be Spring Cloud Feign, Dubbo, gRPC, etc.
[0066] The configuration center 220 can be implemented by hardware or software. The configuration center 220 can be connected with micro-services belonging to one architecture, or can be connected with micro-services of multiple architectures, to achieve connection with the N micro-services 210. The configuration center 220 can provide configuration parameters, timeout time and other data for each micro-service 210, so that the micro-service can perform corresponding operations.
[0067] The micro-service 210 belongs to a distributed micro-service, which is used to, after receiving a communication request, execute a corresponding calculation task based on the communication request, detect whether the calculation task is timed out in the process of executing the calculation task, and directly send a failure instruction to the client when it is determined that the calculation task is timed out.
[0068] The communication request is used to implement the interaction and cooperation between microservices. In the embodiments of the present application, the communication request can include a communication carrier, and the communication carrier can record (or carry) multiple time data. The communication request can be a hypertext transfer protocol (HTTP) request, a remote procedure call (RPC) request, or other communication protocol requests. For example, the communication request is an HTTP request, and the communication carrier is a request header of the HTTP request, which can record (or carry) multiple time data.
[0069] The microservice 210 can divide multiple aspects according to specific requirements and business logic. For example, the microservice 210 can determine cross cutting concerns such as receiving data, log recording, performance monitoring, security control, sending data, and the like. The microservice 210 can identify various cross cutting concerns and define aspects based on the cross cutting concerns. Each aspect corresponds to a cross cutting concern and includes the logic corresponding to the cross cutting concern. For example, the cross cutting concern of “receiving data” can be defined as a “receiving aspect”, the cross cutting concern of “security control” can be defined as a “security aspect”, and the cross cutting concern of “sending data” can be defined as a “sending aspect”.
[0070] The receiving aspect can analyze the communication request to obtain the communication carrier, instructions, and other information of the communication request after receiving the communication request. The sending aspect can receive the calculation results of other aspects completing the calculation task corresponding to the communication request, the time recorded by the communication carrier, and other information, add the received information to the original communication carrier, and then send the communication request. Between the receiving aspect and the sending aspect, there are various other aspects for processing the calculation task corresponding to the communication request, performance detection, authentication or authorization, and the like.
[0071] The microservice 210 can perform non-invasive code enhancement on the aspects in each stage of service calling through the java agent self-decoding enhancement technology to implement the timeout detection service inside the microservice 210. In the embodiments of the present application, the java agent can be connected with the receiving aspect to obtain the communication carrier in the communication request. The java agent can be connected with the sending aspect to send the communication carrier to the sending aspect to update the communication carrier of the communication request.
[0072] The microservice 210 can call a program such as a java agent to implement various functions such as time management, performance monitoring, log enhancement, error tracking, security audit, and the like. In the embodiments of the present application, the microservice 210 can utilize the java agent to control the time decrement mechanism of the microservice 210, and acquire the sending communication request time, the remaining time, and the microservice execution time of the communication carrier record from the communication request in a non-intrusive manner, and then detect whether the remaining time carried by the communication carrier is less than the communication time of receiving the communication request and the time of executing the calculation task corresponding to the communication request by the microservice, so as to realize that the microservice 210 can independently detect whether the calculation task corresponding to the communication request executed by the microservice 210 is timed out. The microservice 210 can record the sending communication request time, the remaining time, and the microservice execution time of the communication carrier in the communication carrier in the communication request by using the non-intrusive time management device, so that the time data can be transmitted with the communication request in the microservice in different microservice architectures, thereby realizing the transmission of the communication request between the microservices in different architectures, and still enabling each microservice to detect whether the communication request is timed out.
[0073] Exemplarily, FIG. 3 is a structural schematic diagram of a time management device provided in the embodiments of the present application. As shown in FIG. 3, the time management device 300 can include a first processing unit 310, a second processing unit 320, and a storage unit 330.
[0074] The first processing unit 310 and the second processing unit 320 can be implemented by software or by hardware. Exemplarily, the implementation of the first processing unit 310 is described below. Similarly, the implementation of the second processing unit 320 can refer to the implementation of the first processing unit 310.
[0075] As an example of a software function unit, the first processing unit 310 can include code running on a computing instance. The computing instance can include at least one of a physical host (computing device), a virtual machine, and a container. Further, the computing instance can be one or more. For example, the first processing unit 310 can include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers for running the code can be distributed in the same region, or can be distributed in different regions. Further, the multiple hosts / virtual machines / containers for running the code can be distributed in the same availability zone (AZ), or can be distributed in different AZs, and each AZ includes one data center or multiple data centers with similar geographical locations. Generally, one region can include multiple AZs.
[0076] Likewise, the plurality of hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Among them, usually one VPC is set in one region, and communication between two VPCs in the same region and between VPCs in different regions needs to set a communication gateway in each VPC to realize the interconnection between VPCs through the communication gateway.
[0077] As an example of a hardware functional unit, the first processing unit 310 can include at least one computing device, such as a server, etc. Alternatively, the first processing unit 310 can also be a device implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD), etc. Among them, the above-mentioned PLD can be implemented by a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0078] The plurality of computing devices included in the first processing unit 310 can be distributed in the same region or in different regions. The plurality of computing devices included in the first processing unit 310 can be distributed in the same AZ or in different AZs. Likewise, the plurality of computing devices included in the first processing unit 310 can be distributed in the same VPC or in multiple VPCs. Among them, the plurality of computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, and GALs, etc.
[0079] It should be noted that in other embodiments, the first processing unit 310 can be used to execute any step in the time management method, and the second processing unit 320 can be used to execute any step in the time management method. The steps implemented by the first processing unit 310 and the second processing unit 320 can be specified as needed, and the entire function of the time management system can be realized by the first processing unit 310 and the second processing unit 320 respectively implementing different steps in the time management method.
[0080] The first processing unit 310 is configured to obtain the communication carrier from the communication request in a non-intrusive manner to obtain a first timestamp TS0, a first residual time δΤ1, and a first execution time E1 carried by the communication carrier after the receiving aspect receives the communication request.
[0081] The first timestamp TS0 can refer to a time when the client initiates the communication request or a time when the sending aspect of the last microservice sends the communication request.
[0082] The first residual time δΤ1 can refer to a longest time δΤ0 for the communication request to be executed or a residual time after the longest time δΤ0 for the communication request to be executed minus a communication time when each microservice before the current microservice receives the communication request and a time for performing a calculation task related to the communication request. The longest time δΤ0 for the communication request to be executed is generally set by the client automatically or determined by the user according to the type of the communication request, the type of the microservice architecture, the number of microservices to be executed, and the like.
[0083] The first execution time E1 refers to a minimum time for the last microservice to predict a calculation task corresponding to the communication request to be executed by the current microservice. If the client sends the communication request to the first microservice, the first execution time E1 can not be carried in the communication carrier of the communication request or set as E1 = 0. The first execution time E1 is generally determined by the last microservice. For example, the last microservice can obtain calculation times of the current microservice in history for processing the calculation task corresponding to the communication request from the storage unit 330, average the historical calculation times of the current microservice, and take the average calculation time as the predicted calculation time of the current microservice, i.e., the first execution time E1.
[0084] The first processing unit 310 can calculate a communication time T1 when the current microservice receives the communication request according to the first timestamp TS0 and a time TS1 (hereinafter referred to as a second timestamp TS1) of the current time. That is, the communication time T1 = TS1-TS0.
[0085] The first processing unit 310 can calculate a residual time δΤ2 (hereinafter referred to as a second residual time δΤ2) of the current microservice after receiving the communication request according to the first residual time δΤ1 and the communication time T1. That is, the second residual time δΤ2 = δΤ1-T1.
[0086] After obtaining the second residual time δT2, the first processing unit 310 can detect whether the second residual time δT2 is less than the first execution time E1. In one case, the first processing unit 310 determines that the second residual time δT2 is less than the first execution time E1, indicating that the current microservice cannot complete the computing task corresponding to the communication request within the longest time δT0. The reason for this situation can be that the network of the computing device or the computing device cluster running the current microservice has timed out, the processor is relatively busy, etc. At this time, the current microservice can directly send a failure instruction to the client.
[0087] In another case, the first processing unit 310 determines that the second residual time δT2 is greater than or equal to the first execution time E1, indicating that the current microservice can complete the computing task corresponding to the communication request within the longest time δT0. At this time, the first processing unit 310 can record the second residual time δT2 and the second time stamp TS1 in the call context information, and then transmit it to the second processing unit 320. Wherein, the context information refers to the transmission of request information at different aspects.
[0088] When the second processing unit 320 sends the communication request to the sending aspect, it can parse the second residual time δT2 and the second time stamp TS1 from the call context. The second processing unit 320 can calculate the computing time T2 of the current microservice processing the computing task corresponding to the communication request according to the current time TS2 (hereinafter referred to as "third time stamp TS2") and the second time stamp TS1. That is, the computing time T2 = TS2-TS1. Exemplarily, the second processing unit 320 can cache the computing time T2 to the storage unit 330, so that the storage unit 330 can combine the already cached computing time of the current microservice to recalculate the average computing time, and let the recalculated average computing time as the next predicted computing time of the current microservice.
[0089] The second processing unit 320 can calculate the residual time δT3 (hereinafter referred to as "third residual time δT3") of the current microservice after completing the computing task corresponding to the communication request according to the second residual time δT2 and the computing time T2. That is, the third residual time δT3 = δT2-T2.
[0090] The second processing unit 320 can obtain the predicted computing time (hereinafter referred to as "second execution time E2") of the next microservice from the storage unit 330, and obtain the pre-configured residual time (hereinafter referred to as "fourth residual time δT4") from the configuration center 220. The second execution time E2 refers to the average time of the computing time of the next microservice in the history of executing the computing task corresponding to the communication request stored in the storage unit 330.
[0091] The fourth residual time refers to the residual time of the current microservice after performing the computing task corresponding to the communication request recorded in the configuration center 220 or the configuration file. Illustratively, after receiving the longest time δΤ0 sent by the client, the configuration center 220 can locally calculate the residual time of the communication request reaching each microservice. After the second processing unit 320 of the current microservice sends a time request to the configuration center 220, the residual time of the current microservice, i.e., the fourth residual time δΤ4, can be obtained from the configuration center 220.
[0092] After obtaining the third residual time δΤ3 and the fourth residual time δΤ4, the second processing unit 320 can detect the size between the third residual time δΤ3 and the fourth residual time δΤ4. The second processing unit 320 can select the smaller residual time T3 from the two residual times, and then detect whether the smaller time T4 is less than the second execution time E2. By comparing the real residual time and the theoretical residual time and selecting the smaller residual time, the second processing unit 320 can avoid the current microservice executing the computing task corresponding to the communication request exceeding the timeout, and still let the next microservice execute the computing task corresponding to the communication request.
[0093] In one case, the second processing unit 320 determines that the smaller residual time T3 is less than the second execution time E2, indicating that the next microservice cannot complete the computing task corresponding to the communication request within the longest time δΤ0. At this time, the current microservice can directly send a failure instruction to the client.
[0094] In another case, the second processing unit 320 determines that the smaller residual time T3 is greater than or equal to the second execution time E2, indicating that the next microservice can complete the computing task corresponding to the communication request within the longest time δΤ0. At this time, the second processing unit 320 can update the third timestamp TS2 as the time stamp TS0 carried by the communication carrier of the communication request, update the first residual time δΤ1 as the third residual time δΤ3, and update the first execution time E1 as the second execution time E2 when the current microservice sends the communication request to the next microservice. After the second processing unit 310 completes the update of the communication carrier, the sending aspect can be instructed to send the updated communication request to the next microservice.
[0095] In the embodiment of the present application, after the time management apparatus 300 receives the communication request in the slice, the time management apparatus 300 can obtain the time when the client or the last microservice sends the communication request, the remaining execution time and the computing time of the current microservice from the communication carrier of the communication request. The time management apparatus 300 can subtract the computing time of the current microservice receiving the communication request and the computing time of performing the computing task corresponding to the communication request from the remaining execution time. When the time management apparatus 300 determines that the current microservice does not exceed the time limit for performing the computing task corresponding to the communication request, the time management apparatus 300 can update the time when the client or the last microservice sends the communication request to the time when the current microservice sends the communication request, the remaining execution time to the remaining time after the current microservice completes the computing task corresponding to the communication request, and the computing time of the current microservice to the computing time of the next microservice in the communication carrier of the communication request. After the time management apparatus 300 updates the time carried in the communication carrier, the time management apparatus 300 can instruct the microservice to send the communication request to the next microservice, so as to realize the transmission of the communication request between the microservices of different architectures, and still enable the microservice to detect whether the communication request exceeds the time limit.
[0096] It should be understood that the functional modules, functional devices, etc. involved in the above-mentioned time management apparatus 300 can also be realized by software or hardware, and the specific implementation can be determined according to the actual situation, which is not limited here. In addition, the functional modules, functional devices, etc. involved in the above-mentioned time management apparatus 300 can be arranged separately or integrated, which is not limited here.
[0097] The above is the introduction of the time management apparatus 300 provided by the embodiment of the present application. It can be understood that the above-mentioned time management apparatus 300 can be configured on a cloud computing platform, for example, deployed on at least one virtual machine or container instance, so that the cloud computing platform can provide time management services. Of course, the time management apparatus 300 can also be configured on nodes other than the cloud computing platform, for example, can be deployed in at least one data center, or deployed on at least one server, and the specific implementation can be determined according to the actual situation, which is not limited here. Among them, the cloud computing platform can provide a page related to the public cloud service for users to remotely access the public cloud service. In the embodiment, the user can purchase the time management service that the time management apparatus 300 can provide in advance on the cloud computing platform. For the sake of understanding, the interaction mode between the user and the cloud computing platform is described below.
[0098] As shown in FIG. 4, the interaction between the user and the cloud computing platform mainly includes: the user logs in the cloud computing platform 400 through a client (notebook) webpage, selects and purchases a cloud service (i.e., a time management service) related to the time management apparatus 300 in the cloud computing platform 400, and after the purchase, the user can generate the time management apparatus 300 on the cloud computing platform 400 based on the functions provided by the time management service. The cloud computing platform 400 is mainly used to manage the infrastructure running the time management service. For example, the infrastructure of the time management service can include multiple data centers arranged in different regions, and each data center includes multiple servers. The data center can provide basic resources such as computing resources and storage resources for the time management service. Therefore, when the user purchases and uses the time management service, the user mainly pays for the used resources. When the user uses the time management service, the user can input the demand for the time management service through a configuration interface, an application program interface (API), or an interface for interacting with the user provided by the cloud computing platform 400, and the cloud computing platform 400 can generate the time management service matching the user demand according to the demand input by the user (or other software / hardware, etc.).
[0099] In addition, the modules in the time management apparatus 300 can also be partially configured on the cloud side and partially configured on the terminal side, so as to realize the time management service in a terminal-cloud collaborative manner. In addition, the time management apparatus 300 can also be entirely configured on the terminal side, which can be determined according to actual conditions, and is not limited here.
[0100] The above is the introduction of the time management system provided by the embodiments of the present application. Next, based on the above content, the time management method provided by the embodiments of the present application is introduced.
[0101] For example, FIG. 5 shows a flowchart of a time management method provided by an embodiment of the present application. It can be understood that the time management method can be executed by the time management apparatus 300 described above, and the specific implementation process is as follows:
[0102] In step S501, a communication carrier of a first communication request is obtained.
[0103] Specifically, after the receiving aspect of the microservice receives the communication request, the time management apparatus 300 can obtain the communication carrier from the communication request in a non-intrusive manner. The communication carrier carries a first timestamp, a first remaining time, and a first execution time. The first timestamp can refer to the time when the client initiates the communication request, or the time when the sending aspect of the previous microservice (i.e., the second microservice) sends the communication request. The first remaining time can refer to the longest time for which the communication request is executed, or the remaining time after the longest time for which the communication request is executed is subtracted from the communication time at which each microservice before the current microservice receives the communication request and the time for which the computing task related to the communication request is executed. The first execution time refers to the minimum time predicted by the previous microservice for the current microservice to execute the computing task corresponding to the communication request. If the client sends the communication request to the first microservice, the first execution time can not be carried in the communication carrier of the communication request, or the first execution time can be set to 0.
[0104] In step S502, whether the first microservice completes the computing task corresponding to the first communication request after the time out is determined according to the first timestamp, the second timestamp, the first remaining time, and the first execution time.
[0105] Specifically, the time management apparatus 300 can calculate the communication time at which the current microservice (i.e., the first microservice) receives the communication request according to the first timestamp and the time of the current time (i.e., the second timestamp). The time management apparatus 300 can calculate the remaining time (i.e., the second remaining time) of the current microservice after receiving the communication request according to the first remaining time and the communication time. After obtaining the second remaining time, the time management apparatus 300 can detect whether the second remaining time is less than the first execution time. In one case, the time management apparatus 300 determines that the second remaining time is less than the first execution time, indicating that the current microservice cannot complete the execution of the computing task corresponding to the communication request within the longest time. The reason for this situation can be that the network of the computing device or the computing device cluster running the current microservice has a time out, the processor is relatively busy, etc. At this time, the current microservice can directly send a failure instruction to the client.
[0106] In another case, the time management apparatus 300 determines that the second remaining time is greater than or equal to the first execution time, indicating that the current microservice can complete the execution of the computing task corresponding to the communication request within the longest time. At this time, the time management apparatus 300 can record the second remaining time and the second timestamp in the call context information, and then transmit it to the time management apparatus 300.
[0107] The time management apparatus 300 can parse the second residual time and the second timestamp from the invocation context when the current microservice sending aspect is going to send the communication request. The time management apparatus 300 can calculate the computation time of the current microservice for processing the computation task corresponding to the communication request according to the current time (i.e., the third timestamp) and the second timestamp. The time management apparatus 300 can calculate the residual time of the current microservice after completing the computation task corresponding to the communication request (i.e., the third residual time) according to the second residual time and the computation time.
[0108] The time management apparatus 300 can obtain the predicted computation time (i.e., the second execution time) of the next microservice (i.e., the third microservice) from the local cache, and obtain the pre-configured residual time (i.e., the fourth residual time) of the next microservice from the configuration center to which the next microservice belongs. The second execution time refers to the average computation time of the next microservice in the history for executing the computation task corresponding to the communication request. The fourth residual time refers to the residual time of the current microservice after completing the computation task corresponding to the communication request recorded in the configuration center or the configuration file.
[0109] After obtaining the third residual time and the fourth residual time, the time management apparatus 300 can detect the size between the third residual time and the fourth residual time. The time management apparatus 300 can select the smaller residual time from the two residual times, and then detect whether the smaller residual time is less than the second execution time. The time management apparatus 300 can avoid the next microservice executing the computation task corresponding to the communication request after the current microservice executing the computation task corresponding to the communication request exceeds the timeout by comparing the real residual time with the theoretical residual time and selecting the smaller residual time. In one case, the time management apparatus 300 determines that the smaller residual time is less than the second execution time, which means that the next microservice cannot complete the computation task corresponding to the communication request within the longest time. At this time, the current microservice can directly send a failure instruction to the client.
[0110] In another case, the time management apparatus 300 determines that the smaller residual time is greater than or equal to the second execution time, which means that the next microservice can complete the computation task corresponding to the communication request within the longest time. At this time, the second processing unit can update the timestamp of initiating the communication request carried by the communication carrier of the communication request to the third timestamp, update the first residual time to the third residual time, and update the first execution time to the second execution time when the current microservice sends the communication request to the next microservice. After the time management apparatus 300 completes the update of the communication carrier, the time management apparatus 300 can instruct the sending aspect to send the updated communication request (i.e., the second communication request) to the next microservice.
[0111] In the embodiment of the present application, the time management device 300 can obtain the sending time of the communication request, the remaining time and the execution time of the microservice of the communication carrier record from the communication request in a non-intrusive manner, and then detect whether the remaining time carried by the communication carrier is less than the communication time of receiving the communication request and the time of executing the calculation task corresponding to the communication request by the microservice itself, so that each microservice can independently detect whether the calculation task corresponding to the communication request is timed out.
[0112] The time management device 300 can record the sending time of the communication request, the remaining time and the execution time of the microservice in the communication carrier in the communication request by using the non-intrusive time management device, so that the time data can be transmitted with the communication request in the microservice in different microservice architectures, thereby realizing the transmission of the communication request between the microservices in different architectures, and still enabling each microservice to detect whether the communication request is timed out.
[0113] The time management device provided in the embodiment of the present application can be divided into a plurality of units according to the execution function, which can be the units of the time management device 300 shown in FIG. 3, such as the first processing unit 310 and the second processing unit 320. The specific implementation process of the time management device is as follows:
[0114] The first processing unit 310 is configured to obtain a communication carrier of a first communication request. The communication carrier includes a first timestamp, a first remaining time and a first execution time. The first timestamp is the sending time of the first communication request. The first remaining time is determined according to the total execution time set by the first communication request. The first execution time is the predicted time of the first microservice processing the calculation task corresponding to the first communication request. The first processing unit 310 is further configured to determine whether the first microservice is timed out after completing the calculation task corresponding to the first communication request according to the first timestamp, a second timestamp, the first remaining time and the first execution time. The second timestamp is the time when the first microservice receives the first communication request.
[0115] In one embodiment, the first processing unit 310, before obtaining the communication carrier of the first communication request, is further configured to receive the first communication request sent by the client or the second microservice. The plurality of microservices further include a second microservice, and the first microservice and the second microservice belong to the microservices in at least one microservice architecture.
[0116] In one embodiment, the first processing unit 310 is specifically configured to detect whether the communication time of the first communication request is timed out based on the first timestamp, the second timestamp and the first remaining time. The first processing unit 310 is specifically configured to, in the case that the communication time of the first communication request is not timed out, determine whether the first microservice is timed out after completing the calculation task corresponding to the first communication request based on the first remaining time, the communication time of the first communication request and the first execution time.
[0117] In an embodiment, the first processing unit 310 is specifically configured to obtain the communication time of the first communication request according to the difference between the first timestamp and the second timestamp. The first processing unit 310 is specifically configured to obtain the second remaining time according to the difference between the first remaining time and the communication time of the first communication request. The first processing unit 310 is specifically configured to detect whether the second remaining time is less than 0, and determine that the communication time of the first communication request is not overdue when the second remaining time is greater than or equal to 0.
[0118] In an embodiment, the first processing unit 310 is specifically configured to detect whether the second remaining time is less than the first execution time. The first processing unit 310 is specifically configured to determine that the first microservice does not exceed the time after completing the computing task corresponding to the first communication request when the second remaining time is greater than or equal to the first execution time.
[0119] In an embodiment, the second processing unit 320 is configured to obtain a third timestamp. The third timestamp is the time after the first microservice completes the computing task corresponding to the first communication request. The second processing unit 320 is also configured to obtain the computing time of the first microservice according to the second timestamp and the third timestamp. The computing time of the first microservice is the time for the first microservice to complete the computing task corresponding to the first communication request. The second processing unit 320 is also configured to obtain a third remaining time according to the second remaining time and the second execution time. The third remaining time is the time for other microservices after the first microservice to execute the computing task corresponding to the first communication request.
[0120] In an embodiment, the second processing unit 320 is also configured to obtain a fourth remaining time. The fourth remaining time is the remaining time recorded in the configuration center or the configuration file after the first microservice executes the computing task corresponding to the first communication request. The second processing unit 320 is also configured to select the remaining time with shorter time from the third remaining time and the fourth remaining time, and determine whether the third microservice exceeds the time after completing the computing task corresponding to the first communication request according to the selected remaining time and the second execution time. The second execution time is the computing time of the third microservice, and the plurality of microservices includes the third microservice, which is the microservice receiving the first microservice forwarding the first communication request.
[0121] In an embodiment, the second processing unit 320 is also configured to obtain the communication carrier of the second communication request according to the third timestamp, the third remaining time and the second execution time when the third microservice does not exceed the time after completing the computing task corresponding to the communication request. The communication carrier of the second communication request includes the third timestamp, the third remaining time and the second execution time. The second processing unit 320 is also configured to send the second communication request to the third microservice.
[0122] FIG. 6 is a structural schematic diagram of a computing device provided in an embodiment of the present application. As shown in FIG. 6, the computing device 600 includes a bus 610, a processor 620, a memory 630, and a communication interface 640. The processor 620, the memory 630, and the communication interface 640 communicate through the bus 610. The computing device 600 can be a server, a computer, a portable notebook, a cabinet, etc. It should be understood that the number of processors and memories in the computing device 600 is not limited in the present application.
[0123] The bus 610 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one line is shown in FIG. 6, but it does not mean that there is only one bus or one type of bus. The bus 610 can include a path for transmitting information between various components (e.g., the processor 620, the memory 630, the communication interface 640) of the computing device 600.
[0124] The processor 620 can be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP), etc.
[0125] The memory 630 can include a volatile memory (e.g., a random access memory (RAM)) and can also include a non-volatile memory (e.g., a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD)).
[0126] The memory 630 stores executable program codes, and the processor 620 executes the executable program codes to respectively implement the functions of the aforementioned multiple modules, such as the functions of the first processing unit 310 and the second processing unit 320, etc., so as to implement the time management method. That is, the memory 630 stores instructions for executing the time management method.
[0127] Alternatively, the memory 630 stores executable code that the processor 620 executes to implement the functionality of the aforementioned modules to implement the time management method. That is, the memory 630 stores instructions for implementing the time management method.
[0128] The communication interface 640 uses a transceiving module such as, but not limited to, a network interface card, a transceiver, to enable communication between the computing device 600 and other devices or communication networks.
[0129] Embodiments of the present disclosure also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0130] As shown in FIG. 7, the computing device cluster includes at least one computing device 600. The memory 630 in one or more computing devices 600 in the computing device cluster can store the same instructions for implementing the time management method.
[0131] In some possible implementations, the memory 630 in one or more computing devices 600 in the computing device cluster can also respectively store partial instructions for implementing the time management method. In other words, the combination of one or more computing devices 100 can collectively execute the instructions for implementing the time management method.
[0132] It should be noted that the memory 630 in different computing devices 600 in the computing device cluster can store different instructions for respectively implementing part of the functionality of the first processing unit 310 and the second processing unit 320. That is, the instructions stored in the memory 630 in different computing devices 600 can implement the functionality of one or more modules in the first processing unit 310 and the second processing unit 320.
[0133] In some possible implementation, one or more of the computing devices in the cluster of computing devices can be connected through a network. In some possible implementation, the network can be a wide area network, a local area network, or the like. FIG. 8 illustrates one possible implementation. As shown in FIG. 8, two computing devices, computing device 600A and computing device 600B, are connected through a network. Specifically, the computing devices are connected to the network through a communication interface in each of the computing devices. In this type of possible implementation, the memory 630 in the computing device 600A stores instructions for performing the functions of some of the modules in the first processing unit 310 and the second processing unit 320 described above. Meanwhile, the memory 630 in the computing device 600B stores instructions for performing the functions of another set of modules in the first processing unit 310 and the second processing unit 320 described above.
[0134] The connection between the computing devices in the cluster of computing devices shown in FIG. 8 can be such that, given the need for a large amount of data storage in the time management method provided in the present application, the functions performed by another set of modules in the first processing unit 310 and the second processing unit 320 are implemented by the computing device 600B.
[0135] It should be understood that the functions of the computing device 600A shown in FIG. 8 can also be performed by multiple computing devices 600. Similarly, the functions of the computing device 600B can also be performed by multiple computing devices 600.
[0136] The present application also provides another cluster of computing devices. The connection between the computing devices in the cluster of computing devices can be similar to the connection between the computing devices in the cluster of computing devices described above with reference to FIG. 6 and FIG. 7. The difference is that the memory 630 in one or more of the computing devices 600 in the cluster of computing devices can store the same instructions for performing the time management method.
[0137] In some possible implementation, the memory 630 in one or more of the computing devices 600 in the cluster of computing devices can also store different instructions for performing the time management method. In other words, the combination of one or more of the computing devices 600 can collectively perform the instructions for performing the time management method.
[0138] It should be noted that the memory 630 in different computing devices 600 in the cluster of computing devices can store different instructions for performing some of the functions of the computing devices 600. That is, the instructions stored in the memory 630 in different computing devices 600 can implement the functions of one or more modules in the first processing unit 310 and the second processing unit 320 described above.
[0139] The embodiments of the present application further provide a computer program product containing instructions. The computer program product can be software or program product containing instructions, which can run on a computing device or be stored in any available medium. When the computer program product runs on at least one computing device, the at least one computing device is caused to perform the time management method.
[0140] The embodiments of the present application further provide a computer readable storage medium. The computer readable storage medium can be any available medium that the computing device can store or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk), etc. The computer readable storage medium contains instructions, which instruct the computing device to perform the time management method.
[0141] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A time management method characterized by, The micro-service system includes a plurality of micro-services, including a first micro-service, the method is executed by the first micro-service, and the method includes: obtaining a communication carrier of a first communication request; the communication carrier includes a first timestamp, a first remaining time and a first execution time; the first timestamp is the sending time of the first communication request; the first remaining time is determined according to the total execution time set by the first communication request; and the first execution time is the predicted time of the first micro-service processing a calculation task corresponding to the first communication request; determining whether the first micro-service is timed out after completing the calculation task corresponding to the first communication request according to the first timestamp, a second timestamp, the first remaining time and the first execution time; the second timestamp is the time when the first micro-service receives the first communication request.
2. The method of claim 1, wherein, Before the communication carrier of the first communication request is obtained, the method further includes: receiving the first communication request sent by a client or a second micro-service; the plurality of micro-services further include the second micro-service, and the first micro-service and the second micro-service belong to micro-services in at least one micro-service architecture.
3. The method according to claim 1 or 2, characterized in that, The determination of whether the first micro-service is timed out after completing the calculation task corresponding to the first communication request according to the first timestamp, the second timestamp, the first remaining time and the first execution time specifically includes: detecting whether the communication time of the first communication request is timed out based on the first timestamp, the second timestamp and the first remaining time; in the case that the communication time of the first communication request is not timed out, determining whether the first micro-service is timed out after completing the calculation task corresponding to the first communication request based on the first remaining time, the communication time of the first communication request and the first execution time.
4. The method of claim 3, wherein, The detection of whether the communication time of the first communication request is timed out based on the first timestamp, the second timestamp and the first remaining time specifically includes: obtaining the communication time of the first communication request according to the difference between the first timestamp and the second timestamp; obtaining a second remaining time according to the difference between the first remaining time and the communication time of the first communication request; detecting whether the second remaining time is less than 0, and determining that the communication time of the first communication request is not timed out when the second remaining time is greater than or equal to 0.
5. The method according to claim 3 or 4, characterized in that, The determination of whether the first micro-service is timed out after completing the calculation task corresponding to the first communication request based on the first remaining time, the communication time of the first communication request and the first execution time specifically includes: detecting whether the second remaining time is less than the first execution time; in the case that the second remaining time is greater than or equal to the first execution time, determining that the first micro-service is not timed out after completing the calculation task corresponding to the first communication request.
6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: obtaining a third timestamp; the third timestamp is the time after the first micro-service completes the calculation task corresponding to the first communication request; obtaining a calculation time of the first microservice according to the second timestamp and the third timestamp; the calculation time of the first microservice is a time for the first microservice to complete a calculation task corresponding to the first communication request; obtaining a third residual time according to the second residual time and the second execution time; the third residual time is a time for other microservices after the first microservice to execute the calculation task corresponding to the first communication request.
7. The method according to any one of claims 1 to 6, characterized in that, The method further comprises: obtaining a fourth residual time; the fourth residual time is a residual time recorded in a configuration center or a configuration file after the first microservice executes the calculation task corresponding to the first communication request; selecting a residual time with a shorter time from the third residual time and the fourth residual time, and determining whether the third microservice is timed out after completing the calculation task corresponding to the first communication request according to the selected residual time and the second execution time; the second execution time is a calculation time of the third microservice, the plurality of microservices include the third microservice, and the third microservice is a microservice receiving the first communication request forwarded by the first microservice.
8. The method of claim 7, wherein, The method further comprises: in a case that the third microservice is not timed out after completing the calculation task corresponding to the communication request, obtaining a communication carrier of a second communication request according to the third timestamp, the third residual time and the second execution time; the communication carrier of the second communication request includes the third timestamp, the third residual time and the second execution time; sending the second communication request to the third microservice.
9. A time management apparatus, characterized by comprising: comprises: a first processing unit, configured to obtain a communication carrier of a first communication request; the communication carrier includes a first timestamp, a first residual time and a first execution time; the first timestamp is a sending time of the first communication request; the first residual time is determined according to a total execution time set by the first communication request; and the first execution time is a predicted time for the first microservice to process a calculation task corresponding to the first communication request; determining whether the first microservice is timed out after completing the calculation task corresponding to the first communication request according to the first timestamp, a second timestamp, the first residual time and the first execution time; the second timestamp is a time for the first microservice to receive the first communication request.
10. The apparatus of claim 9, wherein before the first processing unit obtains the communication carrier of the first communication request, the first processing unit is further configured to receive the first communication request sent by a client or a second microservice; the plurality of microservices further include the second microservice, and the first microservice and the second microservice belong to microservices in at least one microservice architecture.
11. The apparatus of claim 9 or 10, wherein the first processing unit is specifically configured to detect whether a communication time of the first communication request is timed out based on the first timestamp, the second timestamp and the first residual time. In a case where the communication time of the first communication request does not expire, it is determined whether the first microservice is overtime after completing the computing task corresponding to the first communication request based on the first residual time, the communication time of the first communication request, and the first execution time.
12. The apparatus of claim 11, wherein, the first processing unit is specifically configured to obtain the communication time of the first communication request according to a difference between the first timestamp and the second timestamp; obtain a second residual time according to a difference between the first residual time and the communication time of the first communication request; determine that the communication time of the first communication request does not expire in a case where the second residual time is greater than or equal to 0.
13. The apparatus of claim 11 or 12, wherein, the first processing unit is specifically configured to determine whether the second residual time is less than the first execution time; determine that the first microservice is not overtime after completing the computing task corresponding to the first communication request in a case where the second residual time is greater than or equal to the first execution time.
14. The apparatus of any one of claims 1-5, wherein, the apparatus further comprises a second processing unit, the second processing unit is configured to obtain a third timestamp; the third timestamp is a time after the first microservice completes the computing task corresponding to the first communication request; obtain a computing time of the first microservice according to the second timestamp and the third timestamp; the computing time of the first microservice is a time for the first microservice to complete the computing task corresponding to the first communication request; obtain a third residual time according to the second residual time and a second execution time; the third residual time is a time for other microservices after the first microservice to execute the computing task corresponding to the first communication request.
15. The apparatus of any of claims 9-14, wherein, the second processing unit is further configured to obtain a fourth residual time; the fourth residual time is a residual time recorded in a configuration center or a configuration file after the first microservice executes the computing task corresponding to the first communication request; select a residual time with a shorter time from the third residual time and the fourth residual time, and determine whether the third microservice is overtime after completing the computing task corresponding to the first communication request according to the selected residual time and the second execution time; the second execution time is a computing time of the third microservice, the plurality of microservices include the third microservice, and the third microservice is a microservice that receives the first communication request forwarded by the first microservice.
16. The apparatus of claim 15, wherein, the second processing unit is further configured to obtain a communication carrier of a second communication request according to the third timestamp, the third residual time, and the second execution time in a case where the third microservice is not overtime after completing the computing task corresponding to the communication request; the communication carrier of the second communication request includes the third timestamp, the third residual time, and the second execution time. sending the second communication request to the third microservice.
17. A microservice system, characterized in that, comprising: a plurality of microservices belonging to microservices in at least one microservice architecture; any one of the plurality of microservices performing the method of any one of claims 1-8.
18. A cluster of computing devices comprising at least one computing device, each computing device comprising a processor and a memory; the processor of the at least one computing device being configured to execute instructions stored in the memory to cause the cluster of computing devices to perform the method of any one of claims 1-8.
19. A computer-readable storage medium, characterized in that, comprising computer program instructions which, when executed by a cluster of computing devices, cause the cluster of computing devices to perform the method of any one of claims 1-8.
20. A computer program product comprising instructions, characterized in that, the computer program product storing instructions which, when executed by a cluster of computing devices, cause the cluster of computing devices to implement the method of any one of claims 1-8.
Citation Information
Patent Citations
Service timeout management method and device
CN113783822A
Timeout control method and device, electronic equipment, storage medium and program product
CN114510363A
Call request processing method and device and electronic equipment
CN115016942A
Business system parameter configuration method and device and micro-service execution method and device
CN115118769A
Service timeout control method and device, micro-service system and storage medium
CN116170519A