[go: up one dir, main page]

CN119743534A - Dynamic upstream service selection method, device, equipment and medium - Google Patents

Dynamic upstream service selection method, device, equipment and medium

Info

Publication number
CN119743534A
CN119743534A CN202411763947.8A CN202411763947A CN119743534A CN 119743534 A CN119743534 A CN 119743534A CN 202411763947 A CN202411763947 A CN 202411763947A CN 119743534 A CN119743534 A CN 119743534A
Authority
CN
China
Prior art keywords
upstream service
determining
request
access
candidate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411763947.8A
Other languages
Chinese (zh)
Inventor
吴晓敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Cloud Technology Co Ltd
Original Assignee
China Telecom Cloud Technology Co Ltd
Filing date
Publication date
Application filed by China Telecom Cloud Technology Co Ltd filed Critical China Telecom Cloud Technology Co Ltd
Publication of CN119743534A publication Critical patent/CN119743534A/en
Pending legal-status Critical Current

Links

Abstract

The embodiment of the invention provides a dynamic upstream service selection method, a device, equipment and a medium, wherein the method comprises the steps of obtaining an access request and a route matching rule, determining an access parameter for a service instance or a server which directly processes the access request according to the access request by an upstream service, determining a candidate upstream service according to the access parameter and the route matching rule, determining a load condition of the candidate upstream service according to the candidate upstream service, and determining a target upstream service according to the access parameter and the load condition of the candidate upstream service.

Description

