Service calling method, device, computer equipment and storage medium
By identifying the service status of the first service node in the service request routing and forwarding the request to the backup service node when it is in the fuse state, the problem of single selection method of service nodes in the prior art is solved, and the efficiency of service request processing is improved and usability.
Patent Information
- Application Number
- CN202211096467.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-08
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2042-09-08
Smart Images

Figure CN116319239B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communication technology, and in particular to a service calling method, apparatus, computer equipment and storage medium. Background Art
[0002] With the rapid development of Internet technology, the application scope of distributed systems is becoming wider and wider.
[0003] In related technologies, when a distributed system receives a service request and routes the service request, it can locate the service node that processes the service request based on the routing identifier in the request header information of the service request, so as to send the service request to the service node for processing.
[0004] However, in the above-mentioned related technologies, the method of indicating the service node corresponding to the service request through the routing identifier makes the service node selection method relatively simple and cannot adapt to the scenario of abnormal backend service nodes, thereby making the processing efficiency of service requests low and the processing effect poor. Summary of the invention
[0005] The embodiments of the present application provide a service calling method, apparatus, computer equipment and storage medium, which can avoid service anomalies caused by too many service requests, reduce the impact of back-end service node anomalies on the processing of service requests, improve the processing efficiency and processing effect of service requests, and achieve the purpose of long-term service availability. The technical solution is as follows.
[0006] In one aspect, a service invocation method is provided, the method comprising:
[0007] Receive a service request sent by a front-end business system; the service request includes request header information;
[0008] Determining a first service node for processing the service request based on the request header information of the service request;
[0009] Obtaining service status information of the first service node;
[0010] When the service status information indicates that the first service node is in a blown state, obtaining a node identifier of a second service node; the second service node is a backup service node of the first service node;
[0011] Based on the node identifier of the second service node, the service request is forwarded to the second service node.
[0012] In another aspect, a service invocation device is provided, the device comprising:
[0013] A request receiving module, used to receive a service request sent by a front-end business system; the service request includes request header information;
[0014] A node determination module, configured to determine a first service node for processing the service request based on the request header information of the service request;
[0015] An information acquisition module, used to acquire the service status information of the first service node;
[0016] an identification acquisition module, configured to acquire a node identification of a second service node when the service status information indicates that the first service node is in a fuse state; the second service node is a backup service node of the first service node;
[0017] A request sending module is used to forward the service request to the second service node based on the node identifier of the second service node.
[0018] In a possible implementation, the service status information includes a fuse identifier;
[0019] The identifier acquisition module is configured to acquire the node identifier of the second service node when the fuse identifier indicates that the first service node is in the blown state.
[0020] In a possible implementation, the fuse state includes a first fuse state and / or a second fuse state, wherein the first fuse state is a fuse state set based on the first service node's own situation, and the second fuse state is a fuse state set based on a first external command.
[0021] In a possible implementation, the service status information further includes a current limiting identifier;
[0022] The device also includes:
[0023] A current limiting operation module, used to perform a current limiting operation on the service request when the fuse identifier indicates that the first service node is in a non-fuse state and the current limiting identifier indicates that the first service node is in a current limiting state; the current limiting operation refers to determining whether to send the service request to the first service node based on a first blocking rate of the first service node; the first blocking rate is determined based on the load condition of the first service node.
[0024] In a possible implementation, the current limiting state includes a first current limiting state and a second current limiting state, wherein the first current limiting state is a current limiting state set based on the first service node's own situation, and the second current limiting state is a current limiting state set based on a second external command.
[0025] In a possible implementation, the service status information further includes a current limiting identifier;
[0026] The identifier acquisition module is used to acquire the node identifier of the second service node when the fuse identifier indicates that the first service node is in a non-fuse state and the current limiting identifier indicates that the first service node is in a current limiting state;
[0027] The request sending module is used to forward the service request to the second service node based on the node identifier of the second service node.
[0028] In a possible implementation manner, the request sending module is configured to forward the service request to the second service node when the second service node is in a non-fuse state and a non-current limiting state.
[0029] In a possible implementation, the request sending module is used to send the service request to the first service node when the fuse identifier indicates that the first service node is in a non-fuse state and the current limiting identifier indicates that the first service node is in a non-current limiting state.
[0030] In a possible implementation, the request header information includes a service type identifier and a routing attribute; the service type identifier is used to indicate the service type of the first service node; and the routing attribute is used to indicate a route for determining the first service node.
[0031] On the other hand, a computer device is provided, the computer device comprising a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement the above-mentioned service calling method.
[0032] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the above-mentioned service calling method.
[0033] On the other hand, a computer program product is provided, the computer program product comprising at least one computer program, the computer program being loaded and executed by a processor to implement the service calling method provided in the above-mentioned various optional implementations.
[0034] The technical solution provided by this application may have the following beneficial effects:
[0035] The service calling method provided in the embodiment of the present application, after receiving the service request and locating the first service node that processes the service request based on the request header information of the service request, the computer device identifies the service status of the first service node, and after determining that the first service node does not have the service capability, forwards the service request to the backup service node of the first service node, that is, the second service node, so that the second service node processes the service request, thereby avoiding service anomalies caused by too many service requests, reducing the impact of back-end service node anomalies on the processing of service requests, improving the processing efficiency and processing effect of service requests, and achieving the purpose of long-term service availability.
[0036] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0038] Figure 1 A schematic diagram showing a service call corresponding to a service call method provided by an exemplary embodiment of the present application is shown;
[0039] Figure 2 A flow chart of a service calling method provided by an exemplary embodiment of the present application is shown;
[0040] Figure 3 A flowchart of another service calling method provided by an exemplary embodiment of the present application is shown;
[0041] Figure 4 A flowchart of another service calling method provided by an exemplary embodiment of the present application is shown;
[0042] Figure 5 A block diagram of a service invocation device provided by an exemplary embodiment of the present application is shown;
[0043] Figure 6 is a structural block diagram of a computer device according to an exemplary embodiment;
[0044] Figure 7 It is a structural block diagram of a computer device according to an exemplary embodiment. DETAILED DESCRIPTION
[0045] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0046] Figure 1 A schematic diagram of a service invocation system corresponding to a service invocation method provided by an exemplary embodiment of the present application is shown. The service invocation system may be a distributed system, and the service invocation system may include a scheduling center 110 and at least two backend service nodes 120 .
[0047] Among them, the dispatch center 110 can establish a communication connection with the front-end business system to receive the service request sent by the front-end business system, and after receiving the service request sent by the front-end business system, determine the back-end service node corresponding to the service request based on the request header information of the service request, and when it is obtained that the service status of the back-end service node is in a fuse state, obtain the backup service node of the back-end service node, and forward the service request to the backup service node of the back-end service node, so that the backup service node processes the service request.
[0048] In an embodiment of the present application, the dispatch center 110 can be implemented as a server. In some scenarios, the dispatch center 110 can also be referred to as a central server; the dispatch center 110 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0049] The backend service node 120 can be implemented as a terminal or a server. When the backend service node 120 is implemented as a terminal, the backend service node can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc., but is not limited to this; when the backend service node 120 is implemented as a server, the backend service node 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This application does not limit the implementation form of the backend service node.
[0050] In the embodiment of the present application, the dispatch center 110 and each backend service node 120 can communicate through a wired network or a wireless network.
[0051] Figure 2 A flowchart of a service calling method provided by an exemplary embodiment of the present application is shown. The service calling method can be executed by a computer device, and the computer device can be implemented as follows Figure 1 The dispatch center 110 shown in FIG. Figure 2 As shown, the service calling method may include the following steps.
[0052] Step 210: Receive a service request sent by the front-end business system; the service request includes request header information.
[0053] In the embodiment of the present application, the request header information is information associated with routing and is used to indicate a backend service node that can process the service request.
[0054] Step 220: Determine a first service node for processing the service request based on the request header information of the service request.
[0055] The request header information may be included in a request header file of a service request, and the computer device may parse the request header file of the service request to obtain the request header information; after obtaining the request header information, a backend service node, i.e., a first service node, matching the request header information is obtained from a local memory based on the request header information.
[0056] Step 230: Obtain service status information of the first service node.
[0057] The service status information of the first service node is used to indicate the service status of the first service node; schematically, the service status of the first service node may include a fuse status, a current limiting status, and a normal working status.
[0058] Step 240: When the service status information indicates that the first service node is in a blown state, obtain a node identifier of a second service node; the second service node is a backup service node of the first service node.
[0059] Among them, the fuse state means that when the downstream service responds slowly or fails due to excessive access pressure, the upstream service temporarily cuts off the call to the downstream service in order to protect the overall availability of the system; in an embodiment of the present application, the fuse state corresponds to when the back-end service node (such as the first service node) responds slowly or fails due to excessive call pressure, the computer device temporarily cuts off the service request to the back-end service node.
[0060] Optionally, the backup service node of the first service node may be pre-configured; the first service node may have multiple backup service nodes; the second service node may be one of the multiple backup service nodes of the first service node.
[0061] In a possible implementation, there are differences in calling priorities among the multiple backup service nodes of the first service node; the second service node may be a service node with the highest calling priority among the multiple backup service nodes; further, the second service node may be an available service node with the highest current calling priority among the multiple backup nodes. The available service node refers to a service node in a normal working state.
[0062] Step 250: forward the service request to the second service node based on the node identifier of the second service node.
[0063] After obtaining the node identifier of the second service node, the computer device can locate the second service node based on the node identifier of the second service node. By forwarding the service request to the second service node for processing, service request congestion caused by the first service node being blown can be avoided, thereby improving the processing efficiency of the service request.
[0064] To summarize, in the service calling method provided in the embodiment of the present application, after receiving a service request and locating the first service node that processes the service request based on the request header information of the service request, the computer device identifies the service status of the first service node, and after determining that the first service node does not have the service capability, forwards the service request to the backup service node of the first service node, i.e., the second service node, so that the second service node processes the service request, thereby avoiding service anomalies caused by too many service requests, reducing the impact of back-end service node anomalies on the processing of service requests, improving the processing efficiency and processing effect of service requests, and achieving the purpose of long-term service availability.
[0065] Figure 3A flowchart of another service calling method provided by an exemplary embodiment of the present application is shown. The service calling method can be executed by a computer device, and the computer device can be implemented as follows Figure 1 The dispatch center 110 shown in FIG. Figure 3 As shown, the service calling method may include the following steps.
[0066] Step 310: Receive a service request sent by the front-end business system; the service request includes request header information.
[0067] Optionally, the front-end business system sends the service request to the computer device through the bus, and correspondingly, the computer device receives the service request sent by the front-end business system to the bus.
[0068] In an embodiment of the present application, the request header information includes a service type identifier and a routing attribute; the service type identifier is used to indicate the service type of the first service node; and the routing attribute is used to indicate a route for determining the first service node.
[0069] That is to say, in the embodiment of the present application, the routing rules can be defined by defining the request header attribute information of specific rules, that is, adding the routing attribute related to the determination of the route in the request header information; the routing attribute is used to define how to determine the specific backend service node. Schematically, the routing attribute can be used to indicate the backend service node that processes the service request based on the call priority of the backend service node; the way to determine the backend service node defined by the routing attribute can be set differently based on actual needs, and the present application does not limit this.
[0070] The service type identifier is used to indicate the service type of the backend service node that can process the service request.
[0071] Step 320: Determine a first service node for processing the service request based on the request header information of the service request.
[0072] The computer device parses the request header file of the received service request, obtains the request header information corresponding to the service request, and obtains the first service node based on the obtained request header information through the routing configuration information loaded in the local memory; the routing configuration information may include relevant information of each backend service node, such as the node identifier of each backend service node, the business type of each backend service node and the calling priority of each backend service node, etc.; schematically, the process of the computer device obtaining the first service node based on the obtained request header information can be implemented as follows:
[0073] Determine a first node set based on the service type identifier in the request header information; the first node set includes at least two backend service nodes, and the service types corresponding to the at least two backend service nodes are the same;
[0074] Based on the routing attribute, a first service node is determined from the first set of nodes.
[0075] Illustratively, if the routing attribute indicates that the first service node is determined in the order of calling priority, the computer device sorts at least two backend service nodes in the first node set in the order of calling priority of at least two backend service nodes, and determines the backend service node with the highest calling priority as the first service node.
[0076] Computer devices publish decentralized backend service nodes in a centralized manner through the definition of routing rules (i.e. routing attributes) for invocation by various front-end business systems that need to call backend services, to ensure that service requests can be routed to the corresponding backend service nodes.
[0077] Step 330: Obtain service status information of the first service node.
[0078] The service status information may be stored in a database of the computer device; schematically, the database of the computer device may be a Redis database; the computer device may obtain the service status information of the first service node from the database.
[0079] In an embodiment of the present application, the service status information includes a blown fuse flag, which is used to indicate whether the first service node is in a blown fuse state.
[0080] In an embodiment of the present application, the service status information may further include a current limiting identifier, where the current limiting identifier is used to indicate whether the first service node is in a current limiting state.
[0081] Among them, the current limiting state refers to protecting the system by limiting the number of service requests when facing an overload of requests, so that some requests can be responded to in a timely manner; in an embodiment of the present application, the current limiting state corresponds to when the back-end service node (such as the first service node) faces an overload of service requests, the computer device limits the number of service requests sent by the front-end business system to the back-end service node to protect the first service node.
[0082] The service status information may also indicate a second blocking rate when the first service node is in a blown state, and / or a first blocking rate when the first service node is in a current limiting state; wherein the values of the first blocking rate and the second blocking rate may be determined based on the load condition of the first service node.
[0083] Step 340: When the fuse identifier indicates that the first service node is in a blown state, obtain a node identifier of a second service node.
[0084] The second service node is a backup service node of the first service node; the node identifier of the second service node may be stored in a local memory.
[0085] The blown fuse state includes a first blown fuse state and / or a second blown fuse state, wherein the first blown fuse state is a blown fuse state set based on the first service node's own situation, and the second blown fuse state is a blown fuse state set based on the first external command.
[0086] The first fuse state can be called an automatic fuse state. Schematically, when the load quantity of the first service node reaches a first load quantity threshold, the computer device automatically switches the service state of the first service node to the fuse state; the second fuse state can be called a manual fuse state. Schematically, when relevant personnel determine that the load pressure of the first service node is large or the first service node has an abnormality, they perform relevant operations through the operation interface provided by the computer device to generate a first external command to switch the service state of the first service node to the fuse state.
[0087] Optionally, the determination priority of the second blown fuse state is higher than the determination priority of the first blown fuse state; that is, when determining whether the first service node is in the blown fuse state, the computer device may first determine whether the first service node is in the second blown fuse state; when the first service node is in the second blown fuse state, determine that the first service node is in the blown fuse state; when the first service node is not in the second blown fuse state, determine whether the first service node is in the first blown fuse state; when the first service node is in the first blown fuse state, determine that the first service node is in the blown fuse state; when the first service node is neither in the second blown fuse state nor in the first blown fuse state, determine that the first service node is in a non-blown fuse state and enter the current limiting processing link.
[0088] Optionally, the fuse identifier may include a first sub-fuse identifier and a second sub-fuse identifier, wherein the first sub-fuse identifier is used to indicate whether the first service node is in a first fuse state, and the second sub-fuse identifier is used to indicate whether the first service node is in a second fuse state; schematically, when the first service node is in the first fuse state, the first sub-fuse identifier is set to "1", and when the first service node is not in the first fuse state, the first sub-fuse identifier is set to "0"; when the first service node is in the second fuse state, the second sub-fuse identifier is set to "1", and when the second service node is not in the first fuse state, the second sub-fuse identifier is set to "0"; the above configuration method of the fuse identifier is schematic, and the present application does not limit it.
[0089] Optionally, when the computer device determines that the first service node is in a blown state but the second blocking rate is less than 100%, the service request sent by the front-end business system can be restricted according to the second blocking rate, and the processing result of the restricted request is returned to the front-end transaction system, and the first routing operation information of the service request is written into the operation information queue; the first routing operation information is used to indicate the log information of the processing process from receiving the service request to determining to restrict the service request.
[0090] That is to say, the computer device can determine whether to send the service request to the first service node according to the second blocking rate; if not, return the processing result of the service request to the front-end business system and asynchronously write the routing operation information, and the processing result indicates that the service request is restricted; if so, send the service request to the first service node.
[0091] In an illustrative manner, when the computer device determines that the first service node is in a fuse state, it can randomly intercept some of the received service requests according to the proportion indicated by the second blocking rate, or it can sort the service requests according to the order in which the service requests arrive, and intercept some of the service requests that are ranked later and correspond to the proportion indicated by the second blocking rate. If the current service request is randomly received, or the current service request belongs to some of the service requests that are ranked later and correspond to the proportion indicated by the second blocking rate, it is determined that the current service request is intercepted and not sent to the first service node.
[0092] When the second blocking rate is equal to 100%, it indicates that the first service node is unavailable. At this time, based on the failover strategy configured in the system, the node identifier of the backup service node of the first service node, ie, the node identifier of the second service node, can be obtained.
[0093] Step 350: forward the service request to the second service node based on the node identifier of the second service node.
[0094] Optionally, when the second service node is in a non-fuse state and a non-current limiting state, the service request is forwarded to the second service node.
[0095] That is to say, the second service node can be a backup service node of the first service node, which is in normal working condition and currently calls the service node with the highest priority; schematically, if the first service node has 3 backup service nodes, and the calling priorities from high to low are: backup service node 1, backup service node 2, backup service node 3; if when the first service node is in a blown state, backup service node 1 is in a blown state, and backup service node 2 and backup service node 3 are in normal working condition, then the second service node is backup service node 2.
[0096] Optionally, when the node identifier of the second service node is not obtained, a fuse operation is performed on the service request; the fuse operation refers to cutting off the call of the service request to the first service node.
[0097] Among them, the situations where the node identifier of the second service node is not obtained include: the first service node does not have a backup service node; or the backup service nodes of the first service node are all in a fuse and / or current limiting state. At this time, the service request cannot call the back-end service, and a fuse operation is performed on the service request, that is, the service request's call to the first service node is cut off.
[0098] Optionally, after performing a fuse operation on the service request, the method further includes:
[0099] The second routing operation information of the service request is written into the operation information queue, and the fuse information is returned to the front-end business system; wherein the second routing operation information refers to the log information of the processing process from receiving the service request to determining to perform the fuse operation on the service request; optionally, the second routing operation information is asynchronously written into the operation information queue, that is, the second routing operation information is not written into the operation information queue in real time when each processing step is implemented, but is written into the operation information queue after the processing of the service request is completed. By asynchronously writing the routing operation information, the thread occupancy when recording the routing operation information during the processing process is reduced, thereby improving the timeliness of the service request processing.
[0100] Step 360: When the fuse flag indicates that the first service node is in a non-fuse state and the current limiting flag indicates that the first service node is in a current limiting state, perform a current limiting operation on the service request.
[0101] The current limiting operation refers to determining whether to send the service request to the first service node based on a first blocking rate of the first service node; the first blocking rate is determined based on a load condition of the first service node.
[0102] In an illustrative manner, when the computer device determines that the first service node is in a current limiting state, it can randomly intercept some of the received service requests according to the proportion indicated by the first blocking rate, or it can sort the service requests in the order in which they arrive, and intercept some of the service requests that are ranked later and correspond to the proportion indicated by the first blocking rate. If the current service request is randomly received, or the current service request belongs to some of the service requests that are ranked later and correspond to the proportion indicated by the first blocking rate, it is determined that the current service request is intercepted and not sent to the first service node.
[0103] In an embodiment of the present application, the priority of determining the current limiting state is lower than the priority of determining the fuse state. That is to say, when determining the service state of the first service node, it is first determined whether the first service node is in the fuse state, and then it is determined whether the first service node is in the current limiting state.
[0104] Optionally, the current limiting state includes a first current limiting state and a second current limiting state, wherein the first current limiting state is a current limiting state set based on the first service node's own situation, and the second current limiting state is a current limiting state set based on a second external command.
[0105] The first current limiting state can be called an automatic current limiting state. Schematically, when the load quantity of the first service node reaches a second quantity threshold, the computer device automatically switches the service state of the first service node to the current limiting state; the second current limiting state can be called a manual current limiting state. Schematically, when relevant personnel determine that the load pressure of the first service node is large or the first service node has an abnormality, they perform relevant operations through the operation interface provided by the computer device to generate a second external command to switch the service state of the first service node to the current limiting state.
[0106] Optionally, the determination priority of the second current limiting state is higher than the determination priority of the first current limiting state; that is, when determining whether the first service node is in the current limiting state, the computer device may first determine whether the first service node is in the second current limiting state; when the first service node is in the second current limiting state, determine that the first service node is in the current limiting state; when the first service node is not in the second current limiting state, determine whether the first service node is in the first current limiting state; when the first service node is in the first current limiting state, determine that the first service node is in the current limiting state; when the first service node is neither in the second current limiting state nor in the first current limiting state, determine that the first service node is in a non-current limiting state and enter the next processing link.
[0107] Optionally, the current limiting identifier may include a first sub-current limiting identifier and a second sub-current limiting identifier, wherein the first sub-current limiting identifier is used to indicate whether the first service node is in a first current limiting state, and the second sub-current limiting identifier is used to indicate whether the first service node is in a second current limiting state; schematically, when the first service node is in the first current limiting state, the first sub-current limiting identifier is set to "1", and when the first service node is not in the first current limiting state, the first sub-current limiting identifier is set to "0"; when the first service node is in the second current limiting state, the second sub-current limiting identifier is set to "1", and when the second service node is not in the first current limiting state, the second sub-current limiting identifier is set to "0"; the above configuration method of the current limiting identifier is schematic, and the present application does not limit it.
[0108] Alternatively, in another possible implementation, when it is determined that the first service node is in a current limiting state, the service request may also be forwarded to the second service node to ensure timely processing of the service request. The process may be implemented as follows:
[0109] When the fuse identifier indicates that the first service node is in a non-fuse state, and the current limiting identifier indicates that the first service node is in a current limiting state, obtaining a node identifier of the second service node;
[0110] Based on the node identifier of the second service node, the service request is forwarded to the second service node.
[0111] This process may refer to the operation process of forwarding the service request to the second service node when the first service node is in the fuse state, which will not be repeated here.
[0112] Step 370: When the fuse flag indicates that the first service node is in a non-fuse state and the current limiting flag indicates that the first service node is in a non-current limiting state, send the service request to the first service node.
[0113] When the fuse identifier indicates that the first service node is in a non-fuse state and the current limiting identifier indicates that the first service node is in a non-current limiting state, it is determined that the first service node is in a normal working state. At this time, the computer device can send the service request to the first service node for processing.
[0114] In this process, the computer device can encapsulate the service request according to a preset request information data structure to obtain first encapsulated data. Schematically, the request information data structure can include request body information and routing attributes in the request header; the first encapsulated data is asynchronously transmitted to the request information queue; according to the routing attributes in the request header and the order of the service request in the request information queue, the service request is sent to the first service node.
[0115] Optionally, after adding the encapsulated data corresponding to the service request to the request information queue, the computer device may update the service status information of the first service node based on the change in the number of requests in the request information queue; for example, an increase in the number of requests in the request information queue indicates an increase in the number of service requests to be processed by the first service node, and the service status information of the first service request will change accordingly.
[0116] Optionally, when the computer device receives the service result returned by the first service node, it asynchronously writes the service result into a return result queue and returns the service result to the front-end business system.
[0117] Optionally, the computer device may encapsulate the service result returned by the first service node according to a preset response information data structure to obtain second encapsulated data; and asynchronously transmit the second encapsulated data to a return result queue.
[0118] Optionally, after asynchronously writing the service result into the return result queue, the computer device may update the service status information of the first service node based on the change in the number of service results in the return result queue. For example, if the number of service results in the return result queue increases, it means that the number of service requests to be processed by the first service node decreases, and the service status information of the first service request will change accordingly.
[0119] Furthermore, the computer device can also record the log of the entire routing processing process of the service request and record the additional data of routing the service request; in order to improve the timeliness of service request processing, the recording of relevant logs and the recording of additional data of routing the service request can be processed asynchronously compared to the request processing process.
[0120] To summarize, in the service calling method provided in the embodiment of the present application, after receiving a service request and locating the first service node that processes the service request based on the request header information of the service request, the computer device identifies the service status of the first service node, and after determining that the first service node does not have the service capability, forwards the service request to the backup service node of the first service node, i.e., the second service node, so that the second service node processes the service request, thereby avoiding service anomalies caused by too many service requests, reducing the impact of back-end service node anomalies on the processing of service requests, improving the processing efficiency and processing effect of service requests, and achieving the purpose of long-term service availability.
[0121] At the same time, by defining the business type identifier and routing information in the request header information of the service request, the computer device can quickly locate the backend service node corresponding to the service request based on the request header information. The method of locating the backend service node by the characteristics of the service request can improve the routing speed, the rationality of the routing and the overall processing efficiency;
[0122] When routing service requests, the service requests are routed in combination with the backend service status information and the corresponding blocking rate, making the routing process more reasonable and reducing the occurrence of backend service node abnormalities caused by too many routed service requests.
[0123] based on Figure 2 or Figure 3 The embodiment shown in the present application schematically provides an implementation process of a service call. Figure 4A flowchart of another service calling method provided by an exemplary embodiment of the present application is shown. The service calling method can be executed by a computer device, and the computer device can be implemented as follows Figure 1 The dispatch center 110 shown in FIG. Figure 4 As shown, the service calling method may include the following steps.
[0124] S401, receiving a service request.
[0125] S402, parsing the request header file of the service request to obtain request header information.
[0126] S403: Obtain the first service node from the local memory based on the request header information.
[0127] S404: Obtain service status information of the first service node from a database.
[0128] S405, determining whether the first service node is in a manual fuse state, if so, executing S407, otherwise, executing S406.
[0129] S406, determining whether the first service node is in an automatic fuse state, if so, executing S407, otherwise, executing S414.
[0130] S407: Obtain the node identifier of the second service node from the local memory.
[0131] S408, determine whether there is a second service node, if yes, execute S409, otherwise execute S411.
[0132] S409: Forward the service request to the second service node.
[0133] S410: Receive a first service result returned by a second service node.
[0134] S411, feeding back the first service result to the front-end business system.
[0135] S412, performing a fuse operation on the service request.
[0136] S413, feeding back the fuse information to the front-end business system.
[0137] S414, determining whether the first service node is in a manual current limiting state, if so, executing S416, otherwise, executing S415.
[0138] S415, determining whether the first service node is in an automatic current limiting state, if so, executing S416, otherwise, executing S418.
[0139] S416: Perform a flow limiting operation on the service request.
[0140] S417, feeding back the current limiting information to the front-end business system.
[0141] S418: Send the service request to the first service node.
[0142] S419: Receive the second service result returned by the first service node.
[0143] S420, feeding back the second service result to the front-end business system.
[0144] The relevant contents involved in the above steps can be referred to as 2 or Figure 3 The relevant description in the illustrated embodiment will not be repeated here.
[0145] In the process of the above-mentioned service call, after executing each operation on the service request, it involves the process of asynchronously writing the routing operation information of the service request into the operation message queue to record the processing process of the service request. For example, after S409, S412, and S416, it involves the process of asynchronously writing the routing operation information of the service request into the operation message queue. At the same time, in the process of the above-mentioned service call, it also involves the process of asynchronously writing the service request into the request message queue and asynchronously writing the service result of the service request into the return result queue. By asynchronously writing, the thread occupation of the write operation can be reduced, thereby improving the processing efficiency of the service request.
[0146] To summarize, in the service calling method provided in the embodiment of the present application, after receiving a service request and locating the first service node that processes the service request based on the request header information of the service request, the computer device identifies the service status of the first service node, and after determining that the first service node does not have the service capability, forwards the service request to the backup service node of the first service node, i.e., the second service node, so that the second service node processes the service request, thereby avoiding service anomalies caused by too many service requests, reducing the impact of back-end service node anomalies on the processing of service requests, improving the processing efficiency and processing effect of service requests, and achieving the purpose of long-term service availability.
[0147] Figure 5 A block diagram of a service invocation device provided by an exemplary embodiment of the present application is shown, and the device can be used to implement the following Figure 2 , Figure 3 or Figure 4 All or part of the steps in any embodiment; Figure 5 As shown, the service calling device includes:
[0148] The request receiving module 510 is used to receive a service request sent by the front-end business system; the service request includes request header information;
[0149] A node determination module 520, configured to determine a first service node for processing the service request based on the request header information of the service request;
[0150] An information acquisition module 530 is used to acquire service status information of the first service node;
[0151] The identification acquisition module 540 is used to acquire the node identification of the second service node when the service status information indicates that the first service node is in a fuse state; the second service node is a backup service node of the first service node;
[0152] The request sending module 550 is configured to forward the service request to the second service node based on the node identifier of the second service node.
[0153] In a possible implementation, the service status information includes a fuse identifier;
[0154] The identifier acquisition module 540 is configured to acquire the node identifier of the second service node when the fuse identifier indicates that the first service node is in the blown state.
[0155] In a possible implementation, the fuse state includes a first fuse state and / or a second fuse state, wherein the first fuse state is a fuse state set based on the first service node's own situation, and the second fuse state is a fuse state set based on a first external command.
[0156] In a possible implementation, the service status information further includes a current limiting identifier;
[0157] The device also includes:
[0158] A current limiting operation module, used to perform a current limiting operation on the service request when the fuse identifier indicates that the first service node is in a non-fuse state and the current limiting identifier indicates that the first service node is in a current limiting state; the current limiting operation refers to determining whether to send the service request to the first service node based on a first blocking rate of the first service node; the first blocking rate is determined based on the load condition of the first service node.
[0159] In a possible implementation, the current limiting state includes a first current limiting state and a second current limiting state, wherein the first current limiting state is a current limiting state set based on the first service node's own situation, and the second current limiting state is a current limiting state set based on a second external command.
[0160] In a possible implementation, the service status information further includes a current limiting identifier;
[0161] The identifier acquisition module 540 is used to acquire the node identifier of the second service node when the fuse identifier indicates that the first service node is in a non-fuse state and the current limiting identifier indicates that the first service node is in a current limiting state;
[0162] The request sending module 550 is configured to forward the service request to the second service node based on the node identifier of the second service node.
[0163] In a possible implementation, the request sending module 550 is configured to forward the service request to the second service node when the second service node is in a non-fuse state and a non-current limiting state.
[0164] In a possible implementation, the request sending module 550 is used to send the service request to the first service node when the fuse identifier indicates that the first service node is in a non-fuse state and the current limiting identifier indicates that the first service node is in a non-current limiting state.
[0165] In a possible implementation, the request header information includes a service type identifier and a routing attribute; the service type identifier is used to indicate the service type of the first service node; and the routing attribute is used to indicate a route for determining the first service node.
[0166] To summarize, the service calling device provided in the embodiment of the present application, after receiving a service request and locating the first service node that processes the service request based on the request header information of the service request, the computer device identifies the service status of the first service node, and after determining that the first service node does not have the service capability, forwards the service request to the backup service node of the first service node, that is, the second service node, so that the second service node processes the service request, thereby avoiding service anomalies caused by too many service requests, reducing the impact of back-end service node anomalies on the processing of service requests, improving the processing efficiency and processing effect of service requests, and achieving the purpose of long-term service availability.
[0167] Figure 6The structural block diagram of a computer device 600 shown in an exemplary embodiment of the present application is shown. The computer device can be implemented as a call center or a back-end service node in the above-mentioned scheme of the present application. The computer device 600 includes a central processing unit (CPU) 601, a system memory 604 including a random access memory (RAM) 602 and a read-only memory (ROM) 603, and a system bus 605 connecting the system memory 604 and the central processing unit 601. The computer device 600 also includes a large-capacity storage device 606 for storing an operating system 609, a client 610 and other program modules 611.
[0168] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read Only Memory (EPROM), Electronically-Erasable Programmable Read-Only Memory (EEPROM) flash memory or other solid-state storage technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage medium is not limited to the above. The above-mentioned system memory 604 and mass storage device 606 can be collectively referred to as memory.
[0169] According to various embodiments of the present disclosure, the computer device 600 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 600 can be connected to the network 608 through the network interface unit 607 connected to the system bus 605, or the network interface unit 607 can be used to connect to other types of networks or remote computer systems (not shown).
[0170] The memory also includes at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is stored in the memory. The central processing unit 601 implements all or part of the steps in the service calling method shown in the above-mentioned embodiments by executing the at least one instruction, at least one program, code set or instruction set.
[0171] Figure 7 The following is a block diagram of a computer device 700 according to an exemplary embodiment of the present application. The computer device 700 may be implemented as the above-mentioned backend service node, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, etc. The computer device 700 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal, or other names.
[0172] Typically, the computer device 700 includes a processor 701 and a memory 702 .
[0173] The processor 701 may include one or more processing cores, such as a 4-core processor, a 7-core processor, etc. The processor 701 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 701 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 701 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 701 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0174] The memory 702 may include one or more computer-readable storage media, which may be non-transitory. The memory 702 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 702 is used to store at least one instruction, which is used to be executed by the processor 701 to implement all or part of the steps in the service call method shown in the method embodiment of the present application.
[0175] In some embodiments, the computer device 700 may further optionally include: a peripheral device interface 703 and at least one peripheral device. The processor 701, the memory 702 and the peripheral device interface 703 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 703 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 704, a display screen 705, a camera assembly 706, an audio circuit 707 and a power supply 708.
[0176] In some embodiments, the computer device 700 further includes one or more sensors 709 , including but not limited to: an acceleration sensor 710 , a gyroscope sensor 711 , a pressure sensor 712 , an optical sensor 713 , and a proximity sensor 714 .
[0177] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation on the computer device 700, and the computer device 700 may include more or less components than shown in the figure, or combine some components, or adopt a different arrangement of components.
[0178] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one computer program is stored, and the computer program is loaded and executed by a processor to implement all or part of the steps in the above service calling method. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0179] In an exemplary embodiment, a computer program product is also provided, the computer program product comprising at least one computer program, the computer program being loaded and executed by a processor Figure 2 , Figure 3 ,or Figure 4All or part of the steps of the service calling method shown in any embodiment.
[0180] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.
[0181] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A service calling method, characterized in that: The method comprises: Receive a service request sent by a front-end business system; the service request includes request header information; Determining a first service node for processing the service request based on the request header information of the service request; Obtaining service status information of the first service node; When the service status information indicates that the first service node is in a blown state, obtaining a node identifier of a second service node; the second service node is a backup service node of the first service node; forwarding the service request to the second service node based on the node identifier of the second service node; The service status information includes a fuse mark; When the service status information indicates that the first service node is in a fuse state, acquiring the node identifier of the second service node includes: When the blown fuse identifier indicates that the first service node is in the blown fuse state, acquiring a node identifier of the second service node; The request header information includes a service type identifier and a routing attribute; the service type identifier is used to indicate the service type of the first service node; the routing attribute is used to indicate the determination of the first service node; The determining, based on the request header information of the service request, a first service node for processing the service request comprises: Determine a first node set based on the service type identifier in the request header information, wherein the first node set includes at least two backend service nodes, and the service types corresponding to the at least two backend service nodes are the same; Determining a first service node from the first set of nodes based on the routing attribute; The routing attribute is used to indicate the backend service node that processes the service request based on the calling priority of the backend service node. The determining the first service node from the first node set based on the routing attribute includes: At least two backend service nodes in the first node set are sorted according to their calling priority order, and the backend service node with the highest calling priority is determined as the first service node.
2. The method according to claim 1, characterized in that The fuse state includes a first fuse state and / or a second fuse state, wherein the first fuse state is a fuse state set based on the first service node's own situation, and the second fuse state is a fuse state set based on a first external command.
3. The method according to claim 1, characterized in that: The service status information also includes a current limiting identifier; The method further comprises: When the fuse identifier indicates that the first service node is in a non-fuse state, and the current limiting identifier indicates that the first service node is in a current limiting state, a current limiting operation is performed on the service request; the current limiting operation refers to determining whether to send the service request to the first service node based on a first blocking rate of the first service node; the first blocking rate is determined based on the load condition of the first service node.
4. The method according to claim 3, characterized in that The current limiting state includes a first current limiting state and a second current limiting state, wherein the first current limiting state is a current limiting state set based on the first service node's own situation, and the second current limiting state is a current limiting state set based on a second external command.
5. The method according to claim 1, characterized in that The service status information also includes a current limiting identifier; and the method further includes: When the fuse identifier indicates that the first service node is in a non-fuse state, and the current limiting identifier indicates that the first service node is in a current limiting state, acquiring a node identifier of the second service node; Based on the node identifier of the second service node, the service request is forwarded to the second service node.
6. The method according to any one of claims 1 to 5, wherein forwarding the service request to the second service node comprises: When the second service node is in a non-fuse state and a non-current limiting state, the service request is forwarded to the second service node.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In the case where the node identifier of the second service node is not obtained, a fuse operation is performed on the service request; the fuse operation refers to cutting off the call of the service request to the first service node.
8. The method according to claim 3, characterized in that: The method further comprises: When the fuse flag indicates that the first service node is in a non-fuse state, and the current limiting flag indicates that the first service node is in a non-current limiting state, the service request is sent to the first service node.
9. A service calling device, characterized in that: The device comprises: A request receiving module, used to receive a service request sent by a front-end business system; the service request includes request header information; A node determination module, configured to determine a first service node for processing the service request based on the request header information of the service request; An information acquisition module, used to acquire the service status information of the first service node; an identification acquisition module, configured to acquire a node identification of a second service node when the service status information indicates that the first service node is in a fuse state; the second service node is a backup service node of the first service node; a request sending module, configured to forward the service request to the second service node based on the node identifier of the second service node; The service status information includes a fuse mark; The information acquisition module is specifically configured to acquire a node identifier of the second service node when the fuse identifier indicates that the first service node is in the fuse state; The request header information includes a service type identifier and a routing attribute; the service type identifier is used to indicate the service type of the first service node; the routing attribute is used to indicate the determination of the first service node; The node determination module is specifically configured to determine a first node set based on a service type identifier in the request header information, wherein the first node set includes at least two backend service nodes, and the service types corresponding to the at least two backend service nodes are the same; Determining a first service node from the first set of nodes based on the routing attribute; The routing attribute is used to indicate the backend service node that processes the service request based on the calling priority of the backend service node; The node determination module is further specifically used to sort at least two backend service nodes in the first node set according to their calling priority order, and determine the backend service node with the highest calling priority as the first service node.
10. A computer device, characterized in that: The computer device includes a processor and a memory, the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the service calling method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the computer program is loaded and executed by a processor to implement the service calling method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Automatic fusing processing method, device and system for service exception
CN113590422A
Service access optimization method and device, equipment and medium
CN113704000A