Micro-service application execution delay optimization method based on REST API execution chain

By constructing and updating the service call chain and execution chain, reducing the number of redirects of the API gateway and directly accessing microservice instances, solving the problem of increasing network delay in microservice applications and improving response speed and efficiency.

CN119135776AActive Publication Date: 2024-12-13INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411166534.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-13
Estimated Expiration
2044-08-23

AI Technical Summary

Technical Problem

When microservice applications respond to external requests, they need to redirect multiple times through the API gateway, resulting in an increase in network communication delay, which seriously affects execution performance.

Method used

Through the microservice monitoring module, the service call chain and the service execution chain are constructed. When the API gateway receives the service request, the execution chain will be written to the header information and update the execution chain according to the update strategy to reduce the number of times the service calls pass through the gateway. Direct access to the microservice instance.

Benefits of technology

It effectively reduces the additional communication delay introduced by the API gateway, improves the response rate and overall efficiency of microservice applications, and significantly improves the service response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135776A_ABST
    Figure CN119135776A_ABST
Patent Text Reader

Abstract

The invention discloses a micro-service application execution time delay optimization method based on an REST API execution chain, and the method comprises the steps: 1) collecting a historical execution track of a service request response of a micro-service through a micro-service monitoring module, and constructing a service call chain of the micro-service according to the historical execution track data; the service calling chain is a service response link in the micro-service cluster corresponding to the service request of the micro-service; 2) the API gateway constructs a service execution chain of the micro service; the service execution chain responds to a service forwarding flow corresponding to the service request; 3) when the API gateway receives a service request sent by the micro-service, the API gateway writes the service execution chain into header information of an external request to be responded, and then sends the service execution chain to a corresponding micro-service instance; and 4) the API gateway updates the service execution chain according to a set updating strategy. According to the invention, the overall response rate of the micro-service application system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an execution delay optimization method for microservice architecture applications, and in particular to an execution delay optimization method for microservice applications based on a REST API execution chain, and belongs to the field of computer software. Background Art

[0002] Microservices is a software architecture pattern that divides a single application into a group of small services. The services coordinate and cooperate with each other, and use lightweight communication mechanisms to collaborate with each other (usually REST API based on HTTP protocol). Each service is built around a specific business and can be independently deployed to a production environment. Microservices not only represent a new architectural pattern, but also a new organizational pattern. Therefore, when a microservice application responds to an external request, multiple services will cooperate to respond to the external request. Currently, the internal service call of the application needs to be implemented with the assistance of the gateway. The service gateway is a key component in the microservice architecture, acting as the entry point of the entire system, responsible for processing internal and external requests and routing them to the corresponding microservice instances.

[0003] With the rise of REST API, API gateways have gradually developed into more complex and feature-rich components. REST API provides a simple, lightweight, and easy-to-understand communication protocol, making integration between different systems more flexible and simple. API gateways have begun to support REST API routing, authentication, authorization and other functions.

[0004] However, the introduction of the API gateway also brings additional network overhead. Both external service calls and internal service calls need to go through the gateway's redirection operation to access the target microservice instance, which increases the network communication delay overhead and seriously affects the execution performance of the microservice application. Summary of the invention

[0005] In view of the technical problems existing in the prior art, the purpose of the present invention is to provide a method for optimizing the execution delay of a microservice application based on the REST API execution chain, which reduces the number of times a service call passes through the API gateway and thus reduces the additional communication delay caused by the introduction of the API gateway, thereby achieving faster service response and improving the overall response rate of the microservice application system.

[0006] The technical solution of the present invention is:

[0007] A method for optimizing execution delay of a microservice application based on a REST API execution chain, comprising the following steps:

[0008] 1) The microservice monitoring module collects the historical execution traces of the service request responses of the microservice, and constructs the service call chain of the microservice based on the historical execution trace data call ; The service call chain chain call The service response link within the microservice cluster corresponding to the service request of the microservice;