Dynamic upstream service selection method, device, equipment and medium
Technical Field
The present invention relates to the field of route matching technologies, and in particular, to a method, an apparatus, a device, and a medium for dynamic upstream service selection.
Background
Today, where micro-service architecture is increasingly prevalent, the importance of an API gateway as a bridge connecting clients to backend services is self-evident. The API gateway is not only responsible for forwarding the service request, but also bears the key task of load balancing so as to ensure the stable and efficient operation of the back-end service. However, conventional upstream service selection mechanisms often rely on static configurations, which tend to be frustrating when dealing with complex and diverse request scenarios.
Specifically, the conventional upstream service selection manner has the following significant problems:
The lack of dynamic tuning capability-static configuration means that the choice of upstream services is determined at the time of API gateway deployment and cannot be tuned in real time according to the actual request characteristics. This results in often inflexible resource allocation in the face of highly concurrent or diverse requests, which is prone to resource waste or performance bottlenecks.
The resource utilization rate is low, and because the upstream services cannot be dynamically adjusted according to the request situation, static configuration often causes overload of some upstream services, and other services may be in an idle state. The unbalanced resource allocation mode not only reduces the overall performance of the system, but also increases the operation and maintenance cost.
Accordingly, in order to solve the above-described problems, a mechanism capable of dynamically selecting an upstream service according to a real-time request feature is needed. The mechanism can sense the change of the request in real time, intelligently adjust the selection strategy of the upstream service, improve the resource utilization rate, and enhance the flexibility and the expandability of the system, thereby ensuring the stable and efficient operation of the API gateway under the high concurrency and diversified request scenes.
Disclosure of Invention
In view of the foregoing, embodiments of the present invention have been developed to provide a dynamic upstream service selection method, apparatus, device, and medium that overcome, or at least partially solve, the foregoing problems.
In order to solve the above problems, an embodiment of the present invention discloses a dynamic upstream service selection method, which includes:
obtaining access request and route matching rule, wherein the upstream service is a service instance or server directly processing the access request
Determining access parameters according to the access request;
determining a candidate upstream service according to the access parameter and the route matching rule;
determining the load condition of the candidate upstream service according to the candidate upstream service;
And determining the target upstream service according to the access parameters and the load condition of the candidate upstream service.
Optionally, the access parameter includes a request parameter and a uniform resource locator path of the access request, and the determining the candidate upstream service according to the access parameter and a preset route matching rule includes:
And determining the candidate upstream service according to the request parameters, the uniform resource locator path of the access request and a preset route matching rule.
Optionally, the route matching rule includes a uniform resource locator path matching rule, and determining the candidate upstream service according to the access parameter and the route matching rule includes:
And determining a candidate upstream service according to the access parameter and the uniform resource locator path matching rule.
Optionally, the route matching rule includes a hypertext transfer protocol method matching rule, and the determining the candidate upstream service according to the access parameter and the route matching rule includes:
and determining a candidate upstream service according to the access parameter and the matching rule of the hypertext transfer protocol method.
Optionally, the route matching rule includes a hypertext transfer protocol request header rule, and the determining the candidate upstream service according to the access parameter and the route matching rule includes:
And determining a candidate upstream service according to the access parameter and the hypertext transfer protocol request header matching rule.
Optionally, the method further comprises:
determining a matching condition of the access request to the upstream service according to the access parameter;
The determining the candidate upstream service according to the access parameter and the route matching rule comprises the following steps:
And determining the candidate upstream service according to the access parameters, the matching conditions of the access request on the upstream service and the route matching rule.
Optionally, the determining, according to the candidate upstream service, a load condition of the candidate upstream service includes:
Acquiring response time of the upstream service;
and determining the load condition of the candidate upstream service according to the response time of the upstream service and a preset mapping relation.
In another aspect, an embodiment of the present invention discloses a dynamic upstream service selection device, where the device includes:
a request and rule acquisition module for acquiring access request and route matching rule, wherein the upstream service is a service instance or server for directly processing the access request
The access parameter acquisition module is used for determining access parameters according to the access request;
A candidate upstream confirming module, configured to determine a candidate upstream service according to the access parameter and the route matching rule;
the load condition confirming module is used for confirming the load condition of the candidate upstream service according to the candidate upstream service;
And the target upstream service confirmation module is used for determining the target upstream service according to the access parameter and the load condition of the candidate upstream service.
Optionally, the access parameter includes a request parameter and a uniform resource locator path of the access request, and the candidate upstream acknowledgement module includes:
And the first candidate confirmation sub-module is used for determining the candidate upstream service according to the request parameters, the uniform resource locator path of the access request and the preset route matching rule.
Optionally, the route matching rule includes a uniform resource locator path matching rule, and the candidate upstream acknowledgement module includes:
And the second candidate confirmation sub-module is used for determining the candidate upstream service according to the access parameter and the uniform resource locator path matching rule.
Optionally, the route matching rule includes a hypertext transfer protocol method matching rule, and the candidate upstream acknowledgement module includes:
And the third candidate confirmation sub-module is used for determining the candidate upstream service according to the access parameter and the matching rule of the hypertext transfer protocol method.
Optionally, the route matching rule includes a hypertext transfer protocol request header rule, and the candidate upstream acknowledgement module includes:
And the fourth candidate confirmation sub-module is used for determining a candidate upstream service according to the access parameter and the hypertext transfer protocol request header matching rule.
Optionally, the method further comprises:
The matching condition acquisition sub-module is used for determining the matching condition of the access request to the upstream service according to the access parameter;
The candidate upstream acknowledgement module includes:
And the fifth candidate confirmation sub-module is used for determining candidate upstream services according to the access parameters, the matching conditions of the access request on the upstream services and the route matching rules.
Optionally, the load condition confirmation module includes:
a response time obtaining sub-module, configured to obtain a response time of the upstream service;
And the first load condition confirming sub-module is used for determining the load condition of the candidate upstream service according to the response time of the upstream service and a preset mapping relation.
Accordingly, the embodiment of the invention discloses electronic equipment, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein the computer program realizes the steps of the dynamic upstream service selection method embodiment when being executed by the processor.
Accordingly, embodiments of the present invention disclose a computer readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of the dynamic upstream service selection method embodiments described above.
The embodiment of the invention has the advantages that the performance and the resource utilization efficiency of the API gateway in the micro-service architecture are obviously improved by implementing the dynamic upstream service selection mechanism. Specifically, through the process of acquiring the access request and the route matching rule and determining the access parameter, the characteristics of the access request can be perceived and analyzed in real time, and the target upstream service is intelligently selected to forward the request by combining the route matching rule and the load condition of the upstream service. The mechanism effectively solves the problems of uneven resource allocation, performance bottleneck and lack of dynamic adjustment capability in the traditional static configuration, ensures stable and efficient operation of the API gateway in the high-concurrency and diversified request scene, greatly improves the overall throughput and response speed of the system, reduces the operation and maintenance cost, and enhances the expandability and flexibility of the system.
Drawings
FIG. 1 is a flow chart of steps of an embodiment of a dynamic upstream service selection method of the present invention;
FIG. 2 is a flow chart of steps of another dynamic upstream service selection method embodiment of the present invention;
FIG. 3 is a flow chart of steps of another dynamic upstream service selection method embodiment of the present invention;
FIG. 4 is a schematic diagram of a cluster online of an embodiment of a dynamic upstream service selection method of the present invention;
Fig. 5 is a block diagram of an embodiment of a dynamic upstream service selection device of the present invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
An API gateway (API GATEWAY) is a server that serves as an entry point for an Application Programming Interface (API) performing a variety of tasks to simplify, secure, and optimize API communications. In particular, the API gateway is located between the client and the back-end service, providing a unified access portal to manage all API requests. Its main functions include request routing, centralized management of API requests, security control, load balancing, monitoring and logging.
Upstream services are generally referred to in a service architecture as a server that provides some function or data. It may be considered as a preamble in the service chain, providing basic functionality or data for use by subsequent services.
In network engineering, routing refers to the process of determining the network scope of an end-to-end path as a packet goes from a source to a destination. In particular, routing is the process of routing a packet from a source point to a destination in a network. It can determine the best path for data packets to travel between multiple networked devices (e.g., routers). The router uses predefined routing protocols and policies to decide how to forward the packet to the next node or final destination. This decision is based on routing table information that contains parameters such as the state, distance and cost of each path in the network.
One of the core ideas of the embodiment of the invention is that dynamic upstream service selection is realized by analyzing request parameters of an access request and combining preset route matching logic and upstream service load conditions.
Referring to fig. 1, a flowchart illustrating steps of a first embodiment of a dynamic upstream service selection method according to the present invention may specifically include the following steps:
Step 101, obtaining an access request and a route matching rule, wherein the upstream service is a service instance or a server for directly processing the access request;
The system receives the access request from the client and parses out the requested details such as URL path, query parameters, HTTP information, etc. This is the starting point for the overall request processing flow, ensuring that the system is able to properly understand and process the client's request. The route matching rules provide a framework for subsequent upstream service selection so that requests can be properly routed to the corresponding service according to preset rules.
The URL (Uniform Resource Locator ) is a string on the internet that is used to identify the location of a resource. The URL path is the portion of the URL that is used to specify the location of the resource, typically after the domain name. The query parameters are the parts of the URL that are used to deliver additional information to the server, typically located after the URL path, beginning with.
Whereas the hypertext transfer Protocol (Hypertext Transfer Protocol, HTTP) is a simple request-response Protocol that typically runs on top of the transmission control Protocol (TCP, transmissionControl Protocol). It specifies what messages the client might send to the server and what responses it gets. The header of the request and response messages is given in ASCII (AMERICAN STANDARD Code for Information Interchange) form, while the message content has a format similar to MIME (Multipurpose INTERNET MAIL Extensions ). The hypertext transfer protocol is an application layer protocol for distributed, collaborative, and hypermedia information systems, which is the basis for data communication over the world wide web WWW (World Wide Web).
102, Determining access parameters according to the access request;
and the system further extracts access parameters influencing upstream service selection according to the analyzed request information. The parameters may include service identifier, user ID, request type, version information, etc., and the extraction rule of the parameters may be adjusted according to the service, which is not limited by the embodiment of the present invention. The access parameters are key bases for subsequent upstream service selection and they can help the system more accurately identify the requirements and characteristics of the request. By extracting the access parameters, the system is able to more flexibly select the most appropriate upstream service based on the characteristics of the request.
Step 103, determining a candidate upstream service according to the access parameter and the route matching rule;
The system combines the access parameters and the route matching rules to further match and screen the request and determine a preliminary candidate upstream service pool. By comprehensively considering the access parameters and the route matching rules, the system can more accurately determine which upstream services can handle the current request. The determination of the candidate upstream service pool provides a more specific scope and goal for subsequent upstream service selection.
Step 104, determining the load condition of the candidate upstream service according to the candidate upstream service;
And monitoring load conditions of the candidate upstream service in real time, wherein the load conditions comprise key indexes such as response time, request processing capacity, error rate and the like. These load information provide important decision basis for subsequent upstream service selection.
The assessment of load conditions can help the system learn of the current performance and availability status of the candidate upstream services. By considering the load condition, the system can avoid routing the request to the overload or poor-performance service, thereby improving the response speed and quality of the service. The load condition evaluation may also be performed in other manners, which are not limited by the embodiment of the present invention.
And 105, determining a target upstream service according to the access parameter and the load condition of the candidate upstream service.
The system comprehensively considers the access parameters and the load condition of the candidate upstream service, and adopts a comprehensive decision mechanism to determine the final target upstream service. Such mechanisms may include various policies such as weight allocation, prioritization, load balancing algorithms, etc. to ensure that requests are allocated to optimal upstream services for processing.
By integrating the decision mechanism, the system is able to more accurately select the upstream service that is most appropriate for handling the current request. The determination of the targeted upstream services ensures that requests can be efficiently and accurately processed, thereby improving the overall performance and user experience of the system.
The embodiment of the invention remarkably improves the performance and the resource utilization efficiency of the API gateway in the micro-service architecture by implementing the dynamic upstream service selection mechanism. Specifically, through the process of acquiring the access request and the route matching rule and determining the access parameter, the characteristics of the access request can be perceived and analyzed in real time, and the target upstream service is intelligently selected to forward the request by combining the route matching rule and the load condition of the upstream service. The mechanism effectively solves the problems of uneven resource allocation, performance bottleneck and lack of dynamic adjustment capability in the traditional static configuration, ensures stable and efficient operation of the API gateway in the high-concurrency and diversified request scene, greatly improves the overall throughput and response speed of the system, reduces the operation and maintenance cost, and enhances the expandability and flexibility of the system.
Referring to fig. 2, a flowchart illustrating steps of another dynamic upstream selection method embodiment of the present invention may specifically include the steps of:
Step 201, obtaining an access request and a route matching rule, wherein the upstream service is a service instance or a server for directly processing the access request;
The system receives the access request from the client and parses out the requested details such as URL path, query parameters, HTTP information, etc. This is the starting point for the overall request processing flow, ensuring that the system is able to properly understand and process the client's request. The route matching rules provide a framework for subsequent upstream service selection so that requests can be properly routed to the corresponding service according to preset rules.
The URL (Uniform Resource Locator ) is a string on the internet that is used to identify the location of a resource. The URL path is the portion of the URL that is used to specify the location of the resource, typically after the domain name. The query parameters are the parts of the URL that are used to deliver additional information to the server, typically located after the URL path, beginning with.
Whereas the hypertext transfer Protocol (Hypertext Transfer Protocol, HTTP) is a simple request-response Protocol that typically runs on top of the transmission control Protocol (TCP, transmissionControl Protocol). It specifies what messages the client might send to the server and what responses it gets. The header of the request and response messages is given in ASCII (AMERICAN STANDARD Code for Information Interchange) form, while the message content has a format similar to MIME (Multipurpose INTERNET MAIL Extensions ). The hypertext transfer protocol is an application layer protocol for distributed, collaborative, and hypermedia information systems, which is the basis for data communication over the world wide web WWW (World Wide Web).
Step 202, determining access parameters according to the access request, wherein the access parameters comprise request parameters and a uniform resource locator path of the access request
And the system further extracts access parameters influencing upstream service selection according to the analyzed request information. The parameters may include service identifier, user ID, request type, version information, etc. besides the url path, and the extraction rule of the parameters may be adjusted according to the service, which is not limited by the embodiment of the present invention. The access parameters are key bases for subsequent upstream service selection and they can help the system more accurately identify the requirements and characteristics of the request. By extracting the access parameters, the system is able to more flexibly select the most appropriate upstream service based on the characteristics of the request.
Step 203, determining a candidate upstream service according to the request parameter, the uniform resource locator path of the access request and a preset route matching rule;
The system combines the access parameters and the route matching rules to further match and screen the request and determine a preliminary candidate upstream service pool. By comprehensively considering the access parameters and the route matching rules, the system can more accurately determine which upstream services can handle the current request. The determination of the candidate upstream service pool provides a more specific scope and goal for subsequent upstream service selection.
In one embodiment, the method further comprises:
determining a matching condition of the access request to the upstream service according to the access parameter;
according to the specific scene of the request, the user manually selects the matching condition of the corresponding upstream service;
step 203 comprises the steps of:
and determining the candidate upstream service according to the access parameters, the matching conditions of the access request on the upstream service and the route matching rule. The matching conditions for the upstream service can be manually formulated by the user, so that different requirements in each business scene can be further met, and the flexibility of the method is improved.
Step 204, determining the load condition of the candidate upstream service according to the candidate upstream service;
The assessment of load conditions can help the system learn of the current performance and availability status of the candidate upstream services. By considering the load condition, the system can avoid routing the request to the overload or poor-performance service, thereby improving the response speed and quality of the service. The load condition evaluation may also be performed in other manners, which are not limited by the embodiment of the present invention.
In one embodiment, step 204 further comprises the sub-steps of:
A substep S11 of obtaining a response time of the upstream service;
response time is one of the key indicators measuring service performance and reflects the efficiency of service processing requests. By acquiring the response time, performance bottlenecks or potential problems of upstream services can be discovered in time. And simultaneously provides important basis for subsequent load evaluation and request routing.
And a substep S12, determining the load condition of the candidate upstream service according to the response time of the upstream service and a preset mapping relation.
The load situation directly reflects the current processing power and stability of the upstream service. By determining the load situation, the actual operating state of the candidate upstream service can be more accurately known. And simultaneously, an important basis is provided for selecting the optimal upstream service, realizing load balancing and avoiding service overload.
By acquiring the response time of the upstream service in real time and combining the load condition evaluation, the system can rapidly select the upstream service with the highest response speed and the lowest load to process the request. This significantly improves the processing efficiency of the request and reduces the waiting time of the user. Accurate assessment of load conditions helps the system discover and avoid sending requests to overloaded or poorly performing upstream services in a timely manner. This reduces the occurrence of service failures and errors, enhancing the stability and reliability of the system. Through reasonable request routing and load balancing, the system can fully utilize the resources of the upstream service, and avoid the waste and idling of the resources. This increases the utilization of system resources and reduces the operating costs. The fast response time and stable system performance directly promote the user experience. The user can access and use the system more smoothly, and inconvenience and trouble caused by service failure or performance problems are reduced.
And step 205, determining a target upstream service according to the access parameter and the load condition of the candidate upstream service.
The system comprehensively considers the access parameters and the load condition of the candidate upstream service, and adopts a comprehensive decision mechanism to determine the final target upstream service. Such mechanisms may include various policies such as weight allocation, prioritization, load balancing algorithms, etc. to ensure that requests are allocated to optimal upstream services for processing.
By integrating the decision mechanism, the system is able to more accurately select the upstream service that is most appropriate for handling the current request. The determination of the targeted upstream services ensures that requests can be efficiently and accurately processed, thereby improving the overall performance and user experience of the system.
The embodiment of the invention remarkably improves the performance and the resource utilization efficiency of the API gateway in the micro-service architecture by implementing the dynamic upstream service selection mechanism. Specifically, through the process of acquiring the access request and the route matching rule and determining the access parameter, the characteristics of the access request can be perceived and analyzed in real time, and the target upstream service is intelligently selected to forward the request by combining the route matching rule and the load condition of the upstream service. The mechanism effectively solves the problems of uneven resource allocation, performance bottleneck and lack of dynamic adjustment capability in the traditional static configuration, ensures stable and efficient operation of the API gateway in the high-concurrency and diversified request scene, greatly improves the overall throughput and response speed of the system, reduces the operation and maintenance cost, and enhances the expandability and flexibility of the system.
Referring to fig. 3, there is shown a flow chart of steps of another dynamic upstream selection of the present invention, which may specifically include the steps of:
step 301, obtaining an access request and a route matching rule, wherein the upstream service is a service instance or a server for directly processing the access request, and the route matching rule comprises a uniform resource locator path matching rule
The system receives the access request from the client and parses out the requested details such as URL path, query parameters, HTTP information, etc. This is the starting point for the overall request processing flow, ensuring that the system is able to properly understand and process the client's request. The route matching rules provide a framework for subsequent upstream service selection so that requests can be properly routed to the corresponding service according to preset rules.
The URL (Uniform Resource Locator ) is a string on the internet that is used to identify the location of a resource. The URL path is the portion of the URL that is used to specify the location of the resource, typically after the domain name. The query parameters are the parts of the URL that are used to deliver additional information to the server, typically located after the URL path, beginning with.
Whereas the hypertext transfer Protocol (Hypertext Transfer Protocol, HTTP) is a simple request-response Protocol that typically runs on top of the transmission control Protocol (TCP, transmissionControl Protocol). It specifies what messages the client might send to the server and what responses it gets. The header of the request and response messages is given in ASCII (AMERICAN STANDARD Code for Information Interchange) form, while the message content has a format similar to MIME (Multipurpose INTERNET MAIL Extensions ). The hypertext transfer protocol is an application layer protocol for distributed, collaborative, and hypermedia information systems, which is the basis for data communication over the world wide web WWW (World Wide Web).
Step 302, determining access parameters according to the access request;
and the system further extracts access parameters influencing upstream service selection according to the analyzed request information. The parameters may include service identifier, user ID, request type, version information, etc., and the extraction rule of the parameters may be adjusted according to the service, which is not limited by the embodiment of the present invention. The access parameters are key bases for subsequent upstream service selection and they can help the system more accurately identify the requirements and characteristics of the request. By extracting the access parameters, the system is able to more flexibly select the most appropriate upstream service based on the characteristics of the request.
Step 303, determining a candidate upstream service according to the access parameter and the uniform resource locator path matching rule;
By means of URL path matching rules, the system is able to accurately identify and process HTTP requests based on the URL path of the request. This ensures that the request is sent to a service that can properly handle the request, thereby improving the accuracy and efficiency of the request handling. URL path matching rules are the basis for implementing path-based routing, which enables the system to implement different routing policies, such as static routing, dynamic routing, path-based load balancing, etc., depending on the URL path of the request. In addition, the URL path matching rule also provides support for the expandability and flexibility of the system, so that the system can adapt to different service requirements and scene changes more easily.
In one embodiment, the route matching rule includes a hypertext transfer protocol method matching rule, and step 303 includes the following sub-steps:
And a substep S21, determining a candidate upstream service according to the access parameter and the matching rule of the hypertext transfer protocol method.
The method used by HTTP requests (e.g., GET, POST, PUT, DELETE, etc.) is particularly considered when selecting candidate upstream services
HTTP defines several request methods, each corresponding to a different operation. For example, the GET method is used to acquire resources, the POST method is used to submit data, the PUT method is used to update resources, and the DELETE method is used to DELETE resources. By introducing HTTP method matching rules, the system is able to more accurately identify and process different types of HTTP requests. This fine-grained matching mechanism helps to improve the accuracy and efficiency of request routing, ensuring that requests are sent to services that can properly handle the request. At the same time, the system also provides support for the expandability and flexibility of the system, so that the system can adapt to different business requirements and scenes more easily.
In one embodiment, the route matching rule includes a hypertext transfer protocol request header rule, and step 303 may further include the sub-steps of:
substep S31 determines a candidate upstream service according to the access parameter and the hypertext transfer protocol request header matching rule.
In selecting the candidate upstream service, the system considers specific information in the header of the HTTP request, which is typically used to convey additional data about the request and the client, and the header information of the HTTP contains a lot of useful information about the client's environment and the body of the request, such as the user agent, the host of the request, the content type, etc. The request header is in the form of a key-value pair for providing additional information for the server to better handle the request. Common request headers include Host (specifying the server address of the request), user-Agent (representing the browser or application Type of the client), accept (the Type of media acceptable to the client), content-Type (the Type of media of the request body), and so forth. By introducing HTTP request header matching rules, the system is able to more accurately identify and process HTTP requests based on additional information in the request header. This mechanism enables the system to route requests to corresponding upstream services based on different request header fields (e.g., content type, authentication information, etc.), thereby improving the accuracy and flexibility of request processing. In addition, request routing based on the characteristics of client type, user identity and the like can be realized by using the request header matching rule, so that the possibility is provided for providing personalized service and realizing fine-grained access control.
Step 304, determining the load condition of the candidate upstream service according to the candidate upstream service;
response time is one of the key indicators measuring service performance and reflects the efficiency of service processing requests. By acquiring the response time, performance bottlenecks or potential problems of upstream services can be discovered in time. And simultaneously provides important basis for subsequent load evaluation and request routing.
In one embodiment, step 304 further comprises the sub-steps of:
a substep S41 of obtaining a response time of the upstream service;
Response time is one of the key indicators measuring service performance and reflects the efficiency of service processing requests. By acquiring the response time, performance bottlenecks or potential problems of upstream services can be discovered in time. Colleagues provide important basis for subsequent load assessment and request routing.
And a substep S42, determining the load condition of the candidate upstream service according to the response time of the upstream service and a preset mapping relation.
By acquiring the response time of the upstream service in real time and combining the load condition evaluation, the system can rapidly select the upstream service with the highest response speed and the lowest load to process the request. This significantly improves the processing efficiency of the request and reduces the waiting time of the user. Accurate assessment of load conditions helps the system discover and avoid sending requests to overloaded or poorly performing upstream services in a timely manner. This reduces the occurrence of service failures and errors, enhancing the stability and reliability of the system. Through reasonable request routing and load balancing, the system can fully utilize the resources of the upstream service, and avoid the waste and idling of the resources. This increases the utilization of system resources and reduces the operating costs. The fast response time and stable system performance directly promote the user experience. The user can access and use the system more smoothly, and inconvenience and trouble caused by service failure or performance problems are reduced.
And step 305, determining a target upstream service according to the access parameter and the load condition of the candidate upstream service.
The system comprehensively considers the access parameters and the load condition of the candidate upstream service, and adopts a comprehensive decision mechanism to determine the final target upstream service. Such mechanisms may include various policies such as weight allocation, prioritization, load balancing algorithms, etc. to ensure that requests are allocated to optimal upstream services for processing. By integrating the decision mechanism, the system is able to more accurately select the upstream service that is most appropriate for handling the current request. The determination of the targeted upstream services ensures that requests can be efficiently and accurately processed, thereby improving the overall performance and user experience of the system.
The embodiment of the invention remarkably improves the performance and the resource utilization efficiency of the API gateway in the micro-service architecture by implementing the dynamic upstream service selection mechanism. Specifically, through the process of acquiring the access request and the route matching rule and determining the access parameter, the characteristics of the access request can be perceived and analyzed in real time, and the target upstream service is intelligently selected to forward the request by combining the route matching rule and the load condition of the upstream service. The mechanism effectively solves the problems of uneven resource allocation, performance bottleneck and lack of dynamic adjustment capability in the traditional static configuration, ensures stable and efficient operation of the API gateway in the high-concurrency and diversified request scene, greatly improves the overall throughput and response speed of the system, reduces the operation and maintenance cost, and enhances the expandability and flexibility of the system.
In one embodiment, the gateway used in this method embodiment may be Apache APISIX and Apache Apisix is a cloud-native micro-service API gateway service of the Apache foundation. The method has the advantages of dynamic routing and plug-in hot loading, and is suitable for API management under a micro-service system.
Referring to fig. 4, a cluster online schematic of an embodiment of a dynamic upstream service selection method of the present invention is shown:
After the new cluster is online, registering the endpoint to the management console, the front end of the management console obtains the new cluster endpoint according to the cluster selected by the client, the new cluster endpoint is set in the x_cluster_endpoint HTTP header, the dynamic upstream of apisix can extract the value of the x_cluster_endpoint HTTP header from the configured upstream extraction rule as the upstream, and thus the corresponding request is sent to the new cluster.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 5, a block diagram illustrating an embodiment of a dynamic upstream service selection device according to the present invention may specifically include the following modules:
A request and rule acquisition module 401 for acquiring access request and route matching rule, wherein the upstream service is a service instance or server directly processing the access request
An access parameter obtaining module 402, configured to determine an access parameter according to the access request;
A candidate upstream confirmation module 403, configured to determine a candidate upstream service according to the access parameter and the route matching rule;
A load condition confirmation module 404, configured to determine, according to the candidate upstream service, a load condition of the candidate upstream service;
And the target upstream service confirmation module 405 is configured to determine a target upstream service according to the access parameter and the load condition of the candidate upstream service.
In one embodiment, the access parameters include a request parameter and a uniform resource locator path of the access request, and the candidate upstream acknowledgement module includes:
And the first candidate confirmation sub-module is used for determining the candidate upstream service according to the request parameters, the uniform resource locator path of the access request and the preset route matching rule.
In one embodiment, the route matching rules include uniform resource locator path matching rules, and the candidate upstream acknowledgement module includes:
And the second candidate confirmation sub-module is used for determining the candidate upstream service according to the access parameter and the uniform resource locator path matching rule.
In one embodiment, the route matching rule includes a hypertext transfer protocol method matching rule, and the candidate upstream acknowledgement module includes:
And the third candidate confirmation sub-module is used for determining the candidate upstream service according to the access parameter and the matching rule of the hypertext transfer protocol method.
In one embodiment, the route matching rule includes a hypertext transfer protocol request header rule, and the candidate upstream acknowledgement module includes:
And the fourth candidate confirmation sub-module is used for determining a candidate upstream service according to the access parameter and the hypertext transfer protocol request header matching rule.
In one embodiment, the method further comprises:
The matching condition acquisition sub-module is used for determining the matching condition of the access request to the upstream service according to the access parameter;
The candidate upstream acknowledgement module includes:
And the fifth candidate confirmation sub-module is used for determining candidate upstream services according to the access parameters, the matching conditions of the access request on the upstream services and the route matching rules.
In one embodiment, the load condition confirmation module includes:
a response time obtaining sub-module, configured to obtain a response time of the upstream service;
And the first load condition confirming sub-module is used for determining the load condition of the candidate upstream service according to the response time of the upstream service and a preset mapping relation.
The embodiment of the invention remarkably improves the performance and the resource utilization efficiency of the API gateway in the micro-service architecture by implementing the dynamic upstream service selection mechanism. Specifically, through the process of acquiring the access request and the route matching rule and determining the access parameter, the characteristics of the access request can be perceived and analyzed in real time, and the target upstream service is intelligently selected to forward the request by combining the route matching rule and the load condition of the upstream service. The mechanism effectively solves the problems of uneven resource allocation, performance bottleneck and lack of dynamic adjustment capability in the traditional static configuration, ensures stable and efficient operation of the API gateway in the high-concurrency and diversified request scene, greatly improves the overall throughput and response speed of the system, reduces the operation and maintenance cost, and enhances the expandability and flexibility of the system.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
The embodiment of the invention also provides electronic equipment, which comprises:
the dynamic upstream service selection method comprises a processor, a memory and a computer program which is stored in the memory and can run on the processor, wherein the computer program realizes all the processes of the dynamic upstream service selection method embodiment when being executed by the processor, can achieve the same technical effects, and is not repeated here for avoiding repetition.
The embodiment of the invention also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, realizes the processes of the dynamic upstream service selection method embodiment, and can achieve the same technical effects, and in order to avoid repetition, the description is omitted here.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The foregoing describes in detail a dynamic upstream service selection method, apparatus, device and medium provided by the present invention, and specific examples are provided herein to illustrate the principles and embodiments of the present invention, and the above examples are provided to assist in understanding the method and core ideas of the present invention, and meanwhile, to those skilled in the art, according to the ideas of the present invention, there are variations in the specific embodiments and application scope, so that the disclosure should not be construed as limiting the present invention.

