Service call processing method and device
By monitoring the server status and generating proxy detection performance indicators, production accidents caused by frequent modifications of service interfaces by service providers are resolved, rapid switching and business continuity in the event of server failures are achieved, and the high availability and maintainability of the system are improved.
Patent Information
- Application Number
- CN202110063240.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-18
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2041-01-18
AI Technical Summary
In the existing technology, service providers frequently modify service interfaces, leading to online production accidents, and rapid rollback and log viewing methods are time-consuming and affect business continuity.
By monitoring the server status, the proxy detection performance indicators are generated. If there is an abnormality, a remote server is selected from Zookeeper to implement the service call to ensure high availability.
It enables timely switching to a normal server when a server fails, reducing business impact and improving the system's high availability and maintainability.
Smart Images

Figure CN113778637B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of information processing, and in particular to a service call processing method and device. Background Art
[0002] In related technologies, service providers frequently need to modify service implementations to meet evolving needs due to changing requirements or increased business volume. Due to frequent modifications and limited test data, the modified service interfaces often lead to production failures. In such cases, the typical approach is to: 1) quickly roll back to the previous version; 2) identify and fix the issue by reviewing online logs before releasing the service to production. Summary of the Invention
[0003] Through research, the inventors found that the solutions adopted by the relevant technologies take a certain amount of time, and during this period of time, the relevant businesses will continue to be affected, thereby causing the impact of the business anomaly to be expanded.
[0004] Accordingly, the present disclosure provides a service call processing solution that can promptly transfer service calls to a server providing normal services when a server fails.
[0005] According to the first aspect of the embodiment of the present disclosure, a service call processing method is provided, including: monitoring the working status of the current server used for service call; when the working status of the current server is abnormal, deleting the interface role actor instance path of the current server from the distributed service framework zookeeper; generating a proxy for the current calling service implementation class; detecting the performance index of the current server through the proxy; judging whether the performance index of the current server is less than a preset performance index threshold; if the performance index of the current server is less than the preset performance index threshold, selecting an interface actor instance path of a remote server from zookeeper, and implementing the service call through the interface implementation class of the remote server.
[0006] In some embodiments, implementing a service call through the interface implementation class of the remote server includes: obtaining a corresponding remote interface actor reference according to the interface actor instance path of the remote server; sending information to the interface actor instance of the remote server according to the reference, so that the interface actor instance receiving method of the remote server calls parameters from the information and parses them, and reflectively calls the interface implementation class method in the current actor; detecting whether the execution result of the remote server is normal; if the execution result of the remote server is normal, then feeding back information that the execution result is normal.
[0007] In some embodiments, if the execution result of the remote server is abnormal, the number of service call failures is counted; it is detected whether the number of failures is less than a preset threshold; if the number of failures is less than the preset threshold, a remote server interface actor instance path is reselected from zookeeper.
[0008] In some embodiments, if the number of failures is equal to the preset number threshold, service call exception information is fed back.
[0009] In some embodiments, if the performance index of the current server is not less than a preset performance index threshold, the interface implementation class method of the current server is called; whether the execution result of the current server is normal is detected; if the execution result of the current server is abnormal, the step of selecting an interface actor instance path of a remote server from zookeeper is executed.
[0010] In some embodiments, monitoring the working status of the current server used for service calls includes: collecting performance indicators of the current server at a preset frequency; determining whether the performance indicators of the current server are less than a preset performance configuration threshold; if the performance indicators of the current server are less than the preset performance configuration threshold, determining that the working status of the current server is abnormal, and deleting the interface actor instance path of the current server from zookeeper.
[0011] In some embodiments, if the performance index of the current server is not less than a preset performance configuration threshold, it is determined whether the interface actor instance path of the current server is included in Zookeeper; if the interface actor instance path of the current server is not included in Zookeeper, the interface annotation of the current server is scanned to generate an interface actor instance; and the generated interface actor instance is registered in Zookeeper.
[0012] In some embodiments, monitoring the working status of the current server used for service call further includes: monitoring whether the current server instance exists in Zookeeper; if the current server instance does not exist in Zookeeper, deleting the current server interface actor instance path from Zookeeper.
[0013] In some embodiments, the above method also includes registering the interface actor, wherein registering the interface actor includes: scanning the interface annotation to generate an interface actor instance; obtaining the interface implementation object from the spring framework container through the interface name to initialize the interface actor instance; and registering the interface actor instance in zookeeper.
[0014] According to the second aspect of the embodiment of the present disclosure, a service call processing device is provided, including: a monitoring module, configured to monitor the working status of the current server used for service call, and when the working status of the current server is abnormal, delete the interface role actor instance path of the current server from the distributed service framework zookeeper, and send a service call request to the service call module; the service call module is configured to generate a proxy for the current calling service implementation class after receiving the service call request, detect the performance index of the current server through the proxy, and determine whether the performance index of the current server is less than a preset performance index threshold; if the performance index of the current server is less than the preset performance index threshold, select an interface actor instance path of a remote server from zookeeper, and implement the service call through the interface implementation class of the remote server.
[0015] According to a third aspect of an embodiment of the present disclosure, a service call processing device is provided, comprising: a memory configured to store instructions; a processor coupled to the memory, the processor being configured to execute a method as described in any of the above embodiments based on the instructions stored in the memory.
[0016] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and when the instructions are executed by a processor, the method described in any of the above embodiments is implemented.
[0017] Other features and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 A flowchart of a service call processing method according to an embodiment of the present disclosure;
[0020] Figure 2 This is a flow chart of a service call processing method according to another embodiment of the present disclosure;
[0021] Figure 3 A flow chart of a method for monitoring server performance indicators according to an embodiment of the present disclosure;
[0022] Figure 4This is a flow chart of a server downtime monitoring method according to an embodiment of the present disclosure;
[0023] Figure 5 This is a flowchart of an interface actor registration method according to an embodiment of the present disclosure;
[0024] Figure 6 This is a structural diagram of a service call processing device according to an embodiment of the present disclosure;
[0025] Figure 7 This is a structural diagram of a service call processing device according to another embodiment of the present disclosure;
[0026] Figure 8 This is a structural diagram of a service call processing device according to another embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is in no way intended to limit the present disclosure and its application or use. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.
[0028] Unless specifically stated otherwise, the relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure.
[0029] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0030] Technologies, methods and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, such technologies, methods and equipment should be considered part of the authorization specification.
[0031] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0032] It should be noted that like reference numerals and letters refer to like items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0033] Figure 1The following is a flow chart of a service call processing method according to an embodiment of the present disclosure. In some embodiments, the following steps of the service call processing method are executed by a service call processing device.
[0034] In step 101, the working status of the current server used for service call is monitored.
[0035] In some embodiments, monitoring the working status of the current server includes monitoring at least one of a performance indicator of the server and a server instance downtime monitoring.
[0036] In step 102, when the working state of the current server is abnormal, the interface actor (role) instance path of the current server is deleted from the distributed service framework Zookeeper.
[0037] In step 103, a proxy is generated for the currently called service implementation class.
[0038] In step 104, the performance indicators of the current server are detected through the agent.
[0039] In step 105, it is determined whether the performance index of the current server is less than a preset performance index threshold.
[0040] In step 106, if the performance index of the current server is less than the preset performance index threshold, an interface actor instance path of a remote server is selected from Zookeeper, and the service call is implemented through the interface implementation class of the remote server.
[0041] In the service call processing method disclosed in the above embodiment of the present disclosure, if the current server cannot execute the current call, the service call is transferred to a server that can process it normally, thereby ensuring the high availability, maintainability and scalability of the system.
[0042] Figure 2 The following is a flow chart of a service call processing method according to another embodiment of the present disclosure. In some embodiments, the following steps of the service call processing method are performed by a service call processing device. If the current server's operating status is abnormal, after deleting the interface actor instance path of the current server from the distributed service framework Zookeeper, the following steps are performed.
[0043] In step 201, a proxy is generated for the currently called service implementation class.
[0044] In step 202, the performance indicators of the current server are detected through the agent.
[0045] In step 203, it is determined whether the performance index of the current server is less than a preset performance index threshold.
[0046] If the performance index of the current server is less than the preset performance index threshold, step 204 is executed; if the performance index of the current server is not less than the preset performance index threshold, step 212 is executed.
[0047] In step 204, an interface actor instance path of a remote server is selected from Zookeeper.
[0048] In some embodiments, selection is made from the candidate remote servers by polling.
[0049] In step 205, the corresponding remote interface actor reference is obtained according to the interface actor instance path of the remote server.
[0050] In step 206, information is sent to the interface actor instance of the remote server according to the reference.
[0051] In step 207, the interface actor instance receiving method of the remote server calls and parses the parameters from the information, and reflectively calls the interface implementation class method in the current actor.
[0052] In step 208, it is detected whether the execution result of the remote server is normal.
[0053] If the execution result of the remote server is normal, step 209 is executed; if the execution result of the remote server is abnormal, step 210 is executed.
[0054] In step 209, a normal execution result is fed back and the process ends.
[0055] In step 210, the number of service call failures is counted, and it is detected whether the number of failures is less than a preset threshold.
[0056] If the number of failures is less than the preset threshold, the process returns to step 204 to reselect an interface actor instance path of a remote server from Zookeeper. If the number of failures is equal to the preset threshold, the process proceeds to step 211.
[0057] In step 211, the service call exception information is fed back and the process ends.
[0058] In step 212, the interface implementation class method of the current server is called.
[0059] In step 213, it is detected whether the execution result of the current server is normal.
[0060] If the execution result of the current server is abnormal, execute step 204. If the execution result of the current server is normal, end this process.
[0061] Figure 3 The following is a flow chart of a method for monitoring server performance indicators according to an embodiment of the present disclosure. In some embodiments, the following steps of the method for monitoring server performance indicators are executed by a service call processing device.
[0062] In step 301, the performance indicators of the current server are collected at a preset frequency, and the indicator information is placed in a local cache queue.
[0063] In step 302, the server performance indicator is extracted from the local cache queue.
[0064] In step 303, it is determined whether the performance index of the current server is less than a preset performance configuration threshold.
[0065] If the performance index of the current server is less than the preset performance configuration threshold, step 304 is executed; if the performance index of the current server is not less than the preset performance configuration threshold, step 305 is executed.
[0066] In step 304, it is determined that the working state of the current server is abnormal, and the interface actor instance path of the current server is deleted from Zookeeper, and then this process ends.
[0067] In step 305, it is determined whether the zookeeper includes the interface actor instance path of the current server.
[0068] If ZooKeeper does not include the interface actor instance path of the current server, step 306 is executed; if ZooKeeper includes the interface actor instance path of the current server, this process ends.
[0069] In step 306 , the interface annotations of the current server are scanned to generate interface actor instances.
[0070] In step 307, the generated interface actor instance is registered in ZooKeeper, and the process ends.
[0071] Figure 4 The following is a flow chart of a server downtime monitoring method according to an embodiment of the present disclosure. In some embodiments, the following server downtime monitoring method steps are executed by a service call processing device.
[0072] In step 401, monitor whether the current server instance exists in Zookeeper.
[0073] It should be noted here that the current server is registered in Zookeeper in advance.
[0074] In step 402, if the current server instance does not exist in Zookeeper, the current server interface actor instance path is deleted from Zookeeper.
[0075] Figure 5 The following is a flow chart of an interface actor registration method according to an embodiment of the present disclosure. In some embodiments, the following steps of the interface actor registration method are executed by a service call processing device.
[0076] In step 501, the interface annotation is scanned to generate an interface actor instance.
[0077] In step 502, an interface implementation object is obtained from the Spring framework container by the interface name to initialize the interface actor instance.
[0078] In step 503, the interface actor instance is registered in Zookeeper.
[0079] Figure 6 FIG. 1 is a structural diagram of a service call processing device according to an embodiment of the present disclosure. Figure 6 As shown, the service call processing device includes a monitoring module 61 and a service call module 62.
[0080] The monitoring module 61 is configured to monitor the working status of the current server used for service calls. When the working status of the current server is abnormal, the interface role actor instance path of the current server is deleted from the distributed service framework zookeeper, and a service call request is sent to the service call module 62.
[0081] In some embodiments, monitoring the working status of the current server includes monitoring at least one of a performance indicator of the server and a server instance downtime monitoring.
[0082] The service call module 62 is configured to generate a proxy for the currently called service implementation class after receiving a service call request, detect the performance indicators of the current server through the proxy, and determine whether the performance indicators of the current server are less than the preset performance indicator threshold. If the performance indicators of the current server are less than the preset performance indicator threshold, a remote server interface actor instance path is selected from Zookeeper, and the service call is implemented through the interface implementation class of the remote server.
[0083] In some embodiments, upon receiving a service call request, the service call module 62 generates a proxy for the currently called service implementation class. The proxy detects the performance indicators of the current server and determines whether the performance indicators of the current server are less than a preset performance indicator threshold. If the performance indicators of the current server are less than the preset performance indicator threshold, a remote server interface actor instance path is selected from Zookeeper. In some embodiments, the selection from the candidate remote servers is performed through a round-robin process. Next, a corresponding remote interface actor reference is obtained based on the remote server interface actor instance path. Based on this reference, a message is sent to the remote server interface actor instance, so that the remote server interface actor instance receiving method can call and parse the parameters in the message and reflectively call the interface implementation class method in the current actor. The service call module 62 detects whether the execution result of the remote server is normal. If the execution result of the remote server is normal, the normal execution result information is fed back. If the execution result of the remote server is abnormal, the number of service call failures is further counted and the number of failures is detected to be less than a preset number threshold. If the number of failures is less than the preset number threshold, a new remote server interface actor instance path is selected from Zookeeper. If the number of failures is equal to the preset threshold, the service call exception information will be fed back.
[0084] If the performance index of the current server is not less than the preset performance index threshold, the service calling module 62 calls the interface implementation class method of the current server and detects whether the execution result of the current server is normal. If the execution result of the current server is abnormal, the operation of selecting an interface actor instance path of a remote server from Zookeeper is repeated.
[0085] In some embodiments, the monitoring module 61 collects the performance indicators of the current server at a preset frequency during the process of monitoring the performance indicators of the server, and determines whether the performance indicators of the current server are less than the preset performance configuration threshold. If the performance indicators of the current server are less than the preset performance configuration threshold, it is determined that the working state of the current server is abnormal, and the interface actor instance path of the current server is deleted from Zookeeper. If the performance indicators of the current server are not less than the preset performance configuration threshold, it is further determined whether the interface actor instance path of the current server is included in Zookeeper. If the interface actor instance path of the current server is not included in Zookeeper, the interface annotation of the current server is scanned to generate an interface actor instance, and the generated interface actor instance is registered in Zookeeper.
[0086] In some embodiments, the monitoring module 61 monitors whether the current server instance exists in Zookeeper during the process of monitoring server downtime. If the current server instance does not exist in Zookeeper, the current server interface actor instance path is deleted from Zookeeper.
[0087] Figure 7 This is a structural diagram of a service call processing device according to another embodiment of the present disclosure. Figure 7 and Figure 6 The difference is that in Figure 7 In the illustrated embodiment, the service call processing device further includes an interface actor registration module 63 .
[0088] The interface actor registration module 63 scans the interface annotation to generate an interface actor instance, obtains the interface implementation object from the spring framework container through the interface name to initialize the interface actor instance, and registers the interface actor instance in zookeeper.
[0089] Figure 8 FIG. 1 is a structural diagram of a service call processing device according to another embodiment of the present disclosure. Figure 8 As shown, the service call processing device includes a memory 81 and a processor 82.
[0090] The memory 81 is used to store instructions. The processor 82 is coupled to the memory 81. The processor 82 is configured to execute the instructions stored in the memory. Figures 1 to 5 The method according to any one of the embodiments.
[0091] like Figure 8 As shown, the service call processing device further includes a communication interface 83 for exchanging information with other devices. At the same time, the service call processing device further includes a bus 84 through which the processor 82, the communication interface 83, and the memory 81 communicate with each other.
[0092] Memory 81 may include high-speed RAM memory or non-volatile memory, such as at least one disk storage device. Memory 81 may also be a memory array. Memory 81 may also be divided into blocks, and the blocks may be combined into virtual volumes according to certain rules.
[0093] Furthermore, the processor 82 may be a central processing unit (CPU), or may be an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present disclosure.
[0094] The present disclosure also relates to a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the following Figures 1 to 5 The method according to any one of the embodiments.
[0095] In some embodiments, the functional unit module described above can be implemented as a general-purpose processor, a programmable logic controller (PLC), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component or any appropriate combination thereof for performing the functions described in the present disclosure.
[0096] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0097] The description of the present disclosure is provided for purposes of illustration and description and is not intended to be exhaustive or to limit the disclosure to the disclosed form. Many modifications and variations will be apparent to those skilled in the art. The embodiments are selected and described in order to better illustrate the principles and practical applications of the present disclosure and to enable those skilled in the art to understand the present disclosure and design various embodiments with various modifications suitable for specific applications.
Claims
1. A service call processing method, comprising: Monitor the working status of the current server used for service calls; When the working status of the current server is abnormal, the interface role actor instance path of the current server is deleted from the distributed service framework zookeeper; Generate a proxy for the currently called service implementation class; Detecting the performance indicators of the current server through the agent; Determine whether the performance index of the current server is less than a preset performance index threshold; If the performance index of the current server is less than the preset performance index threshold, select an interface actor instance path of a remote server from Zookeeper and implement the service call through the interface implementation class of the remote server; If the performance index of the current server is not less than the preset performance index threshold, calling the interface implementation class method of the current server; Detecting whether the execution result of the current server is normal; If the execution result of the current server is abnormal, the step of selecting an interface actor instance path of a remote server from Zookeeper is executed.
2. The method according to claim 1, wherein Implementing a service call through the interface implementation class of the remote server includes: Get the corresponding remote interface actor reference according to the interface actor instance path of the remote server; Send information to the interface actor instance of the remote server according to the reference, so that the interface actor instance receiving method of the remote server calls parameters from the information and parses them, and reflectively calls the interface implementation class method in the current actor; Detecting whether the execution result of the remote server is normal; If the execution result of the remote server is normal, normal execution result information is fed back.
3. The method according to claim 2, further comprising: If the execution result of the remote server is abnormal, the number of service call failures is counted; Detecting whether the number of failures is less than a preset number threshold; If the number of failures is less than the preset threshold, a remote server interface actor instance path is reselected from Zookeeper.
4. The method according to claim 3, further comprising: If the number of failures is equal to the preset number threshold, service call exception information is fed back.
5. The method according to claim 1, wherein The working status of the current server monitored for service calls includes: Collect the performance indicators of the current server at a preset frequency; Determine whether the performance indicator of the current server is less than a preset performance configuration threshold; If the performance indicator of the current server is less than the preset performance configuration threshold, it is determined that the working status of the current server is abnormal, and the interface actor instance path of the current server is deleted from Zookeeper.
6. The method according to claim 5, further comprising: If the performance index of the current server is not less than the preset performance configuration threshold, determine whether the interface actor instance path of the current server is included in Zookeeper; If ZooKeeper does not include the interface actor instance path of the current server, the interface annotation of the current server is scanned to generate the interface actor instance; Register the generated interface actor instance with Zookeeper.
7. The method according to claim 5, wherein: Monitoring the working status of the current server for service calls also includes: Monitor whether the current server instance exists in Zookeeper; If the current server instance does not exist in Zookeeper, delete the current server interface actor instance path from Zookeeper.
8. The method according to any one of claims 1 to 7, further comprising registering the interface actor, wherein registering the interface actor comprises: Scan interface annotations to generate interface actor instances; Get the interface implementation object from the Spring framework container by the interface name to initialize the interface actor instance; Register the interface actor instance with Zookeeper.
9. A service call processing device, comprising: The monitoring module is configured to monitor the working status of the current server used for service invocation, and when the working status of the current server is abnormal, delete the interface role actor instance path of the current server from the distributed service framework Zookeeper, and send a service invocation request to the service invocation module; The service call module is configured to generate a proxy for the currently called service implementation class after receiving the service call request, detect the performance index of the current server through the proxy, and determine whether the performance index of the current server is less than the preset performance index threshold; if the performance index of the current server is less than the preset performance index threshold, select an interface actor instance path of a remote server from Zookeeper, and implement the service call through the interface implementation class of the remote server; if the performance index of the current server is not less than the preset performance index threshold, call the interface implementation class method of the current server to detect whether the execution result of the current server is normal; if the execution result of the current server is abnormal, select an interface actor instance path of a remote server from Zookeeper.
10. A service call processing device, comprising: a memory configured to store instructions; A processor is coupled to the memory, and the processor is configured to execute the method according to any one of claims 1 to 8 based on instructions stored in the memory.
11. A computer-readable storage medium, wherein: The computer-readable storage medium stores computer instructions, and when the instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Flow control method and device, storage medium and electronic equipment
CN110324253A