A micro-service application execution latency optimization method based on a REST API execution chain

By constructing a service call chain and execution chain, the service request is directly redirected to the target microservice instance, which solves the network delay problem introduced by the API gateway and improves the response speed and efficiency of the microservice application.

CN119135776BActive Publication Date: 2025-10-17INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the microservice architecture, the additional network communication delay introduced by the API gateway increases the service call overhead and affects the execution performance of the microservice application.

Method used

By constructing service call chains and execution chains, the number of times service calls pass through the API gateway is reduced, and service requests are directly redirected to the target microservice instance, reducing gateway redirection operations.

Benefits of technology

It significantly improves the response speed and overall efficiency of microservice applications and increases the service response rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135776B_ABST
    Figure CN119135776B_ABST
Patent Text Reader

Abstract

The application discloses a micro-service application execution time delay optimization method based on a REST API execution chain, and steps of the method comprise the following steps: 1) a micro-service monitoring module collects historical execution tracks of service request responses of micro-services, and constructs a service call chain of the micro-service according to historical execution track data; the service call chain is a service response link in a micro-service cluster corresponding to a service request of the micro-service; 2) an API gateway constructs a service execution chain of the micro-service; the service execution chain is a service forwarding process corresponding to the service request response; 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 header information to a corresponding micro-service instance; 4) the API gateway updates the service execution chain according to a set update strategy. The application improves the overall response rate of a micro-service application system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a micro-service architecture application execution time delay optimization method, in particular to a micro-service application execution time delay optimization method based on a REST API execution chain, and belongs to the computer software field. BACKGROUND

[0002] Micro-service is a software architecture mode, which divides a single application into a group of small services, the services coordinate and cooperate with each other, and the services cooperate with each other by using a light-weight communication mechanism (usually a REST API based on an HTTP protocol). Each service is constructed around a specific business and can be independently deployed to a production environment. Micro-service not only shows a new architecture mode, but also shows a new organization mode. Therefore, when a micro-service application responds to an external request, a plurality of services cooperate to respond to the external request. At present, application internal service calling needs to be assisted by a gateway, and the service gateway is a key component in the micro-service architecture, which acts as an entry point of the whole system and is responsible for processing internal and external requests and routing to corresponding micro-service instances.

[0003] With the rise of REST API, the API gateway has gradually developed into a more complex and functional component. REST API provides a simple, lightweight and easy-to-understand communication protocol, so that the integration between different systems becomes more flexible and simple. The API gateway starts to support the routing, authentication and authorization of REST API.

[0004] However, the introduction of the API gateway also brings additional network overhead. External service calling and internal service calling both need to pass through the redirection operation of the gateway to access the target micro-service instance, which increases the network communication time delay overhead and seriously affects the execution performance of the micro-service application. SUMMARY

[0005] In view of the technical problems in the prior art, the purpose of the application is to provide a micro-service application execution time delay optimization method based on a REST API execution chain, which reduces the number of service calls through the API gateway, thereby reducing the additional communication time delay caused by the introduction of the API gateway, realizing faster service response and improving the overall response rate of the micro-service application system.

[0006] The technical scheme of the application is as follows:

[0007] A micro-service application execution time delay optimization method based on a REST API execution chain, the steps of which comprise:

[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] Furthermore, 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 the 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 serv Sort and generate the service call chain call ; Among them, the request calls the chain node node servThe information is stored in a key-value mode, wherein the key includes the service request sender name, service request path and service request type, and the value includes the service request receiver name and service receiver version; the service calling chain chain call is stored in a <key, value> data format, wherein the key includes the unique identification information of the service request, and the value is the service calling chain chain call .

[0015] Further, the method for constructing the service execution chain chain exec is as follows:

[0016] 21) The service calling chain chain call is split into a group of request calling chain nodes node serv , the service address is parsed from each request calling chain node node serv and mapped into an executable micro-service instance, an execution chain node node ins is generated according to each executable micro-service instance, and a set set exec of execution chain nodes node send is obtained; the information stored in the executable micro-service instance includes the service caller serv rec , the service receiver serv call , the requested path and method information;

[0017] 22) The execution chain nodes node ins are constructed into a service execution chain chain exec in the calling order recorded in the service calling chain chain call .

[0018] Further, the service request sender serv send and the service request receiver serv rec both include service identification and service version information; the service request information req includes the request path url, the request method method and the request parameter; the abstract service definition serv includes the service identification and the service version information.

[0019] Further, the method for constructing the request calling chain node node serv corresponding to the service request is as follows: the monitoring data is classified using the identification mark corresponding to the service request, the monitoring data corresponding to the service request is obtained, and the service request sender serv send , the service request receiver serv rec and the service request information req are parsed and encapsulated into the request calling chain node corresponding to the service request.