Claims (10)

1. A method of dynamic upstream service selection, the method comprising:
obtaining access request and route matching rule, wherein the upstream service is a service instance or server directly processing the access request
Determining access parameters according to the access request;
determining a candidate upstream service according to the access parameter and the route matching rule;
determining the load condition of the candidate upstream service according to the candidate upstream service;
And determining the target upstream service according to the access parameters and the load condition of the candidate upstream service.
2. The method of claim 1, wherein the access parameters include request parameters and a uniform resource locator path of the access request, wherein the determining the candidate upstream service based on the access parameters and a preset route matching rule comprises:
And determining the candidate upstream service according to the request parameters, the uniform resource locator path of the access request and a preset route matching rule.
3. The method of claim 1, wherein the route matching rules comprise uniform resource locator path matching rules, and wherein the determining the candidate upstream service based on the access parameters and the route matching rules comprises:
And determining a candidate upstream service according to the access parameter and the uniform resource locator path matching rule.
4. The method of claim 1, wherein the route matching rules comprise hypertext transfer protocol method matching rules, and wherein said determining a candidate upstream service based on the access parameters and the route matching rules comprises:
and determining a candidate upstream service according to the access parameter and the matching rule of the hypertext transfer protocol method.
5. The method of claim 1, wherein the route matching rules comprise hypertext transfer protocol request header rules, and wherein said determining a candidate upstream service based on the access parameters and the route matching rules comprises:
And determining a candidate upstream service according to the access parameter and the hypertext transfer protocol request header matching rule.
6. The method according to any one of claims 1-5, further comprising:
determining a matching condition of the access request to the upstream service according to the access parameter;
The determining the candidate upstream service according to the access parameter and the route matching rule comprises the following steps:
And determining the candidate upstream service according to the access parameters, the matching conditions of the access request on the upstream service and the route matching rule.
7. The method of claim 6, wherein said determining a load condition of said candidate upstream service based on said candidate upstream service comprises:
Acquiring response time of the upstream service;
and determining the load condition of the candidate upstream service according to the response time of the upstream service and a preset mapping relation.
8. A dynamic upstream service selection device, the device comprising:
a request and rule acquisition module for acquiring access request and route matching rule, wherein the upstream service is a service instance or server for directly processing the access request
The access parameter acquisition module is used for determining access parameters according to the access request;
A candidate upstream confirming module, configured to determine a candidate upstream service according to the access parameter and the route matching rule;
the load condition confirming module is used for confirming the load condition of the candidate upstream service according to the candidate upstream service;
And the target upstream service confirmation module is used for determining the target upstream service according to the access parameter and the load condition of the candidate upstream service.
9. An electronic device comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, which when executed by the processor implements the steps of a dynamic upstream service selection method according to any one of claims 1-7.
10. A computer readable storage medium, characterized in that it has stored thereon a computer program which, when executed by a processor, implements the steps of a dynamic upstream service selection method according to any of claims 1 to 7.
CN202411763947.8A 2024-12-03 Dynamic upstream service selection method, device, equipment and medium Pending CN119743534A (en)