[0009] 2) The API gateway constructs the service execution chain of the microservice exec ; The service execution chain chain exec A service forwarding process corresponding to the service request response;

[0010] 3) When the API gateway receives the service request from the microservice, the API gateway executes the service chain exec Write it into the header information of the external request to be responded to, and then send it to the corresponding microservice instance;

[0011] 4) The API gateway updates the service execution chain according to the set update strategy exec .

[0012] Further, construct the service call chain call The method is:

[0013] 11) The microservice monitoring module monitors the data of the microservice cluster and extracts relevant information about the service request response of the microservice from the acquired monitoring data; the relevant information includes the service request issuer serv send , service request receiver serv rec , service request information req;

[0014] 12) Obtain the service request execution path in the service request information req, and construct each service party in the service request execution path as a request call chain node node serv The service provider includes a service request issuer serv send , service request receiver serv rec ; Then call the chain node node according to the request serv The calling order in the topology structure calls the node of each request chain node serv Sort and generate the service call chain call ; Among them, the request calls the chain node node servThe information is saved in a key'-value' format, where key' includes the name of the service request sender, the service request path, and the service request type, and value' includes the name of the service request receiver and the service receiver version; the service call chain call Stored in the <key, value> data format, where the key includes the unique identification information of the service request and the value is the service call chain call .

[0015] Further, construct the service execution chain exec The method is:

[0016] 21) Chain the service call chain call Split into a group of request call chain nodes node serv , from each request call chain node node serv Parse the service address and map it to an executable microservice instance; generate an execution chain node node according to each executable microservice instance ins , get an execution chain node set set exec The information stored in the executable microservice instance includes the service caller serv send , service receiver serv rec , requested path and method information;

[0017] 22) Follow the service call chain call The calling sequence recorded in the execution chain node node ins Constructed as a service execution chain exec .

[0018] Furthermore, the service request issuing party serv send , the service request receiver serv rec They all contain service identification and service version information; the service request information req contains request path url, request method method and request parameters; the abstract service definition serv includes service identification and service version information.

[0019] Further, construct the request call chain node node corresponding to the service request serv The method comprises: using the identification mark corresponding to the service request to classify the monitoring data, obtaining the monitoring data corresponding to the service request and parsing the service request issuing party serv send , service request receiver serv rec The service request information req is encapsulated into the request call chain node corresponding to the service request.

[0020] Furthermore, the unique identification information of the service request is the service identifier, the request parameters included in the service request information req, and a hash value of the service request information req.

[0021] Furthermore, the specific implementation method of step 3) is:

[0022] 31) When the API gateway receives the service request q issued by the microservice, it determines that the service request q is in the service execution chain chain exec The corresponding execution chain node node ins And parse the preset microservice instance address;

[0023] 32) intercept the service request q, and determine whether the path and method information in the service request q is consistent with the execution chain node node determined in step 31) ins The information corresponds; if it corresponds, the execution chain node node determined in step 31) is used ins The information rewrites the address in the service request q, and modifies the service identification information in the url in the service request q to the execution chain node node ins The microservice instance address in generates a new service request;

[0024] 33) Add a modification mark to the new service request modified , used to distinguish it from the service request q to prevent the service request q from being modified repeatedly; then the request response information of the new service request is returned as the response information of the service request q.

[0025] Furthermore, the update strategy is: scheduled update every five minutes, update if used 200 times within one minute, update if used 500 times within 10 seconds, update if used 1000 times within one second, or single update without caching.

[0026] The technical solution process of the present invention is as follows Figure 1 As shown, it specifically includes the following steps:

[0027] 1. The microservice monitoring module collects the historical execution traces of the service request responses of the microservices, and constructs the service call chain based on the historical execution trace data, such as Figure 3 As shown, the service call chain call It is the service response link within the cluster corresponding to the service request. The specific steps are as follows:

