Routing method and device of service request, equipment and storage medium
By using preset routing rules and forwarding components in the service grid, service requests are routed in a refined manner based on the label information and version information of the service instance, the problem of difficulty in routing to a specific version of the service instance in the prior art is solved, and more flexible and accurate service request routing is achieved.
Patent Information
- Application Number
- CN202411575106.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-06
AI Technical Summary
The prior art is difficult to route service requests to specific versions of service instances in the service mesh in a refined manner, and cannot effectively respond to the needs of complex business scenarios.
Through the gateway component, according to the preset routing rules, the characteristic information of the target service instance that the target service request matches is determined from multiple service instances, including the label information and version information of the service instance. Then, through the forwarding component, the target service request is forwarded to the target service instance.
It realizes the flexibly defines preset routing rules based on the label information and version information of the service instance, and finely forwards business requests to target service instances with specific tags and specific versions, improving the flexibility and accuracy of routing, and adapting to the needs of various complex business scenarios.
Smart Images

Figure CN119583655A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of microservice technology, and in particular to a method, apparatus, device, and storage medium for routing a service request. Background Art
[0002] With the development of service grid technology, service grid is widely used in the management of microservices and is an important component of large-scale distributed systems. Among them, service grid introduces gateway system and routing rules, and routing rules can be used to realize the routing of business requests.
[0003] At present, the routing module in the gateway system usually routes business requests according to the service instance label carried in the business request. However, this routing method has limitations and it is difficult to finely route business requests to specific versions of service instances, making it difficult to meet the needs of complex business scenarios. Summary of the invention
[0004] In order to solve the above technical problem or at least partially solve the above technical problem, the embodiments of the present disclosure provide a method, apparatus, device and storage medium for routing a service request.
[0005] A first aspect of an embodiment of the present disclosure provides a method for routing a service request, which is applied to a gateway system, wherein the gateway system includes a gateway component, a forwarding component, and multiple service instances, wherein the method includes:
[0006] Determining, by the gateway component, characteristic information of a target service instance that matches the received target business request from the multiple service instances according to a preset routing rule, wherein the preset routing rule includes characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes label information and version information of the service instance;
[0007] The target service request is forwarded to the target service instance through the forwarding component according to the characteristic information of the target service instance.
[0008] A second aspect of an embodiment of the present disclosure provides a routing device for a service request, which is applied to a gateway system, wherein the gateway system includes a gateway component, a forwarding component, and multiple service instances, wherein the device includes:
[0009] A first determination module is used to determine, through the gateway component, characteristic information of a target service instance that matches the received target business request from the multiple service instances according to a preset routing rule, wherein the preset routing rule contains characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes label information and version information of the service instance;
[0010] The first forwarding module is used to forward the target service request to the target service instance through the forwarding component according to the characteristic information of the target service instance.
[0011] A third aspect of an embodiment of the present disclosure provides an electronic device, the server comprising: a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method of the first aspect above.
[0012] A fourth aspect of an embodiment of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of the first aspect described above can be implemented.
[0013] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0014] The disclosed embodiment can determine the characteristic information of the target service instance that matches the received target business request from multiple service instances through a gateway component according to preset routing rules, wherein the preset routing rules contain the characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes the label information and version information of the service instance; through a forwarding component, the target business request is forwarded to the target service instance according to the characteristic information of the target service instance. It can be seen that by adopting the above technical solution, the preset routing rules can be flexibly defined according to the label information and version information of the service instance, and then the preset routing rules can be used to precisely forward the target request to the target service instance with a specific label and a specific version, so that the routing method of the business request is more flexible and accurate, thereby adapting to the needs of various complex business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0017] Figure 1 is a flow chart of a method for routing a service request provided by an embodiment of the present disclosure;
[0018] Figure 2 is a schematic diagram of the structure of a gateway system provided by an embodiment of the present disclosure;
[0019] Figure 3 is a flow chart of a routing process of a service request provided by an embodiment of the present disclosure;
[0020] Figure 4 is a schematic diagram of a call link provided by an embodiment of the present disclosure;
[0021] Figure 5 It is a structural diagram of a service request routing device provided by an embodiment of the present disclosure;
[0022] Figure 6 It is a structural schematic diagram of an electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0024] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0025] Figure 1 1 is a flow chart of a method for routing a service request provided by an embodiment of the present disclosure, and the method can be executed by an electronic device. The electronic device can be exemplarily understood as a device such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, a smart TV, etc. Figure 1 As shown, the method provided in this embodiment includes the following steps:
[0026] S110. Determine, through the gateway component and according to preset routing rules, characteristic information of a target service instance that matches the received target business request from multiple service instances, wherein the preset routing rules include characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes label information and version information of the service instance.
[0027] In an embodiment of the present disclosure, a gateway system is integrated in an electronic device, wherein the gateway system includes a gateway component, a forwarding component, and multiple service instances. In order to enable the gateway system to execute the method described in the embodiment of the present disclosure, the gateway system can be initialized in advance and preset routing rules can be defined through a configuration file. Specifically, the gateway component is configured, the preset routing rules required by the gateway component are defined through the configuration file, and the forwarding component is initialized, and the preset routing rules in the configuration file are loaded. Among them, the preset routing rules are used to define how to route a business request from the current node (client or currently called service instance) to a matching service instance. In other words, some preset routing rules are used to define how to route a business request from a client to a matching service instance, and some preset routing rules are used to define how to route a business request from a currently called service instance to the next matching service instance. The specific definition of the preset routing rules includes but is not limited to the following method: for each service instance, a corresponding preset routing rule is defined based on the characteristic information of the service instance.
[0028] Specifically, the target service request may be any service request to be routed. Exemplarily, the target service request may include requests related to user authentication and account management (such as login request, registration request, password retrieval request, personal information management request, account cancellation request, etc.), requests related to video content browsing and searching (such as video search request, video category browsing request, video detail page request, homepage recommendation request, etc.), and requests related to video playback interaction (such as video playback request, comment request, collection and sharing request, etc.), but is not limited thereto.
[0029] Specifically, the target service instance is a service instance that is capable of executing the target service request (or is applicable to the target service request) as indicated by the preset routing rule.
[0030] Specifically, the preset routing rules include characteristic information of the service instance that matches the business request, wherein the characteristic information of the service instance includes but is not limited to tag information of the service instance (information used to describe the service performance of the service instance, etc.) and version information (used to indicate the version number of the service instance).
[0031] In the disclosed embodiment, the gateway component serves as the entrance to the service grid and is mainly responsible for receiving the service request from the client and determining the characteristic information of the service instance matching the service request according to the preset routing rules.
[0032] Exemplarily, the gateway component can use a common service grid tool (such as Istio or Nginx, etc.) to determine the characteristic information of the service instance that matches the business request according to the preset routing rules, but is not limited to this. Figure 2As shown, the gateway component includes a gateway resolver, which determines the label information and version information of the service instance that matches the business request according to the preset routing rules in the configuration file.
[0033] S120 . Forward the target business request to the target service instance through the forwarding component according to the characteristic information of the target service instance.
[0034] In some real-time examples, multiple service instances are divided into multiple service instance groups, and the service instances in the same service instance group have the same characteristic information. The forwarding component includes a routing rule engine and a load balancer of the service instance group, wherein S120 includes:
[0035] S121. Through the routing rule engine, according to the preset routing rules, determine the target call link corresponding to the characteristic information of the target service instance, and forward the target business request to the load balancer corresponding to the target service instance group according to the target call link, wherein the target service instance group is the service instance group to which the target service instance belongs.
[0036] In the embodiment of the present disclosure, when the forwarding component is initialized through the configuration file, the routing rule engine is initialized. Therefore, the routing rule engine can match the preset routing rules according to the characteristic information of the service instance matched by the business request, and forward the business request to the load balancer corresponding to the service instance group to which the matched service instance belongs according to the call link in the matched preset routing rule.
[0037] Specifically, the target call link is a link that routes the service request from the current node (client or currently called service instance) to the service instance group to which the matching service instance belongs. In some embodiments, the current node is the client, in which case the target call link is a link that routes the service request from the client to the service instance group to which the matching service instance belongs. Of course, in other embodiments, the current node is the currently called service instance, in which case the target call link is a link that routes the service request from the currently called service instance to the service instance group to which the next matching service instance belongs.
[0038] For example, Figure 3 As shown, the gateway system includes three services, mocka, mockb and mockc. Each service corresponds to three versions of service instances, V1, V2 and V3. If the target service instance is the V1 version of the mocka service, the target call link is the link that routes the business request from the client to the "service instance group to which the V1 version of the mocka service instance belongs".
[0039] S122. Forward the target business request to the target service instance through the load balancer of the target service instance group.
[0040] In the disclosed embodiment, the load balancer can evenly distribute the service requests to the matching service instances to improve the responsiveness and availability of the gateway system. Of course, the load balancer can also check whether the target service request meets the preset routing conditions to improve the security of the gateway system. But it is not limited to this.
[0041] In some other embodiments, S120 includes: determining a target call link corresponding to the characteristic information of the target service instance, and forwarding the target service request to the target service instance according to the target call link. In this case, the target call link is a link that routes the service request from the current node (client or currently called service instance) to the matching service instance.
[0042] The disclosed embodiment can determine the characteristic information of the target service instance that matches the received target business request from multiple service instances through a gateway component according to preset routing rules, wherein the preset routing rules contain the characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes the label information and version information of the service instance; through a forwarding component, the target business request is forwarded to the target service instance according to the characteristic information of the target service instance. It can be seen that by adopting the above technical solution, the preset routing rules can be flexibly defined according to the label information and version information of the service instance, and then the preset routing rules can be used to precisely forward the target request to the target service instance with a specific label and a specific version, so that the routing method of the business request is more flexible and accurate, thereby adapting to the needs of various complex business scenarios.
[0043] In some embodiments, according to a preset routing rule, determining characteristic information of a target service instance that matches the received target service request from multiple service instances includes:
[0044] Parsing characteristic information of a client sending the target service request from the target service request;
[0045] Determine a first target routing rule that matches the characteristic information of the client from the preset routing rules;
[0046] The characteristic information of the service instance included in the first target routing rule is used as the characteristic information of the target service instance.
[0047] Specifically, the characteristic information of the client includes but is not limited to the client's IP address, the client's name, the client's metadata, the region to which the client belongs, the client type, the identification information of the application that initiates the service request in the client, and / or the version number of the application that initiates the service request in the client.
[0048] Specifically, the preset routing rules also include characteristic information of the client that initiates the service request. Therefore, the first target routing rule that matches the characteristic information of the client can be determined from the preset routing rules, wherein the first target routing rule is used to implement routing of the service request to the matching service instance. Exemplarily, the characteristic information of the client and the preset routing rules can be matched by prefix matching, suffix matching, regular matching, etc., but are not limited thereto.
[0049] Specifically, the preset routing rules include characteristic information of the client initiating the business request and characteristic information of the service instance matching it. Therefore, the characteristic information of the service instance contained in the first target routing rule can be used as the characteristic information of the service instance matching the business request.
[0050] It is understandable that by determining the characteristic information of the service instance that matches the service request based on the characteristic information of the client that initiates the service request, the selected service instance can be matched or suitable with the characteristic information of the client, so that a more personalized experience can be provided to the user. In addition, compared with carrying the label of the service instance used to process the service request in the service request, the client does not need to know how many service instances are currently in the gateway system, when the service instances are added or reduced, or which service instance to use to process the service request in advance. It can simply bring its own characteristic information, which is conducive to reducing the difficulty of generating service requests on the client side.
[0051] In some embodiments, according to a preset routing rule, determining a target call link corresponding to the characteristic information of a target service instance includes:
[0052] Using a tree structure matching algorithm, searching for a target node that matches the characteristic information of the target service instance, wherein the target node includes the characteristic information of the target service instance;
[0053] Determine a second target routing rule that matches the characteristic information of the target service instance from the preset routing rules associated with the target node;
[0054] The call link in the second target routing rule is used as the target call link.
[0055] Specifically, a tree structure can be constructed in advance based on the characteristic information of multiple service instances (including at least label information and version information), and each node in the tree structure can represent a characteristic information, wherein the tree structure can be a binary tree, a multi-branch tree or a dictionary tree, etc., but is not limited to this.
[0056] Specifically, according to the characteristic information of the service instance matching the business request, matching is performed in the tree structure until a matching node (i.e., the target node) is found. Exemplarily, the characteristic information of the service instance matching the business request and the nodes in the tree structure can be matched by prefix matching, suffix matching, regular matching, etc., but it is not limited thereto.
[0057] Specifically, the preset routing rule associated with the target node includes feature information of the service instance matching the business request.
[0058] Specifically, the preset routing rule also includes a call link for routing the business request to a matching service instance (or a service instance group to which the matching service instance belongs). Therefore, the call link included in the second target routing rule can be used as the target call link.
[0059] It can be understood that, through the tree structure matching algorithm, it is possible to quickly locate and select a suitable target call link according to the characteristic information of the service instance matching the business request, thereby improving the routing efficiency of the business request.
[0060] In some embodiments, the multiple service instances include a fallback service instance, and the method further includes: if the target call link fails according to the characteristic information of the target service instance using the preset routing rule, forwarding the target service request to the load balancer of the fallback service instance according to the fallback call link through the routing rule engine;
[0061] The target business request is forwarded to the underlying service instance through the load balancer of the underlying service instance.
[0062] Specifically, the fallback service instance is a default service instance, which is used when no service instance matching the business request is found. Exemplarily, the fallback service instance can be marked as "default".
[0063] Specifically, the fallback call link is a default call link, which is used to route the business request to the fallback service instance when no service instance matching the business request is found.
[0064] It can be understood that by setting up a fallback service instance and a fallback call link, when there is no specific routing rule to select a service instance that matches a business request, the business request can be quickly switched to the default service instance (i.e., the fallback service instance), thereby reducing routing failures.
[0065] In some embodiments, forwarding the target service request to the target service instance includes: detecting whether the target service request meets a preset routing condition to obtain a detection result;
[0066] If the target service request meets the preset routing conditions, the target service request is routed to the target service instance;
[0067] If the target service request does not meet the preset routing conditions, the error handling process for the target service request is triggered.
[0068] Specifically, the preset routing conditions may include security detection (such as malicious request detection), content detection (such as illegal character detection, detection of whether the request size threshold is exceeded, detection of whether the request format conforms to the expected format), current limiting and rate limiting detection, etc., but are not limited to these.
[0069] Specifically, if the target service request meets the preset routing conditions, the target service request is routed to the target service instance so that the target service instance executes the target service request. It should be noted that if there is only one target service instance, the service request will be routed to the target service instance. Of course, if there are multiple matching target service instances (the multiple target service instances are the same or the multiple target service instances belong to the same service instance group), one of them can be selected according to the load balancing strategy, where the load balancing strategy can include a polling algorithm, a least connection algorithm, or a weight-based load balancing algorithm (such as Figure 2 ), but is not limited thereto.
[0070] Specifically, if the target service request does not meet the preset routing condition, an error handling process for the target service request is triggered, and the target service request is not routed to the target service instance.
[0071] Specifically, if the target service request is routed to the target service instance, the target service request is processed by the target service instance.
[0072] It can be understood that by performing preset routing condition detection before forwarding business requests to matching service instances, the load balancer can provide a layer of protection to ensure the validity and security of business requests, thereby optimizing the performance of the gateway system and improving the reliability of the gateway system.
[0073] In some embodiments, the gateway system further includes a monitoring component, wherein the method further includes: monitoring the routing process of the target service request through the monitoring component to obtain a monitoring result, and feeding back the monitoring result to the gateway component.
[0074] Specifically, the functions of the monitoring component include but are not limited to performance monitoring, health status monitoring, fault detection and recovery, fault tracing and traffic analysis, log recording and analysis, business request distribution and execution results, call link tracing, analysis of whether there are similar routing rules and business request forwarding mechanisms to detect infringement and / or alarm and notification, etc. For example, the monitoring component can use tools such as Prometheus or Grafana (such as Figure 2 As shown in the figure, it records the call path, delay, error rate and other indicators of the business request in real time. Of course, it can also provide a friendly visual interface and alarm function. For example, when the business request does not meet the preset routing conditions, it can trigger an alarm notification. It can also display a friendly error page to the user, explaining why the business request was rejected and providing possible solutions or contact information.
[0075] It is understandable that by setting up monitoring components, the status of the service can be fully monitored, and problems can be discovered in a timely manner, thereby improving the reliability and performance of the gateway system.
[0076] In some embodiments, security authentication and data encryption are performed through the gateway system.
[0077] It is understandable that by adding security authentication and data encryption functions, the security and data protection capabilities of the gateway system can be significantly improved. These mechanisms can generally include identity authentication, authorization, token management, transport layer encryption, data encryption and key management, etc., but are not limited to these. In this way, data and communication security can be effectively protected.
[0078] In some embodiments, the method also includes: for each service instance, setting label information of the service instance according to the service performance of the service instance, wherein the service performance includes hardware resources and service quality, the label information of some service instances among multiple service instances is critical traffic, the label information of another part of the service instances is ordinary traffic, and the label information of the remaining part of the service instances is test traffic, the service performance of the service instances with label information as critical traffic is higher than the service performance of the service instances with label information as ordinary traffic, and the service performance of the service instances with label information as ordinary traffic is higher than the service performance of the service instances with label information as test traffic.
[0079] Specifically, the hardware resource indicators may include, but are not limited to, the number of cores and frequency of the processor, and / or memory capacity, etc. The service quality indicators may include, but are not limited to, response time, throughput, resource utilization, error rate, delay, etc.
[0080] Specifically, the specific forms of expression of service performance include scores or ratings. For example, after obtaining various indicators of hardware resources and service quality of the service instance, the service performance of the service instance is scored or rated according to the various indicators, but it is not limited to this.
[0081] It is understandable that in the field of business requests, business requests can be divided into critical traffic, ordinary traffic and test traffic according to their importance, priority and purpose, among which critical traffic refers to traffic that is critical to business operations, usually involving core business functions and services, ordinary traffic refers to traffic generated in daily business operations, which has a certain impact on business operations, but is not as important as critical traffic, and test traffic refers to traffic used for system testing, verification and debugging, which does not directly affect actual business operations. By configuring labels for critical traffic for service instances with the strongest service performance, labels for ordinary traffic for service instances with relatively strong service performance, and labels for test traffic for service instances with average service performance, it helps the gateway system to optimize resource allocation and ensure the stability and security of the system when processing business requests. In summary, the routing methods in the relevant technologies have some limitations, such as the lack of a flexible routing rule mechanism, the inability to finely route business requests to specific versions of services based on the labels of service instances, and the lack of practical interfaces and algorithms for easy integration and expansion. However, the disclosed embodiment, based on the service grid architecture, sets preset routing rules in the gateway component to forward the service request to the target service instance in a refined manner. This method combines the label information and version information of the service instance to make the routing and forwarding mechanism more flexible and accurate, thereby adapting to various complex business needs, and can monitor and feedback the routing process of the business request in real time. In this way, the flow control accuracy can be enhanced, the gateway system can manage the flow in a more refined manner, and the stability and scalability of the gateway system can be improved, the failure rate of the service instance can be reduced, and user satisfaction can be improved.
[0082] The routing process of the service request provided by the embodiment of the present disclosure is described in detail below with reference to a specific example. Figure 4As shown, the gateway component receives the business request, and determines the label information and version information of the service instance that matches the business request according to the preset routing rules. The routing service engine uses a tree structure matching algorithm to determine the preset routing rules that match the label information and version information of the service instance that matches the business request, and forwards the business request to the load balancer corresponding to the service instance that matches the business request according to the preset routing rules. When the business request meets the preset routing requirements, the load balancer forwards the business request to a matching service instance, and the monitoring component can monitor the routing process of the business request. It can be seen that the example disclosed in the present invention can use the preset routing rules set in the gateway component to route the business request to a specific version of the service instance according to the label information and version information of the service subset (including at least one service instance, and the service instances in the same service subset are the same), so that the flow control is more flexible and accurate.
[0083] Figure 5 1 is a schematic diagram of a structure of a service request routing device provided by an embodiment of the present disclosure. The service request routing device can be understood as the above electronic device or a part of the functional modules in the above electronic device. Figure 5 As shown, the service request routing device 500 includes:
[0084] A first determination module 510 is used to determine, through the gateway component, characteristic information of a target service instance that matches the received target business request from the multiple service instances according to a preset routing rule, wherein the preset routing rule includes characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes tag information and version information of the service instance;
[0085] The first forwarding module 520 is used to determine the target call link corresponding to the characteristic information of the target service instance according to the preset routing rule through the routing rule engine, and forward the target service request to the load balancer corresponding to the target service instance according to the target call link;
[0086] The first routing module 530 is used to perform routing management on the target service request through the load balancer corresponding to the target service instance.
[0087] Optionally, the first determination module 510 is specifically configured to parse the target service request to obtain characteristic information of the client;
[0088] Determine a first target routing rule that matches the characteristic information of the client from the preset routing rules;
[0089] The characteristic information of the service instance included in the first target routing rule is used as the characteristic information of the target service instance.
[0090] Optionally, the first forwarding module 520 includes a first determining submodule, which is used to determine the target call link corresponding to the characteristic information of the target service instance according to the preset routing rule, wherein the first determining submodule is specifically used to use a tree structure matching algorithm to find a target node that matches the characteristic information of the target service instance;
[0091] Determine a second target routing rule that matches the characteristic information of the target service instance from the preset routing rules associated with the target node;
[0092] The call link in the second target routing rule is used as the target call link.
[0093] Optionally, the multiple service instances include a fallback service instance, and the device further includes:
[0094] A first determination module 510 is configured to forward the target service request to the load balancer of the fallback service instance according to the fallback call link through the routing rule engine if the target call link fails according to the characteristic information of the target service instance using the preset routing rule;
[0095] The first routing module 530 is further used to perform routing management on the target business request through the load balancer of the backup service instance.
[0096] Optionally, the first routing module 530 includes:
[0097] A first detection submodule, used to detect whether the target service request meets the preset routing condition to obtain a detection result;
[0098] The first routing submodule is used to perform routing management on the target service request according to the detection result.
[0099] A first routing submodule, specifically configured to route the target service request to the target service instance if the target service request meets the preset routing condition;
[0100] If the target service request does not meet the preset routing condition, triggering an error handling process for the target service request;
[0101] The device further comprises:
[0102] The first processing module is configured to process the target service request through the target service instance if the target service request is routed to the target service instance.
[0103] Optionally, the gateway system further includes a monitoring component, wherein the device further includes:
[0104] The first monitoring module is used to monitor the routing process of the target service request through the monitoring component to obtain a monitoring result, and feed back the monitoring result to the gateway component.
[0105] The device provided in this embodiment can execute the method of any of the above embodiments, and its execution method and beneficial effects are similar, which will not be repeated here.
[0106] An embodiment of the present disclosure further provides an electronic device, which includes: a memory, in which a computer program is stored; and a processor, for executing the computer program. When the computer program is executed by the processor, the method of any of the above embodiments can be implemented.
[0107] For example, Figure 6 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 6 , which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure. The electronic device 600 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0108] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0109] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0110] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0111] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0112] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0113] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0114] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: determines, through a gateway component, according to a preset routing rule, from multiple service instances the characteristic information of a target service instance that matches the received target business request, wherein the preset routing rule contains the characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes the label information and version information of the service instance; determines, through a routing rule engine, according to the preset routing rule, a target call link corresponding to the characteristic information of the target service instance, and forwards the target business request to the load balancer corresponding to the target service instance according to the target call link; and performs routing management on the target business request through the load balancer corresponding to the target service instance.
[0115] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0116] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0117] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0118] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0119] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0120] The embodiments of the present disclosure further provide a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of any of the above embodiments can be implemented. The execution method and beneficial effects are similar and will not be repeated here.
[0121] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0122] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for routing a service request, characterized in that: Applied to a gateway system, the gateway system includes a gateway component, a forwarding component and multiple service instances, wherein the method includes: Determining, by the gateway component, characteristic information of a target service instance that matches the received target business request from the multiple service instances according to a preset routing rule, wherein the preset routing rule includes characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes label information and version information of the service instance; The target service request is forwarded to the target service instance through the forwarding component according to the characteristic information of the target service instance.
2. The method according to claim 1, characterized in that The determining, according to the preset routing rule, characteristic information of the target service instance that matches the received target service request from the multiple service instances includes: Parsing characteristic information of a client sending the target service request from the target service request; Determine a first target routing rule that matches the characteristic information of the client from the preset routing rules; The characteristic information of the service instance included in the first target routing rule is used as the characteristic information of the target service instance.
3. The method according to claim 1, characterized in that The multiple service instances are divided into multiple service instance groups, the service instances in the same service instance group have the same feature information, the forwarding component includes a routing rule engine and a load balancer for each of the service instance groups, wherein forwarding the target business request to the target service instance according to the feature information of the target service instance includes: Determine, by the routing rule engine, the target call link corresponding to the characteristic information of the target service instance according to the preset routing rule, and forward the target business request to the load balancer corresponding to the target service instance group according to the target call link, wherein the target service instance group is the service instance group to which the target service instance belongs; The target service request is forwarded to the target service instance through the load balancer of the target service instance group.
4. The method according to claim 3, characterized in that The step of determining, according to the preset routing rule, a target call link corresponding to the characteristic information of the target service instance includes: Using a tree structure matching algorithm, searching for a target node that matches the characteristic information of the target service instance, wherein the target node includes the characteristic information of the target service instance; Determine a second target routing rule that matches the characteristic information of the target service instance from the preset routing rules associated with the target node; The call link in the second target routing rule is used as the target call link.
5. The method according to claim 3, characterized in that: The multiple service instances include a backup service instance, and the method further includes: If the target call link fails according to the characteristic information of the target service instance using the preset routing rule, the target service request is forwarded to the load balancer of the fallback service instance according to the fallback call link through the routing rule engine; The target business request is forwarded to the fallback service instance through the load balancer of the fallback service instance.
6. The method according to claim 3, characterized in that The forwarding the target service request to the target service instance includes: Detecting whether the target service request meets a preset routing condition to obtain a detection result, wherein the preset routing condition includes at least one of the following: passing a security detection, passing a content detection, and passing a current limiting and rate limiting detection; If the target service request meets the preset routing condition, routing the target service request to the target service instance; If the target service request does not meet the preset routing condition, an error handling process for the target service request is triggered.
7. The method according to claim 1, characterized in that The gateway system further includes a monitoring component, wherein the method further includes: The monitoring component monitors the routing process of the target service request to obtain a monitoring result, and feeds back the monitoring result to the gateway component.
8. The method according to claim 1, characterized in that The method further comprises: For each of the service instances, the label information of the service instance is set according to the service performance of the service instance, wherein the service performance includes hardware resources and service quality, the label information of some of the multiple service instances is critical traffic, the label information of another part of the service instances is ordinary traffic, and the label information of the remaining part of the service instances is test traffic, the service performance of the service instances with label information as critical traffic is higher than the service performance of the service instances with label information as ordinary traffic, and the service performance of the service instances with label information as ordinary traffic is higher than the service performance of the service instances with label information as test traffic.
9. A routing device for service requests, characterized in that: Applied to a gateway system, the gateway system includes a gateway component, a forwarding component and multiple service instances, wherein the device includes: A first determination module is used to determine, through the gateway component, characteristic information of a target service instance that matches the received target business request from the multiple service instances according to a preset routing rule, wherein the preset routing rule contains characteristic information of the service instance that matches the business request, and the characteristic information of the service instance includes label information and version information of the service instance; The first forwarding module is used to forward the target service request to the target service instance through the forwarding component according to the characteristic information of the target service instance.
10. An electronic device, characterized in that: include: A processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Service instance determination method and device, storage medium and electronic equipment
CN110837424A
Flow management method and device for micro-service request, server and storage medium
CN111600930A
Proxy server forwarding method and device, computer storage medium and electronic equipment
CN112491940A
Remote procedure call routing management control method, system and equipment for micro-service
CN115102854A
Business processing method and device, nonvolatile storage medium and electronic equipment
CN118488102A
Cited By
Micro-service instance routing method, API gateway and computing service equipment
CN120017720A
Microservice Instance Routing Method, API Gateway, and Computing Service Device
CN120017720B