Publications (1)

Publication Number Publication Date
CN119743534A true CN119743534A (en) 2025-04-01

Family

ID=

Similar Documents

Publication Publication Date Title
EP3968594B1 (en) Method, apparatus and system for selecting mobile edge computing node
US11418620B2 (en) Service request management
RU2549135C2 (en) System and method for providing faster and more efficient data transmission
WO2020228505A1 (en) Method, device, and system for selecting mobile edge computing node
US20050060425A1 (en) Application-based autonomic connectivity
CN108429701B (en) Network acceleration system
CN102792292A (en) System and method for site performance optimization and Internet traffic processing
US7877479B2 (en) Bandwidth control system and method capable of reducing traffic congestion on content servers
US20150127837A1 (en) Relay apparatus and data transfer method
US9705762B2 (en) Systems and methods for detecting device identity at a proxy background
CN107613037A (en) Method and system for domain name redirection
US20090067419A1 (en) Transmission control apparatus and method
US20020136204A1 (en) Method and system for routing network traffic based upon application information
US20090150564A1 (en) Per-user bandwidth availability
CN106992906A (en) Method and system for adjusting access rate
US20060069777A1 (en) Request message control method for using service and service providing system
CN110601989A (en) Network traffic balancing method and device
CN119743534A (en) Dynamic upstream service selection method, device, equipment and medium
JP5894981B2 (en) Accessing a network of nodes distributed across a communication architecture using a topology server with multiple criteria selection
CN110601993B (en) Multi-outlet load balancing method and device
CN115622943B (en) Data distribution method, device, system, equipment and medium
EP2827557B1 (en) Automated application metric selection for multi-cost ALTO queries
CN112543191B (en) Load balancing method and device
CN105359485A (en) Method for retrieving, by a client terminal, a content part of a multimedia content
CN112436981B (en) Method and system for measuring network flow by cloud control strategy and multi-protocol implementation

Legal Events

Date Code Title Description
PB01 Publication