[0028] 1) If Figure 2 As shown, the microservice cluster system is monitored to obtain relevant information about the service request response. The relevant information includes the service request issuer serv send, service request receiver serv rec , service request information req, where the service request issuer serv send That is, the service request issuing node and the service request receiving node serv rec That is, the service request receiving node contains the service identification and service version information of the microservice; the service request information req contains the request path url, request method method and request parameters.

[0029] 2) Construct the request call chain node corresponding to the service request based on the historical execution trajectory data serv , node serv The abstract service definition serv is stored in the , which refers to the general information such as service identification and service version, and does not contain specific information such as the deployment address, port, and health status of the service. The construction of the request call chain node requires parsing the monitoring data. The monitoring data is classified by using the identification mark corresponding to the service request to obtain the monitoring data corresponding to the service request, and the serv mentioned in step 1) is parsed from the monitoring data. send 、serv rec and req, and encapsulates all the parsed data into the request call chain node. Then, the request call chain nodes are sorted according to the topological structure of the service call, where the topological structure describes the call relationship between services, including the dependency of the services, the connection between the caller and the callee, the path of the call chain, etc. The present invention sorts the request call chain nodes according to the calling order of the encapsulated request call chain nodes in the topological structure.

[0030] 3) For the request information req, the service request execution path serv within the cluster A →serv B →serv C , each service party in the service request path during the service call process is used as the request call chain node in the call chain serv , the request call chain node is the service party that calls the execution in the service request execution path. serv This information is stored in a key-value format, where the key is the service request sender name + service request path + service request type, and the value is the storage service request receiver name + service receiver version; send Includes the name of the service request sender, serv rec Includes the recipient name + version, req includes the service request path + service request type serv send , req as key information, serv rec As value.

[0031] 4) Write relevant information into the service call chain call , the call chain is composed of It is stored in the system in the format of <key, value>. The key is the unique identification information of the service request identified by the service request information req. The unique identification information is represented by the hash value calculated by the service identifier, the request parameters contained in the service request information req, and the service request information req. The value is the service call chain chain. call . Service call chain call Start constructing when the service request response arrives at the API gateway. If there is a service call chain for the current service request, call , it is necessary to analyze the validity of the call chain. If the call chain is within the valid time and no new execution track appears corresponding to the service request, the construction of the service call chain will not be repeated.

[0032] 2.API Gateway constructs service execution chain exec , service execution chain exec Refers to the complete service forwarding process corresponding to the service request response obtained in advance during the service scheduling process. For the external request to be responded to, the API gateway obtains the service call chain obtained in step 1 by comparing the method, path, parameters and other information of the external request with the req information saved in the call chain. call Information. Call chain for the obtained service call Do node parsing.

[0033] 1) Split the service call chain call For a group of individual call nodes serv , for each calling node serv Perform concurrent parsing calculations to obtain the actual service address and improve the parsing rate of the call node. There is a one-to-one correspondence between the execution chain node and the call chain node. The execution chain node is generated by parsing the call chain node and mapping it to a real microservice instance. The real microservice instance refers to a real executable microservice instance containing specific information such as the service deployment address ip, port port, and health status healthy. The service call chain is split to obtain a call node set

[0034] 2) Perform a mapping operation on the nodes in the call node set to the real microservice instance to obtain the execution chain node set The call node stores the abstract definition of the service serv, performs real service mapping on the abstract definition, implements instantiation mapping, and obtains the physical real instance information of the microservice. Use the instance information and the corresponding service request information to execute the real service instance node of the execution chain ins The information stored in the real service instance includes the service caller serv send , service receiver serv rec , the requested path and method information. The service receiver here is different from the service receiver information stored in the call chain node. It is the address information of the specific real microservice instance.

[0035] 3) Set the real microservice instance node ins According to the service call chain call The calling sequence recorded in constructs the service execution chain chain exec To ensure the accuracy of the topology construction of the execution chain nodes. The accurately constructed execution chain is