[0020] Further, the unique identification information of the service request is a service identifier, a request parameter contained in the service request information req, and a hash value of the service request information req.

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

[0022] 31) When the API gateway receives the service request q issued by the microservice, determine the corresponding execution chain node node exec of the service request q in the service execution chain chain ins and parse the preset microservice instance address therein;

[0023] 32) Intercept the service request q, and determine whether the path and method information in the service request q correspond to the execution chain node node ins information determined in step 31); if corresponding, use the execution chain node node ins information determined in step 31) to rewrite the address in the service request q, modify the service identifier information in the url in the service request q to the microservice instance address in the execution chain node node ins , and generate a new service request;

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

[0025] Further, the update strategy is: five-minute timed update, 200 times used within 1 minute, 500 times used within 10s, 1000 times used within 1s, or no cache single update.

[0026] The technical solution of the application is shown in Figure 1 , and specifically includes the following steps:

[0027] 1. The microservice monitoring module collects the historical execution track of the service request response of the microservice, and constructs a service call chain according to the historical execution track data, as shown in Figure 3 , the service call chain chain call is the service response link inside the cluster corresponding to the service request. The specific steps are as follows:

[0028] 1) As shown in Figure 2 , the data of the microservice cluster system is monitored to obtain the related information of the service request response. The related information includes the service request issuing party serv send, service request receiver serv rec , service request information req, wherein the service request sender serv send , the service request receiver serv rec , and the service request receiver serv serv Both the service request sending node and the service request receiving node contain service identification and service version information of the microservice; the service request information req contains a request path url, a request method method, and a request parameter.

[0029] 2) Construct a request call chain node node serv based on historical execution trajectory data corresponding to the service request serv The abstract service definition serv stored in node send contains service identification and service version information, and does not contain specific information such as deployment address, port, and health status of the service. The construction of the request call chain node requires parsing monitoring data, classifying the monitoring data using the identification mark corresponding to the service request, obtaining monitoring data corresponding to the service request, and parsing serv rec , serv A and req mentioned in step 1) from the monitoring data, and encapsulating these parsed data into the request call chain node. Then, the request call chain node is sorted according to the topology structure of the service call. The topology structure describes the calling relationship between services, including the dependency relationship between services, the connection between the caller and the callee, and the path of the call chain. The request call chain node is sorted according to the calling order of the encapsulated request call chain node in the topology structure.

[0030] 3) For the service request execution path serv B →serv C inside the cluster, each service party on the service request path during service calling is taken as a request call chain node node serv in the call chain. The request call chain node is the service party that calls and executes in the service request execution path. The request call chain node node serv saves these information in a key-value manner, wherein the key is the service request sender name + service request path + service request type, and the value stores the service request receiver name + service request version; wherein serv send includes the service request sender name, serv rec includes the receiver name + version, and req includes the service request path + service request type serv send , req as key information, and serv rec as value.

[0031] 4) write the related information into the service call chain chain call , the construction of the call chain is In the system, it is stored in the format of <key, value> data. The key is the unique identification information of the service request identified by the service request information req, and the unique identification information is represented by the service identification, the request parameter contained in the service request information req, and the hash value calculated by the service request information req. The value is the service call chain chain call . The service call chain chain call The construction starts when the service request response reaches the API gateway. If there is a service call chain chain call of the current service request, the validity analysis of the call chain is needed. If the call chain is within the valid time and there is no new execution track corresponding to the service request, the construction of the service call chain is not repeated.

[0032] 2. API gateway constructs service execution chain chain exec , the service execution chain chain exec refers to the complete service forwarding process corresponding to the service request response obtained by pre-computation in the service scheduling process. The API gateway obtains the service call chain chain call information obtained in step 1 by matching the req information saved in the call chain with the method, path, parameter and other information of the external request to be responded. call The obtained service call chain chain call is node parsed.

[0033] 1) split the service call chain chain call into a set of single call nodes node serv , and perform concurrent analysis and calculation on each call node node serv to obtain the actual service address, thereby improving the parsing rate of the call nodes. The execution chain nodes and the call chain nodes are in one-to-one correspondence, and the execution chain nodes are generated by parsing the call chain nodes and mapping them to real microservice instances. The real microservice instance refers to a real executable microservice instance containing service deployment address ip, port port, health status healthy and other specific information. The service call chain is split into a set of call nodes

[0034] 2) perform mapping operation on the nodes in the call node set to real microservice instances to obtain the execution chain node set The abstract definition serv of the service stored in the calling node is mapped to the real service, and the instantiation mapping is realized to obtain the physical real instance information of the micro service. The instance information is used to execute the real service instance node of the request information corresponding to the service ins The information stored in the real service instance includes the service calling party serv send , the service receiving party serv rec , the path and method information of the request, and the address information of the specific real micro service instance, which is different from the service receiving party information stored in the calling chain node.

