Routing methods, devices, equipment, and storage media for business requests
By setting preset routing rules in the gateway system and combining the tag information and version information of service instances, business requests are forwarded to target service instances in a more refined manner, which solves the problem of insufficient routing flexibility in the existing technology and achieves more accurate and flexible business request routing.
Patent Information
- Application Number
- CN202411575106.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2044-11-06
AI Technical Summary
In existing technologies, the routing module of a gateway system has difficulty in finely routing business requests to specific versions of service instances, which cannot meet the needs of complex business scenarios.
The gateway component determines the characteristic information of the target service instance that matches the target business request from multiple service instances based on preset routing rules, including the service instance's tag information and version information, and forwards the request to the target service instance through the forwarding component.
It enables flexible definition of routing rules based on the tag and version information of service instances, improving the accuracy and flexibility of business request routing and adapting to the needs of various complex business scenarios.
Smart Images

Figure CN119583655B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of microservices technology, and in particular to a method, apparatus, device, and storage medium for routing business requests. Background Technology
[0002] With the development of service mesh technology, service mesh is widely used in the management of microservices and is an important component of large-scale distributed systems. Service mesh introduces gateway systems and routing rules, which enable the routing of business requests.
[0003] Currently, the routing module in the gateway system typically routes business requests based on the service instance tag carried in the business request. However, this routing method has limitations and is difficult to route business requests to specific versions of service instances in a fine-grained manner, thus making it difficult to meet the needs of complex business scenarios. Summary of the Invention
[0004] To solve the above-mentioned technical problems, or at least partially solve them, embodiments of this disclosure provide a method, apparatus, device, and storage medium for routing service requests.
[0005] A first aspect of this disclosure provides a method for routing service requests, applied to a gateway system, the gateway system including a gateway component, a forwarding component, and multiple service instances, wherein the method includes:
[0006] The gateway component determines the feature information of the target service instance matching the received target business request from the plurality of service instances according to the preset routing rules. The preset routing rules include the feature information of the service instance matching the business request, and the feature information of the service instance includes the tag information and version information of the service instance.
[0007] The forwarding component forwards the target service request to the target service instance based on the characteristic information of the target service instance.
[0008] A second aspect of this disclosure provides a service request routing apparatus applied to a gateway system, the gateway system including a gateway component, a forwarding component, and multiple service instances, wherein the apparatus includes:
[0009] The first determining module is used to determine, through the gateway component, the characteristic information of the target service instance matching the received target service request from the plurality of service instances according to the preset routing rules, wherein the preset routing rules include the characteristic information of the service instance matching the service request, and the characteristic information of the service instance includes the tag 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 based on the characteristic information of the target service instance through the forwarding component.
[0011] A third aspect of this disclosure provides an electronic device, the server comprising: a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the method of the first aspect described above.
[0012] A fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the method of the first aspect described above.
[0013] The technical solution provided in this disclosure has the following advantages compared with the prior art:
[0014] This embodiment of the disclosure enables a gateway component to determine the characteristic information of a target service instance matching a received target business request from multiple service instances based on preset routing rules. The preset routing rules include the characteristic information of the service instance matching the business request, including its tag information and version information. A forwarding component then forwards the target business request to the target service instance based on its characteristic information. Therefore, by employing the above technical solution, preset routing rules can be flexibly defined based on the tag information and version information of the service instance. These preset routing rules then allow for precise forwarding of target requests to target service instances with specific tags and versions, making the routing of business requests more flexible and accurate, thus adapting to the needs of various complex business scenarios. Attached Figure Description
[0015] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0016] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of a service request routing method provided in an embodiment of this disclosure;
[0018] Figure 2 This is a schematic diagram of the structure of a gateway system provided in an embodiment of this disclosure;
[0019] Figure 3 This is a flowchart illustrating a service request routing process provided in an embodiment of this disclosure;
[0020] Figure 4 This is a schematic diagram of a call chain provided in an embodiment of this disclosure;
[0021] Figure 5 This is a schematic diagram of the structure of a service request routing device provided in an embodiment of this disclosure;
[0022] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. Detailed Implementation
[0023] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0024] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0025] Figure 1 This is a flowchart illustrating a service request routing method provided in an embodiment of this disclosure. This method can be executed by an electronic device. The electronic device can be exemplarily understood as a device such as a mobile phone, tablet computer, laptop computer, desktop computer, or smart TV. Figure 1 As shown, the method provided in this embodiment includes the following steps:
[0026] S110. Through the gateway component, based on the preset routing rules, determine the feature information of the target service instance that matches the received target business request from multiple service instances. The preset routing rules include the feature information of the service instance that matches the business request. The feature information of the service instance includes the tag information and version information of the service instance.
[0027] In this embodiment of the disclosure, an electronic device integrates a gateway system, which includes a gateway component, a forwarding component, and multiple service instances. To enable the gateway system to execute the methods described in this embodiment, the gateway system can be pre-initialized 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, loading the preset routing rules from the configuration file. The preset routing rules define how to route a service request from the current node (client or currently invoked service instance) to a matching service instance. In other words, some preset routing rules define how to route a service request from the client to a matching service instance, and some preset routing rules define how to route a service request from the currently invoked service instance to the next matching service instance. The specific definition methods of the preset routing rules include, but are not limited to, the following: for each service instance, a corresponding preset routing rule is defined based on the characteristic information of that service instance.
[0028] Specifically, the target business request can be any business request to be routed. For example, the target business request may include requests related to user authentication and account management (such as login requests, registration requests, password retrieval requests, personal information management requests, account cancellation requests, etc.), requests related to video content browsing and searching (such as video search requests, video category browsing requests, video details page requests, homepage recommendation requests, etc.), and requests related to video playback interaction (such as video playback requests, comment requests, collection and sharing requests, etc.), but is not limited to these.
[0029] Specifically, the target service instance is the service instance specified by the preset routing rules that is capable of executing the target business request (or is suitable for the target business request).
[0030] Specifically, the preset routing rules include the feature information of the service instance that matches the business request. The feature information of the service instance includes, but is not limited to, the service instance's tag information (information used to describe the service performance of the service instance, etc.) and version information (used to represent the version number of the service instance).
[0031] In this embodiment of the disclosure, the gateway component serves as the entry point of the service mesh and is primarily responsible for receiving service requests from clients and determining the characteristic information of the service instance matching the service request based on preset routing rules.
[0032] For example, the gateway component can use general service mesh tools (such as Istio or Nginx) to determine the characteristic information of the service instance matching the business request based on preset routing rules, but it is not limited to this. For example, Figure 2As shown, the gateway component includes a gateway resolver, which determines the tag information and version information of the service instance that matches the business request based on the preset routing rules in the configuration file.
[0033] S120. Using the forwarding component, the target service request is forwarded to the target service instance based on the characteristic information of the target service instance.
[0034] In some real-time examples, multiple service instances are divided into multiple service instance groups. Service instances within the same service instance group have the same characteristic information. The forwarding component includes a routing rule engine and a load balancer for the service instance group. S120 includes:
[0035] S121. Using the routing rule engine, determine the target call chain corresponding to the characteristic information of the target service instance according to the preset routing rules, and forward the target business request to the load balancer corresponding to the target service instance group according to the target call chain. The target service instance group is the service instance group to which the target service instance belongs.
[0036] In this embodiment of the 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 feature information of the service instance to which the service request is matched, and forward the service request to the load balancer corresponding to the service instance group to which the matched service instance belongs according to the call chain in the matched preset routing rule.
[0037] Specifically, the target call chain is the chain that routes a service request from the current node (client or the currently invoked service instance) to the service instance group to which the matching service instance belongs. In some embodiments, the current node is the client, and in this case, the target call chain is the chain that routes a 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 invoked service instance, and in this case, the target call chain is the chain that routes a service request from the currently invoked service instance to the next matching 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 a service instance of version V1, V2, and V3, respectively. If the target service instance is a V1 version service instance of the mocka service, then the target call chain is the chain that routes the business request from the client to the "service instance group to which the V1 version service instance of the mocka service belongs".
[0039] S122. The target service requests are forwarded to the target service instance through the load balancer of the target service instance group.
[0040] In this embodiment, the load balancer can evenly distribute service requests to matching service instances to improve the responsiveness and availability of the gateway system. Of course, the load balancer can also check whether target service requests meet preset routing conditions to improve the security of the gateway system. However, it is not limited to this.
[0041] In other embodiments, S120 includes: determining the target call chain corresponding to the feature information of the target service instance, and forwarding the target service request to the target service instance according to the target call chain. In this case, the target call chain is the chain that routes the service request from the current node (client or the currently invoked service instance) to the matching service instance.
[0042] This embodiment of the disclosure enables a gateway component to determine the characteristic information of a target service instance matching a received target business request from multiple service instances based on preset routing rules. The preset routing rules include the characteristic information of the service instance matching the business request, including its tag information and version information. A forwarding component then forwards the target business request to the target service instance based on its characteristic information. Therefore, by employing the above technical solution, preset routing rules can be flexibly defined based on the tag information and version information of the service instance. These preset routing rules then allow for precise forwarding of target requests to target service instances with specific tags and versions, making the routing of business requests more flexible and accurate, thus adapting to the needs of various complex business scenarios.
[0043] In some embodiments, based on preset routing rules, the characteristic information of the target service instance matching the received target service request is determined from multiple service instances, including:
[0044] Extract the characteristic information of the client that sent the target business request from the target business request;
[0045] Determine the first target routing rule that matches the client's feature information from the preset routing rules;
[0046] The feature information of the service instance contained in the first target routing rule is used as the feature information of the target service instance.
[0047] Specifically, the client's characteristic information includes, but is not limited to, the client's IP address, client name, client metadata, the region to which the client belongs, client type, the identification information of the application initiating the business request in the client, and / or the version number of the application initiating the business request in the client.
[0048] Specifically, the preset routing rules also include the characteristic information of the client initiating the business request. Therefore, a first target routing rule matching the client's characteristic information can be determined from the preset routing rules. The first target routing rule is used to route the business request to the matching service instance. For example, the client's characteristic information and the preset routing rules can be matched using prefix matching, suffix matching, regular expression matching, etc., but it is not limited to these methods.
[0049] Specifically, the preset routing rules include the feature information of the client that initiates the business request and the feature information of the service instance that matches it. Therefore, the feature information of the service instance contained in the first target routing rule can be used as the feature information of the service instance that matches the business request.
[0050] Understandably, determining the characteristic information of the service instance matching the business request based on the client's characteristic information ensures that the selected service instance matches or is suitable for the client's characteristics, thus providing a more personalized user experience. Furthermore, compared to carrying a tag for the service instance used to handle the business request in the request itself, the client doesn't need to know how many service instances are currently in the gateway system, when service instances were added or removed, or which service instance to use to handle the business request. It can simply provide its own characteristic information, which helps reduce the difficulty of generating business requests for the client.
[0051] In some embodiments, determining the target call chain corresponding to the characteristic information of the target service instance according to preset routing rules includes:
[0052] A tree-structure matching algorithm is used to find target nodes that match the feature information of the target service instance, wherein the target node includes the feature information of the target service instance;
[0053] Determine a second target routing rule from the preset routing rules associated with the target node that matches the feature information of the target service instance;
[0054] Use the call chain in the second target routing rule as the target call chain.
[0055] Specifically, a tree structure can be pre-constructed based on the feature information (at least including tag information and version information) of multiple service instances. Each node in the tree structure can represent a feature information. The tree structure can be a binary tree, a multi-branch tree, or a trie, but is not limited to these.
[0056] Specifically, based on the feature information of the service instance matching the business request, a matching process is performed in the tree structure until a matching node (i.e., the target node) is found. For example, prefix matching, suffix matching, regular expression matching, and other matching methods can be used to match the feature information of the service instance matching the business request with the nodes in the tree structure, but this is not limited to these methods.
[0057] Specifically, the preset routing rules associated with the target node include feature information of the service instance that matches the business request.
[0058] Specifically, the preset routing rules also include a call chain that routes business requests to a matching service instance (or the service instance group to which the matching service instance belongs). Therefore, the call chain contained in the second target routing rule can be used as the target call chain.
[0059] Understandably, tree-structured matching algorithms can quickly locate and select appropriate target call paths based on the feature information of service instances that match business requests, thereby improving the routing efficiency of business requests.
[0060] In some embodiments, the plurality of service instances include a fallback service instance. The method further includes: if it is determined that the target call link has failed based on the characteristic information of the target service instance using preset routing rules, then the target business request is forwarded 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 backup service instance through the load balancer of the backup service instance.
[0062] Specifically, the fallback service instance is the default service instance used when no matching service instance is found for the business request. For example, the fallback service instance can be marked as "default".
[0063] Specifically, the fallback call chain is the default call chain, used to route business requests to a fallback service instance when no matching service instance is found.
[0064] Understandably, by setting up a fallback service instance and a fallback call chain, when there are no specific routing rules to select the service instance that matches the business request, the business request can be quickly switched to the default service instance (i.e., the fallback service instance), thus reducing routing failures.
[0065] In some embodiments, forwarding a target service request to a target service instance includes: detecting whether the target service request meets preset routing conditions and obtaining a detection result;
[0066] If the target service request meets the preset routing conditions, the target service request will be routed to the target service instance;
[0067] If the target business request does not meet the preset routing conditions, the error handling process for the target business request will be triggered.
[0068] Specifically, preset routing conditions may include security detection (such as malicious request detection), content detection (such as illegal character detection, detection of whether the request exceeds the request size threshold, detection of whether the request format conforms to the expected format), rate limiting and speed limiting detection, etc., but are not limited to these.
[0069] Specifically, if a target service request meets the preset routing conditions, it is routed to the target service instance so that the target service instance can execute the request. It should be noted that if there is only one target service instance, the service request will be routed to that instance. However, if multiple matching target service instances exist (these instances are identical or belong to the same service instance group), a load balancing strategy can be used to select one. This strategy can include round-robin algorithms, least connections algorithms, or weighted load balancing algorithms (such as...). Figure 2 (as shown), but not limited to this.
[0070] Specifically, if the target business request does not meet the preset routing conditions, an error handling process for the target business request is triggered, and the target business 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 instance will process the target service request.
[0072] Understandably, by performing pre-defined routing condition checks before forwarding business requests to matching service instances, the load balancer can provide a protective barrier to ensure the validity and security of business requests, thereby optimizing the performance 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 monitoring results, and feeding back the monitoring results to the gateway component.
[0074] Specifically, the monitoring component's functions include, but are not limited to, performance monitoring, health status monitoring, fault detection and recovery, fault tracing and traffic analysis, log recording and analysis, distribution and execution results of business requests, call chain tracing, and analysis of similar routing rules and business request forwarding mechanisms to detect infringement and / or issue alarms and notifications. For example, the monitoring component can employ tools such as Prometheus or Grafana (e.g.,...). Figure 2 As shown, it records metrics such as the call path, latency, and error rate of business requests in real time. Of course, it can also provide a user-friendly visualization interface and alarm functions. For example, it can trigger an alarm notification when a business request does not meet the preset routing conditions, and it can also display a user-friendly error page to explain why the business request was rejected and provide possible solutions or contact information.
[0075] Understandably, by setting up monitoring components, the status of services can be comprehensively monitored, problems can be detected in a timely manner, and the reliability and performance of the gateway system can be improved.
[0076] In some embodiments, security authentication and data encryption are performed through the gateway system.
[0077] Understandably, adding security authentication and data encryption features can significantly improve the security and data protection capabilities of a gateway system. These mechanisms typically include, but are not limited to, authentication, authorization, token management, transport layer encryption, data encryption, and key management. In this way, data and communication security can be effectively protected.
[0078] In some embodiments, the method further includes: setting tag information for each service instance based on the service performance of the service instance, wherein the service performance includes hardware resources and service quality, and in a plurality of service instances, the tag information of a portion of the service instances is critical traffic, the tag information of another portion of the service instances is normal traffic, and the tag information of the remaining portion of the service instances is test traffic, wherein the service performance of the service instance with the tag information of critical traffic is higher than that of the service instance with the tag information of normal traffic, and the service performance of the service instance with the tag information of normal traffic is higher than that of the service instance with the tag information of test traffic.
[0079] Specifically, hardware resource metrics may include, but are not limited to, the number and frequency of processor cores, and / or memory capacity. Service quality metrics may include, but are not limited to, response time, throughput, resource utilization, error rate, latency, etc.
[0080] Specifically, the performance of services can be expressed in the form of scores or ratings. For example, after obtaining the hardware resources and service quality indicators of a service instance, the service performance of the service instance can be scored or rated based on these indicators, but this is not the only option.
[0081] Understandably, in the domain of business requests, requests can be categorized into critical traffic, normal traffic, and test traffic based on their importance, priority, and purpose. Critical traffic refers to traffic essential to business operations, typically involving core business functions and services. Normal traffic refers to traffic generated during daily business operations, which has some impact on business operations but is less important than critical traffic. Test traffic refers to traffic used for system testing, verification, and debugging, and does not directly affect actual business operations. By configuring critical traffic labels for service instances with the highest service performance, normal traffic labels for service instances with relatively high service performance, and test traffic labels for service instances with average service performance, the gateway system can optimize resource allocation and ensure system stability and security when processing business requests. In summary, the routing methods in related technologies have some limitations, such as a lack of flexible routing rule mechanisms, an inability to precisely route business requests to specific service versions based on service instance labels, and a lack of practical interfaces and algorithms for easy integration and extension. However, in this embodiment of the disclosure, based on a service mesh architecture, business requests are finely forwarded to target service instances by setting preset routing rules in the gateway component. This method, by combining the tag information and version information of the service instance, makes the routing and forwarding mechanism more flexible and accurate, thereby adapting to various complex business needs. Furthermore, it allows for real-time monitoring and feedback of the routing process of business requests. This enhances traffic control precision, enabling the gateway system to manage traffic more granularly, improves the stability and scalability of the gateway system, reduces service instance failure rates, and increases user satisfaction.
[0082] The routing process for service requests provided in this disclosure will be described in detail below with reference to a specific example. For example... Figure 4As shown, the gateway component receives a service request and determines the tag information and version information of the service instance matching the service request based on preset routing rules. The routing service engine uses a tree-structure matching algorithm to determine the preset routing rules that match the tag information and version information of the service instance matching the service request. Based on these matching preset routing rules, the service request is forwarded to the load balancer corresponding to the service instance matching the service request. When the service request meets the preset routing requirements, the load balancer forwards the service request to a matching service instance. Furthermore, the monitoring component can monitor the routing process of the service request. Therefore, this disclosed example can utilize the preset routing rules set in the gateway component to route service requests to service instances of specific versions based on the tag information and version information of a service subset (including at least one service instance, with service instances within the same service subset being identical), making traffic control more flexible and precise.
[0083] Figure 5 This is a schematic diagram of a service request routing device provided in an embodiment of this disclosure. This service request routing device can be understood as the aforementioned electronic device or a functional module within the aforementioned electronic device. For example... Figure 5 As shown, the routing device 500 for this service request includes:
[0084] The first determining module 510 is used to determine, through the gateway component, the characteristic information of the target service instance matching the received target service request from the plurality of service instances according to the preset routing rules, wherein the preset routing rules include the characteristic information of the service instance matching the service request, and the characteristic information of the service instance includes the 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 feature information of the target service instance through the routing rule engine and according to the preset routing rules, 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 manage the routing of the target service request through the load balancer corresponding to the target service instance.
[0087] Optionally, the first determining module 510 is specifically used to parse the target service request to obtain the feature information of the client;
[0088] Determine a first target routing rule that matches the client's feature information from the preset routing rules;
[0089] The feature information of the service instance contained in the first target routing rule is used as the feature 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 feature information of the target service instance according to the preset routing rules. Specifically, the first determining submodule is used to use a tree structure matching algorithm to find the target node that matches the feature information of the target service instance.
[0091] A second target routing rule matching the feature information of the target service instance is determined 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 plurality of service instances includes a fallback service instance, and the device further includes:
[0094] The first determining module 510 is used to forward the target service request to the load balancer of the fallback service instance according to the fallback call link by the routing rule engine if the target call link is determined to be unsuccessful based on the feature information of the target service instance using the preset routing rules.
[0095] The first routing module 530 is also used to manage the routing of the target service request through the load balancer of the fallback service instance.
[0096] Optionally, the first routing module 530 includes:
[0097] The first detection submodule is used to detect whether the target service request meets the preset routing conditions and obtain the detection result;
[0098] The first routing submodule is used to manage the routing of the target service request based on the detection results.
[0099] The first routing submodule is specifically used to route the target service request to the target service instance if the target service request meets the preset routing conditions;
[0100] If the target service request does not meet the preset routing conditions, an error handling process for the target service request is triggered.
[0101] The device also includes:
[0102] The first processing module is used to route the target service request to the target service instance and process the target service request through 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, obtain monitoring results, and feed back the monitoring results to the gateway component.
[0105] The apparatus provided in this embodiment can execute the methods of any of the above embodiments, and its execution method and beneficial effects are similar, so they will not be described again here.
[0106] This disclosure also provides an electronic device, which includes: a memory storing a computer program; and a processor for executing the computer program, wherein when the computer program is executed by the processor, it can implement the methods of any of the above embodiments.
[0107] Example, Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 6 The diagram illustrates a structural schematic suitable for implementing the electronic device 600 in the embodiments of this disclosure. The electronic device 600 in the embodiments of this disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0108] like Figure 6 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0109] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0110] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via 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, it performs the functions defined in the methods of embodiments of this disclosure.
[0111] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0112] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0113] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0114] The aforementioned computer-readable medium carries one or more programs. When the electronic device executes the aforementioned one or more programs, the electronic device causes the following to occur: Through a gateway component, based on preset routing rules, determine the characteristic information of the target service instance matching the received target service request from multiple service instances, wherein the preset routing rules include the characteristic information of the service instance matching the service request, and the characteristic information of the service instance includes the service instance's tag information and version information; Through a routing rule engine, based on the preset routing rules, determine the target call chain corresponding to the characteristic information of the target service instance, and forward the target service request to the load balancer corresponding to the target service instance according to the target call chain; Through the load balancer corresponding to the target service instance, perform routing management on the target service request.
[0115] Computer program code for performing the operations of this disclosure can 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, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone 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 remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0116] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0117] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.
[0118] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0119] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0120] This disclosure also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the methods of any of the above embodiments. The execution method and beneficial effects are similar, and will not be described again here.
[0121] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0122] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily 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 this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method of routing a service request, characterized by, The method is applied to a gateway system, the gateway system comprising a gateway component, a forwarding component and a plurality of service instances, and the method comprises: determining, by the gateway component, characteristic information of a target service instance matching a received target service request from the plurality of service instances according to a preset routing rule, wherein the preset routing rule comprises characteristic information of a service instance matching a service request, and the characteristic information of the service instance comprises tag information and version information of the service instance; forwarding, by the forwarding component, the target service request to the target service instance according to the characteristic information of the target service instance; The method further comprises: for each service instance, setting tag information of the service instance according to service performance of the service instance, wherein the service performance comprises hardware resources and service quality, tag information of a part of the service instances is critical traffic, tag information of another part of the service instances is ordinary traffic, and tag information of the remaining part of the service instances is test traffic, the service performance of the service instance with the tag information of critical traffic is higher than the service performance of the service instance with the tag information of ordinary traffic, the service performance of the service instance with the tag information of ordinary traffic is higher than the service performance of the service instance with the tag information of test traffic, indicators of the hardware resources comprise core number, frequency and / or memory capacity of a processor, and indicators of the service quality comprise response time, throughput, resource utilization, error rate and / or delay.
2. The method of claim 1, wherein, The method further comprises: for each service instance, setting tag information of the service instance according to service performance of the service instance, wherein the service performance comprises hardware resources and service quality, tag information of a part of the service instances is critical traffic, tag information of another part of the service instances is ordinary traffic, and tag information of the remaining part of the service instances is test traffic, the service performance of the service instance with the tag information of critical traffic is higher than the service performance of the service instance with the tag information of ordinary traffic, the service performance of the service instance with the tag information of ordinary traffic is higher than the service performance of the service instance with the tag information of test traffic, indicators of the hardware resources comprise core number, frequency and / or memory capacity of a processor, and indicators of the service quality comprise response time, throughput, resource utilization, error rate and / or delay. The method further comprises: for each service instance, setting tag information of the service instance according to service performance of the service instance, wherein the service performance comprises hardware resources and service quality, tag information of a part of the service instances is critical traffic, tag information of another part of the service instances is ordinary traffic, and tag information of the remaining part of the service instances is test traffic, the service performance of the service instance with the tag information of critical traffic is higher than the service performance of the service instance with the tag information of ordinary traffic, the service performance of the service instance with the tag information of ordinary traffic is higher than the service performance of the service instance with the tag information of test traffic, indicators of the hardware resources comprise core number, frequency and / or memory capacity of a processor, and indicators of the service quality comprise response time, throughput, resource utilization, error rate and / or delay. The plurality of service instances are divided into a plurality of service instance groups, the characteristic information of the service instances in the same service instance group is the same, the forwarding component comprises a routing rule engine and a load balancer of each service instance group, and the forwarding of the target service request to the target service instance according to the characteristic information of the target service instance comprises: determining, by the routing rule engine, a target calling link corresponding to the characteristic information of the target service instance according to the preset routing rule, and forwarding the target service request to a load balancer corresponding to a target service instance group according to the target calling link, wherein the target service instance group is a service instance group to which the target service instance belongs; 3. The method of claim 1, wherein, forwarding, by the load balancer of the target service instance group, the target service request to the target service instance. The determination of the target calling link corresponding to the characteristic information of the target service instance according to the preset routing rule comprises: 4. The method of claim 3, wherein, The tree structure matching algorithm is adopted to search for a target node matching the characteristic information of the target service instance, wherein the target node includes the characteristic information of the target service instance; A second target routing rule matching the characteristic information of the target service instance is determined from preset routing rules associated with the target node; The calling link in the second target routing rule is taken as the target calling link.
5. The method of claim 3, wherein, The plurality of service instances include a bottom service instance, and the method further comprises: If the target calling link is failed to be determined according to the characteristic information of the target service instance by using the preset routing rules, the target service request is forwarded to a load balancer of the bottom service instance according to a bottom calling link by the routing rule engine; The target service request is forwarded to the bottom service instance by the load balancer of the bottom service instance.
6. The method of claim 3, wherein, The target service request is forwarded to the target service instance, comprising: A detection result is obtained by detecting whether the target service request meets preset routing conditions, wherein the preset routing conditions include at least one of the following: passing security detection, passing content detection, passing flow limiting and rate limiting detection; If the target service request meets the preset routing conditions, the target service request is routed to the target service instance; If the target service request does not meet the preset routing conditions, an error processing procedure for the target service request is triggered.
7. The method of claim 1, wherein, The gateway system further comprises a monitoring component, and the method further comprises: The routing process of the target service request is monitored by the monitoring component to obtain a monitoring result, and the monitoring result is fed back to the gateway component.
8. An apparatus for routing a service request, characterized by The device is applied to a gateway system, and the gateway system comprises a gateway component, a forwarding component and a plurality of service instances, wherein the device comprises: A first determination module is configured to determine, by the gateway component, characteristic information of a target service instance matching a target service request received from a plurality of service instances according to preset routing rules, wherein the preset routing rules include characteristic information of service instances matching service requests, and the characteristic information of the service instances includes tag information and version information of the service instances; A first forwarding module is configured to forward, by the forwarding component, the target service request to the target service instance according to the characteristic information of the target service instance. The device is also used to set label information of each service instance according to service performance of the service instance, wherein the service performance includes hardware resources and service quality, label information of part of the service instances is critical traffic, label information of another part of the service instances is ordinary traffic, label information of the remaining part of the service instances is test traffic, service performance of the service instance with label information of critical traffic is higher than service performance of the service instance with label information of ordinary traffic, service performance of the service instance with label information of ordinary traffic is higher than service performance of the service instance with label information of test traffic, indicators of the hardware resources include core number, frequency and / or memory capacity of a processor, and indicators of the service quality include response time, throughput, resource utilization, error rate and / or delay.
9. An electronic device, comprising: comprising: a processor and a memory, wherein the memory has stored therein a computer program which, when executed by the processor, causes the processor to perform the method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium has stored therein a computer program which, when executed by a processor, implements the method of any one of claims 1-7.
Citation Information
Patent Citations
Service instance determination method and device, storage medium and electronic equipment
CN110837424A