[0036] 3. When the service request sent by the microservice reaches the API gateway, the API gateway executes the service chain obtained in step 2 exec Write it into the header information of the external request to be responded, and then send the processed external request to be responded to the corresponding microservice instance, triggering the subsequent execution path and participating in the overall service response process. Through the Agent method, the application process of the execution chain is realized by intercepting and rewriting the service request to the service during the response process, such as Figure 4 The specific application process is as follows:

[0037] 1) Determine whether the service request currently sent by the microservice is in the service execution chain exec The location in which the service is located is to obtain the execution chain node corresponding to the service. ins , and parse the execution chain node node ins The preset microservice instance information (i.e., microservice instance address) includes instance IP and port information.

[0038] 2) Intercept the service request through the Agent method, that is, intercept the execution function exec() in the service request sending framework, and determine whether the path and method information in the current service request corresponds to the execution chain node node insInformation, if it corresponds, use the execution chain node information to rewrite the request address. Rewriting the request address requires modifying the service identification information in the corresponding URL in the service request to the real microservice instance address. For example, the URL in the original service request is declared as service.com / service / api, and the modified URL is declared as ip:port / service / api.

[0039] 3) Modify the request address in the service request information and add a modification mark in the new request modified Differentiate from the original service request information to prevent the request from being modified repeatedly. Return the obtained request response information as the response information of the original service request, and finally realize the accelerated service response.

[0040] 4. The gateway updates the service execution chain information through the update strategy to reduce the request response errors caused by the service online and offline, and ensure the correctness of the overall service response. The update strategy is as follows:

[0041] 1) Update every five minutes.

[0042] 2) It will be updated if it is used 200 times within 1 minute.

[0043] 3) Updated if used 500 times within 10 seconds.

[0044] 4) Updated if used 1000 times within 1 second

[0045] 5) No caching, single update. This strategy is used when real-time requirements are high.

[0046] The positive effects of the present invention are:

[0047] The method of the present invention can effectively improve the service response speed. For a microservice system with a large number of microservice application internal service calls, the present invention can significantly improve the overall speed of microservice response, thereby improving the efficiency of microservice applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A technical solution diagram for applying a service response acceleration method based on historical trajectories.

[0049] Figure 2 Diagram of the technical method for monitoring and grouping historical execution data.

[0050] Figure 3 Construct a technical approach diagram for the REST API call chain.

[0051] Figure 4 This is a technical solution diagram for the execution chain application. DETAILED DESCRIPTION

[0052] The present invention is further described below with reference to the accompanying drawings and examples.

[0053] Taking the current main open source microservice system, the railway ticket booking system TrainTicket, as an example, it includes 41 business logic-related positioning services such as ticket inquiry, reservation, payment, change and user notification.

[0054] This method first collects and stores the call relationship between microservice system services. For example, the / api / getAllOrders method of the microservice ts-admin-order-service in the TrainTicket system calls the / api / findAllOrder method in the microservice ts-order-service. At this time, we will record the call chain call ={ts-admin-order-service: / api / getAllOrders:GET→ts-order-service: / api / findAllOrder:GET}. The service execution chain is calculated based on the call chain exec ={192.168.12.11:12030: / api / getAllOrders:GET→192.168.12.12:12032: / api / findAllOrder:GET}. Use the method in step 3 to change ts-order-service to 192.168.12.12:12032 in the external request method of ts-admin-order-service, bypassing the microservice gateway for service access and reducing the service delay caused by the gateway.

[0055] The method described in the present invention improves the response speed in the TrainTicket system by 46.20%.

[0056] The above case proves that the method of the present invention can increase the service response speed based on the service response historical trajectory, which has a positive effect on improving the response speed of the overall microservice system.

Claims