[0035] 3) The real micro service instance node node ins is constructed into a service execution chain chain call according to the calling order recorded in the service calling chain chain exec to ensure the accuracy of the topology construction of the execution chain node.

[0036] 3. When the service request sent by the micro service reaches the API gateway, the API gateway writes the service execution chain chain exec obtained through step 2 into the header information of the external request to be responded, and then sends the processed external request to be responded to the corresponding micro service instance, triggers the subsequent execution path, and participates in the process of the whole service response. Through the Agent method, the application process of the execution chain is realized by intercepting and rewriting the service request in the response process, as shown in Figure 4 . The specific application process is as follows:

[0037] 1) Determine the position of the service request currently sent by the micro service in the service execution chain chain exec , that is, obtain the execution chain node node ins corresponding to the service, and parse the preset micro service instance information (i.e. micro service instance address) in the execution chain node node ins , including 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 correspond to the execution chain node node insIf the information corresponds, the execution chain node information is used to request address rewriting. The rewriting of the request address needs to modify the service identification information in the corresponding url in the service request to the real micro-service instance address, such as modifying the url declared as service.com / service / api in the original service request to ip:port / service / api.

[0039] 3) Modify the request address in the service request information, and add a modification mark mark in the new request modified Distinguish from the original service request information to prevent the request from being repeatedly modified. The obtained request response information is returned as the response information of the original service request, and finally the response acceleration of the service is realized.

[0040] 4. The gateway updates the service execution chain information by updating the policy, reduces the request response error caused by the online and offline of the service, and ensures the correctness of the overall service response. The update policy is as follows:

[0041] 1) Five-minute timing update.

[0042] 2) 200 times are used within 1 minute to update.

[0043] 3) 500 times are used within 10s to update.

[0044] 4) 1000 times are used within 1s to update

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

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

[0047] By adopting the method of the present application, the service response speed can be effectively improved. For the micro-service system with a large number of micro-service application internal service calls, the present application can significantly improve the overall speed of micro-service response, thereby improving the efficiency of micro-service application. BRIEF DESCRIPTION OF DRAWINGS

[0048] Figure 1 The figure is a service response acceleration method based on historical trajectory application technical solution.

[0049] Figure 2 The figure is a historical execution data monitoring and grouping technical method.

[0050] Figure 3 The figure is a RESTAPI call chain construction technical method.

[0051] Figure 4 The figure is an execution chain application technical solution. DETAILED DESCRIPTION

[0052] The application will be further described below in connection with the accompanying drawings and examples.

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

[0054] The method first collects the calling relationship of the microservice system and stores it. For example, the / api / getAllOrders method of the microservice ts-admin-order-service in the TrainTicket system calls the / api / findAllOrder method of the microservice ts-order-service, at which time we will record the calling chain chain call ={ts-admin-order-service: / api / getAllOrders: GET→ts-order-service: / api / findAllOrder: GET}. According to the calling chain, the service execution chain chain exec ={192.168.12.11: 12030: / api / getAllOrders: GET→192.168.12.12: 12032: / api / findAllOrder: GET} is calculated. By the method of step three, ts-order-service is changed to 192.168.12.12: 12032 in the external request method of ts-admin-order-service, bypassing the microservice gateway to access the service, reducing the service delay caused by the gateway.

[0055] The method in the application can improve the response speed of the TrainTicket system by 46.20%.

[0056] The above case proves that the method of the application can improve the service response speed based on the service response history track, and has a positive effect on the improvement of the response speed of the overall microservice system.

Claims

1. A method for optimizing execution latency of microservice applications based on a REST API execution chain, comprising the following steps: 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 The 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; the specific implementation method is: 31) When the API gateway receives the service request q issued by the microservice, Determine the service request q 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 If the information corresponds, use the execution chain node determined in step 31) 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) adds 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; and then return the request response information of the new service request as the response information of the service request q; 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 monitors 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; 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 the 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 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 the key' includes the service request sender name, service request path, and service request type, and the value' includes the service request receiver name and 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 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 the request path url, request method method and request parameters.

5. The method according to claim 2, characterized in that Construct the request call chain node corresponding to the service request serv The method is as follows: 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 issuer 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 update strategy is: scheduled update every five minutes, update if used 200 times within 1 minute, update if used 500 times within 10 seconds, update if used 1000 times within 1 second, or single update without caching.

Citation Information

Patent Citations

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

    CN111049878A

  • Link tracking method for realizing heterogeneous micro-service framework

    CN117435436A