1. A method for optimizing execution delay of a microservice application based on a REST API execution chain, the steps comprising: 1) The microservice monitoring module collects the historical execution traces of the service request responses of the microservice, and constructs the service call chain of the microservice based on the historical execution trace data call ; The service call chain call The service response link within the microservice cluster corresponding to the service request of the microservice; 2) The API gateway constructs the service execution chain of the microservice exec ; The service execution chain chain exec A service forwarding process corresponding to the service request response; 3) When the API gateway receives the service request from the microservice, the API gateway executes the service chain exec Write it into the header information of the external request to be responded to, and then send it to the corresponding microservice instance; 4) The API gateway updates the service execution chain according to the set update strategy exec .

2. The method according to claim 1, characterized in that Construct the service call chain call The method is: 11) The microservice monitoring module performs data monitoring on the microservice cluster and extracts relevant information about the service request response of the microservice from the acquired monitoring data; The relevant information includes the service request issuer serv send , service request receiver serv rec , service request information req; 12) Obtain the service request execution path in the service request information req, and construct each service party in the service request execution path as a request call chain node node serv The service provider includes a service request issuer serv send , service request receiver serv rec ; Then call the chain node node according to the request serv The calling order in the topology structure calls the node of each request chain node serv Sort and generate the service call chain call ; Among them, the request calls the chain node node serv The information is stored in a key'-value' format, where key' includes the name of the service request sender, the service request path, and the service request type, and value' includes the name of the service request receiver and the service receiver version; the service call chain call by<key,value> The data format is stored, where the key includes the unique identification information of the service request and the value is the service call chain call .

3. The method according to claim 2, characterized in that Construct the service execution chain exec The method is: 21) Chain the service call chain call Split into a group of request call chain nodes node serv , from each request call chain node node serv Parse the service address and map it to an executable microservice instance; generate an execution chain node node according to each executable microservice instance ins , get an execution chain node set set exec The information stored in the executable microservice instance includes the service caller serv send , service receiver serv rec , requested path and method information; 22) Follow the service call chain call The calling sequence recorded in the execution chain node node ins Constructed as a service execution chain exec .

4. The method according to claim 2, characterized in that: The service request issuer serv send , the service request receiver serv rec Both contain service identification and service version information; the service request information req contains request path url, request method method and request parameters; the abstract service definition serv includes service identification and service version information.

5. The method according to claim 2, characterized in that: Construct the request call chain node corresponding to the service request serv The method comprises: using the identification mark corresponding to the service request to classify the monitoring data, obtaining the monitoring data corresponding to the service request and parsing the service request issuing party serv send , service request receiver serv rec The service request information req is encapsulated into the request call chain node corresponding to the service request.

6. The method according to claim 2, characterized in that The unique identification information of the service request is the service identifier, the request parameters included in the service request information req, and the hash value of the service request information req.

7. The method according to claim 1, 2 or 3, characterized in that: The specific implementation method of step 3) is: 31) When the API gateway receives the service request q issued by the microservice, it determines that the service request q is in the service execution chain chain exec The corresponding execution chain node node ins And parse the preset microservice instance address; 32) intercept the service request q, and determine whether the path and method information in the service request q is consistent with the execution chain node node determined in step 31) ins The information corresponds; if it corresponds, the execution chain node node determined in step 31) is used ins The information rewrites the address in the service request q, and modifies the service identification information in the url of the service request q to the execution chain node node ins The microservice instance address in generates a new service request; 33) Add a modification mark to the new service request modified , used to distinguish it from the service request q to prevent the service request q from being modified repeatedly; then the request response information of the new service request is returned as the response information of the service request q.

8. The method according to claim 1, 2 or 3, characterized in that: The update strategy is: scheduled update every five minutes, update if used 200 times within one minute, update if used 500 times within 10 seconds, update if used 1000 times within one second, or single update without caching.

Citation Information

Patent Citations

  • Micro-service call chain concretization method and device, electronic device and storage medium

    CN111049878A

  • Performance analysis method and device based on call chain

    CN112631880A

  • Task engine execution method and device, equipment and medium

    CN113672371A

  • Micro-service scheduling method, system and device for task response time perception

    CN115145705A

  • Link tracking method for realizing heterogeneous micro-service framework

    CN117435436A