Service fault processing method and device
Active detection and management of proxy service node availability in Nginx servers enhance request processing efficiency and load balancing by preventing futile forwardings and integrating recovered nodes, thus optimizing Nginx server performance.
Patent Information
- Application Number
- CN202411046862.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-12-10
AI Technical Summary
Nginx reverse proxy servers experience reduced efficiency due to repeated forwarding of requests to faulty proxy service nodes, leading to inefficient request processing and load balancing.
Active detection of proxy service node availability, identifying and removing failed nodes from the proxy service node list, and re-adding nodes when they return to normal, using methods such as network connection and HTTP request testing, to optimize request forwarding.
Improves request processing efficiency and load balancing by reducing invalid forwardings and enabling seamless integration of recovered nodes, while facilitating automated monitoring and testing.
Smart Images

Figure CN119109755A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of servers, and in particular to a method and device for processing service failures. Background Art
[0002] Nginx is a commonly used reverse proxy server that processes requests by forwarding them to the proxy service node at the back end. However, if the proxy service node at the back end fails during the request processing, Nginx will be able to detect the failure of the proxy service node when forwarding, and then re-forward the request to other available proxy service nodes. Therefore, when a faulty service node appears at the back end, Nginx needs to forward the request multiple times to process the request, thus reducing the request processing efficiency. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a method and device for processing service failures, which actively detects the availability of multiple proxy service nodes in the proxy service node list of the proxy server, determines the target service node of the failure according to the availability, and deletes the identifier of the target service node from the proxy service node list, so that the proxy service node will not continue to try to forward the request to the failed target service node, reducing the number of invalid forwardings of the proxy server, thereby improving the request processing efficiency. Moreover, after the target service node returns to normal, the identifier of the target service node is re-added to the proxy service node list, so that the proxy server can continue to forward the request to the target proxy node that has returned to normal, thereby not only further improving the request processing efficiency, but also facilitating the load balancing of the proxy server.
[0004] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for processing a service failure is provided, which is applied to a proxy server, and the method includes:
[0005] Obtaining a proxy service node list of the proxy server, the proxy service node list including identifiers of multiple proxy service nodes;
[0006] Detect the availability of multiple proxy service nodes;
[0007] Determine a target service node of the failure from among multiple proxy service nodes according to availability;
[0008] Delete the target service node's ID from the proxy service node list;
[0009] When the target service node returns to normal, the identifier of the target service node is added back into the proxy service node list.
[0010] Optionally, the method further comprises:
[0011] Obtaining a test request for the proxy server through a web page, the test request indicating at least one or more of the following: a network test, an interface test, and a configuration verification;
[0012] According to the test request, the methods corresponding to the network test, interface test and configuration verification are called through the remote interaction module to test the proxy server;
[0013] Feedback test results via the web page.
[0014] Optionally, the availability of multiple proxy service nodes is detected, including:
[0015] Determine the correspondence between the network listening port of the proxy server and the proxy service node;
[0016] According to the corresponding relationship, the proxy service node is connected to the network monitoring port to detect the availability of the proxy service node.
[0017] Optionally, according to the corresponding relationship, connection detection is performed on the proxy service node through the network monitoring port, including:
[0018] Send an HTTP request to the corresponding proxy service node through the network listening port, and receive the response status code returned by the proxy service node; determine the availability of the proxy service node based on the response status code;
[0019] Optionally, a TCP connection is established with the proxy service node through a network monitoring port; if the connection is successful, it is determined that the proxy service node is available, otherwise it is determined that the proxy service node is faulty.
[0020] Optionally, before adding the identifier of the target service node to the proxy service node list again, the method further includes:
[0021] Send an HTTP request and / or establish a TCP connection to the target service node through the network monitoring port according to a preset period; determine whether the target service node has returned to normal based on the response status code of the HTTP request and / or the TCP connection status.
[0022] Optionally, when the number of times the response status code indicating success is received continuously reaches a preset first threshold, and / or the number of times the TCP connection is successfully established continuously reaches a preset second threshold, it is determined that the target service node has returned to normal.
[0023] Optionally, after the number of consecutive detected failures of the target service node reaches a preset third threshold, the target service node is deleted from the proxy service node list.
[0024] Optionally, the availability of multiple proxy service nodes is detected respectively through multiple threads.
[0025] To achieve the above object, according to another aspect of the embodiment of the present invention, a device for processing service failure is provided, which is applied to a proxy server. The device includes: a list acquisition module, a detection module and a processing module; wherein:
[0026] The list acquisition module is configured to acquire a proxy service node list of the proxy server, the proxy service node list including identifiers of multiple proxy service nodes;
[0027] The detection module is configured to detect the availability of the proxy service node; determine the target service node of the failure from the multiple proxy service nodes according to the availability;
[0028] The processing module is configured to delete the identifier of the target service node from the proxy service node list; when the target service node recovers to normal, add the identifier of the target service node back into the proxy service node list.
[0029] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a server for handling service failures is provided, the server comprising: a processor; a memory for storing processor executable instructions, wherein the processor is configured to execute the instructions to implement a service failure handling method of an embodiment of the present invention.
[0030] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of a server for processing service failures, the server for processing service failures can execute a service failure processing method of an embodiment of the present invention.
[0031] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, which, when executed by a processor, implements a service fault handling method of an embodiment of the present invention.
[0032] One embodiment of the above invention has the following advantages or beneficial effects: by actively detecting the availability of multiple proxy service nodes in the proxy service node list of the proxy server, determining the failed target service node according to the availability, and deleting the identifier of the target service node from the proxy service node list, the proxy service node will not continue to try to forward the request to the failed target service node, reducing the number of invalid forwardings of the proxy server, thereby improving the request processing efficiency. Moreover, after the target service node returns to normal, the identifier of the target service node is re-added to the proxy service node list, so that the proxy server can continue to forward the request to the target proxy node that has returned to normal, thereby not only further improving the request processing efficiency, but also facilitating the load balancing of the proxy server.
[0033] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0035] Figure 1 It is a flowchart of a method for handling a service failure provided by an embodiment of the present invention;
[0036] Figure 2 It is a schematic diagram of the architecture of a proxy server and its corresponding proxy service node provided by an embodiment of the present invention;
[0037] Figure 3 It is a schematic diagram of the architecture of a device for processing a service failure provided by an embodiment of the present invention;
[0038] Figure 4 It is a flowchart of another method for handling service failures provided by an embodiment of the present invention;
[0039] Figure 5 It is a flowchart of another method for handling a service failure provided by an embodiment of the present invention;
[0040] Figure 6 It is a schematic diagram of main modules of a device for processing service failures provided by an embodiment of the present invention;
[0041] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0042] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0044] In order to make those skilled in the art better understand the present disclosure, the following is a detailed description of various embodiments of the present invention in conjunction with the accompanying drawings and specific implementation methods. It should be noted that the embodiments of the present invention and the technical features in the embodiments can be combined with each other without conflict.
[0045] Figure 1A method for processing a service failure according to an embodiment of the present invention is applied to a proxy server. The method includes the following steps S101 to S104:
[0046] Step S101: obtaining a proxy service node list of a proxy server, wherein the proxy service node list includes identifiers of multiple proxy service nodes.
[0047] Step S102: Detect the availability of multiple proxy service nodes.
[0048] Step S103: determining a failed target service node from multiple proxy service nodes according to availability.
[0049] Step S104: when the target service node returns to normal, the identifier of the target service node is added to the proxy service node list again.
[0050] The proxy server may be an Nginx server, which, as a high-performance reverse proxy server, can provide the resources of the backend service nodes to the client, that is, the user can obtain the resources of the backend service nodes by accessing the Nginx server. These backend service nodes are the proxy service nodes of the Nginx proxy server, and the list composed of the identifiers of the backend service nodes constitutes the proxy service node list of the Nginx proxy server. Figure 2 As shown, the Nginx server can provide the resources of the backend service node A, the backend service node B and the backend service node C to the client according to the user request, that is, the backend service node A, the backend service node B and the backend service node C are the proxy service nodes of the Nginx server, and accordingly, the proxy service node list of the Nginx server is [A, B, C]. The proxy service node list can be configured in the configuration file of the Nginx server, and the proxy service node list can be obtained by reading the configuration file.
[0051] In one embodiment of the present invention, the availability of the proxy service node can be detected in a variety of ways such as network connection detection or pre-configured rules. Exemplarily, for the network connection detection method, the corresponding relationship between the network listening port of the proxy server and the proxy service node can be determined, and according to the corresponding relationship, the proxy service node is connected to the proxy service node through the network listening port to detect the availability of the proxy service node. For example, Python is used to write the logic of detecting availability, and the Python script is deployed to an executable environment such as a Python virtual environment or a Docker container, so that the Python script can run normally in the execution environment. Then, a new task is created in the XXL-JOB scheduler, and the above-mentioned Python script is specified as an execution command, and the execution cycle of the task is configured (such as executing a task every 5s). Thus, after the XXL-JOB scheduler is started and runs normally, the task of availability detection can be executed according to the configured execution cycle to realize the detection of the availability of the proxy service node. Among them, XXL-JOB is a lightweight distributed task scheduling platform that can be used to manage and schedule task execution; after writing the code in its relevant format, operations such as starting, executing, terminating, and monitoring the status of tasks can be performed in its visual interface.
[0052] Specifically, each network listening port and its corresponding proxy service node of the HTTP module and Stream module of Nginx can be scanned and parsed through Python scripts to form a correspondence between the network listening port and the proxy service node, and then the availability of the proxy service node can be determined for each group of network listening ports through TCP connection and / or HTTP detection according to the correspondence. Among them, the HTTP module of Nginx is the core module for processing HTTP requests in Nginx, and the Stream module is the module for processing network traffic in Nginx, which can be used to implement TCP and UDP proxy, load balancing, and traffic distribution.
[0053] For the method of detecting availability through TCP connection, a TCP connection can be attempted to be established with the proxy service node through the network monitoring port. If the connection is successful, it is determined that the corresponding proxy service node is available. Otherwise, it is determined that the proxy service node is faulty, and the faulty proxy service node is the target service node. Specifically, the Python script can attempt to establish a TCP connection with the specified port of the proxy service node through the telnetlib module. If the connection is successful, it means that the proxy service node is in a network connected state, that is, it means that the proxy service node is currently in an available state. Otherwise, it means that the proxy service node is in a network disconnected state, and it is in an unavailable state. Among them, the telnetlib module is used for remote login and interactive operations through the telnet protocol. It provides a set of methods that can realize functions such as connecting to a remote host, sending commands and receiving responses. In this embodiment, a telnet function can be constructed through a Python script, such as constructing a function to open a telnet connection: open(host=***, port=23, timeout=###), where host is the address of the proxy service node to be connected, port is the port number of the proxy service node, and timeout is the connection timeout. By calling this function, you can determine whether the TCP connection is successful by determining whether the telnet connection is successfully opened before the timeout period is reached.
[0054] For the method of detecting availability by HTTP detection, an HTTP request can be sent to the corresponding proxy service node through the network listening port, and the response status code returned by the proxy service node can be received to determine the availability of the proxy service node according to the response status code. Exemplarily, the HTTP request can be sent to the specific port and path of the proxy service node using the requests library through a Python script, and then the availability status of the proxy service node can be determined by checking the response status code. For example, if the proxy service node returns a response status code of 2××, it means that the HTTP request has been successfully received and processed, and it can be determined that the proxy service node is available; and if the proxy service node returns a response status code of 5××, it means that an error occurred in the HTTP request processing due to a server-side error, and it can be determined that the proxy service node is unavailable. Among them, the requests library is an HTTP request library in Python, which can be used to simplify the sending and processing of HTTP requests, such as sending GET requests, sending POST requests, and processing responses and handling exceptions.
[0055] Therefore, through the combination of XXL-JOB scheduler and Python script, it is possible to send HTTP requests to the proxy service node through the network listening port according to the execution cycle and / or try to establish a TCP connection with the proxy service node, so as to detect the availability of the proxy service node through network connection detection, thereby realizing active detection of the availability of the proxy service node, avoiding Nginx from perceiving the faulty target proxy node when forwarding user requests, thereby reducing the number of invalid forwardings of Nginx and improving request processing efficiency.
[0056] In addition to the network connection detection method, the embodiment of the present invention can also detect the availability of the proxy service node through other methods such as pre-configured rules. Exemplarily, the pre-configured rules may include any one or more of the following: judging the availability of the proxy service node based on the total number of failed processing requests within a preset first time period, judging the availability of the proxy service node based on the number of consecutive failures in processing requests within a preset second time period, and judging the availability of the proxy service node based on the time it takes to process a specific request. Among them, the first time period may be the same as or different from the second time period. The multiple factors of the above-mentioned pre-configured rules can be used alone or in combination with each other. The pre-configured rules and the network connection detection method can also be used alone or in combination, and the embodiment of the present invention does not limit this.
[0057] In the embodiment of the present invention, in order to improve the efficiency of availability detection, the availability of multiple proxy service nodes can be detected respectively through multiple threads, so as to detect the availability of multiple proxy service nodes in parallel. For example, multi-threaded parallel detection can be implemented through Python's threading module.
[0058] After determining the availability of the proxy service node, the target service node of the fault can be determined according to the availability, such as the proxy service node that cannot establish a TCP connection, HTTP request response error, or the total number or consecutive number of request processing failures greater than the preset thresholds corresponding to them is used as the target service node. Then the identifier of the target service node is deleted from the proxy service node list of Nginx, so that when the Nginx server receives a new request later, since the identifier of the target service node does not exist in its proxy service node list, the Nginx server will not forward the new request to the target service node, thereby reducing the invalid forwarding of the Nginx server and improving its efficiency in processing requests.
[0059] Moreover, after the target service node is determined, the information of the target service node can be notified to the monitoring and operation and maintenance personnel through the alarm channel. In addition, the availability data of the proxy service node corresponding to each network listening port can be reported to Prometheus through Python scripts to realize the monitoring of each proxy service node. And the monitoring visualization can be realized through Grafana, which is convenient for viewing the status of the Nginx load balancing service from a global perspective, which can not only improve the efficiency of the operation of the Nginx service itself, but also facilitate the active monitoring of the proxy service node. Among them, Prometheus is a monitoring system specially used to collect and store time series data. Grafana is a tool for creating and displaying dashboards of monitoring data, which can use Prometheus as a data source for data display.
[0060] In one embodiment of the present invention, in order to avoid the accidental deletion of the proxy service node due to the false detection of availability, the target service node's identifier is deleted from the proxy service node list only after the number of failures of the target service node is continuously detected to reach a preset third threshold. For example, the initial number of failures K of service node A, service node B, and service node C of Nginx proxy are all 0. In the process of detecting availability, Nginx can send HTTP requests to service node A, service node B, and service node C respectively through the network monitoring port, and determine that service node A is faulty according to the response status code returned by each service node. If service node B and service node C are available, then the number of failures of service node A + 1, that is, K A =1, K B =0, K C = 0. After that, Nginx continues to send HTTP requests to service nodes A, B, and C according to the task execution cycle. If service node A still returns a response status code indicating an error, its failure count increases again, that is, K A =2. If the third threshold is preset to 3, that is, after the proxy service node failure is detected for three consecutive times, the identifier of the target service node is deleted from the proxy service node list. Therefore, if the service node A still returns a response status code representing an error next time, the identifier of the service node A can be deleted from the proxy service node list, and the proxy service node list of the Nginx server is updated from [A, B, C] to [B, C]. Specifically, this can be achieved by automatically updating the configuration file of the Nginx server through a Python script. Therefore, by deleting the identifier of the corresponding target service node from the proxy service node list only after multiple failures are detected in succession, the consequence of the target service node being mistakenly deleted due to the availability misdetection caused by a certain network connection failure is avoided, and the normal proxy service node is avoided from being mistakenly deleted, which is conducive to improving the request processing efficiency.
[0061] It is worth mentioning that in the embodiment of the present invention, after determining the target service node of the fault, the network connection detection of the target service node can still be continued through the scheduled task in the XXL-JOB scheduler, such as continuing to send HTTP requests to the target service node and / or trying to establish a TCP connection with the target service node, and then determining whether the target service node has returned to normal based on the response status code of the HTTP request and / or the TCP connection result. The target service node is determined to be restored to normal when the number of consecutive receipts of the response status code representing success reaches a preset first threshold, and / or the number of consecutive successful TCP connections reaches a preset second threshold.
[0062] It is understandable that the above-mentioned method of sending HTTP request and attempting to establish TCP connection with target service node can be used alone or in combination. For the method of sending HTTP request alone, after determining that the target service node is faulty, the response status code N received to indicate success can be initialized to 0, that is, N=0. Thereafter, the scheduled task is continued to be executed to continue sending HTTP request to the target service node, and N=1 is updated after the response status code indicating success is received for the first time. If the preset first threshold is 3, then if two response status codes indicating success are received consecutively, it is determined that the target service node has recovered to normal, and before N=3, once a response status code indicating an error is received, N=0 is updated. For the method of establishing TCP connection with target service node alone, it is similar to the method of sending HTTP request alone, and will not be described in detail here. Among them, the first threshold and the second threshold may be equal or unequal. For the combination of the two methods, the target service node is determined to be recovered to normal only after the number of response status codes indicating success received reaches the preset first threshold and the number of consecutive successful TCP connections reaches the second threshold. However, when the response status code indicating success is received and reaches the preset first threshold but the number of consecutive successful TCP connections is less than the second threshold, or when the response status code indicating success is received and is less than the preset first threshold but the number of consecutive successful TCP connections is reached The second threshold, it will not be determined that the target service node has returned to normal.
[0063] After determining that the target service node has been restored to normal, the service of the target service node can be restored. In an embodiment of the present invention, the identifier of the target service node that has been restored to normal can be added back to the proxy service node list. This process can also be achieved by automatically updating the configuration file of the Nginx server through a Python script, so that the proxy server can forward the new requests received subsequently to the target service node that has been restored to normal according to the updated proxy service node list, thereby improving the request processing efficiency. After the target service node has been restored to normal, the recovery information can also be notified to the monitoring personnel and operation and maintenance personnel through the alarm channel, and the status visualization display of the proxy service node can be updated through Prometheus combined with Grafana.
[0064] The following describes the service failure handling method provided by the embodiment of the present invention by taking sending an HTTP request to the proxy service node or establishing a TCP connection to detect the availability of the proxy service node as an example. Figure 3 The architecture shown is implemented as follows: By combining the distributed scheduling platform XXL-JOB with Python scripts, each network listening port in the NginxHTTP module and the Stream module and its corresponding backend proxy service node can be scanned and parsed to form a corresponding relationship between the port and the proxy service node. Then, the availability of the proxy service node is determined by establishing a TCP connection or sending an HTTP request for each network listening port. When the proxy service node is unavailable, the Python script will automatically comment the line of the target service node in the Nginx configuration file, reload the Nginx service, and inform the monitoring and operation and maintenance personnel of this information through the alarm channel. Driven by the XXL-JOB platform, the Python script is executed regularly according to the execution cycle (such as once every 1S). When the failed target service node returns to normal, the Python script will automatically add the proxy service node back to the Nginx proxy service node list, and also notify the monitoring and operation and maintenance personnel of this information through the alarm channel. In addition, by combining Prometheus and Grafana, the availability data of each network listening port and proxy service node is reported to Prometheus through Python scripts, and the monitoring visualization is realized through Grafana, thereby realizing the global view of the status of the Nginx load balancing service.
[0065] Specifically, in the case of detecting availability by sending an HTTP request, the method for processing a service failure provided by an embodiment of the present invention mainly includes the following steps: Figure 4 Steps shown:
[0066] Step S401: obtaining a proxy service node list of a proxy server, where the proxy service node list includes identifiers of multiple proxy service nodes.
[0067] Step S402: determining the correspondence between the network listening port of the proxy server and the proxy service node, and using multiple threads to send HTTP requests to the corresponding proxy service nodes through the network listening port respectively according to the correspondence.
[0068] Step S403: receiving a response status code returned by the proxy service node, and determining the availability of the proxy service node according to the response status code.
[0069] Step S404: Determine the failed target service node from the multiple proxy service nodes according to availability.
[0070] Step S405: after the number of consecutive detected failures of the target service node reaches a preset third threshold, the identifier of the target service node is deleted from the proxy service node list.
[0071] Step S406: Continue to send HTTP requests to the target service node through the network monitoring port according to a preset period.
[0072] Step S407: receiving the response status code returned by the proxy service node, and recording the number of times the response status code indicating success is received consecutively.
[0073] Step S408: When the number of times the response status code indicating success is received continuously reaches a preset first threshold, it is determined that the target service node has recovered to normal.
[0074] Step S409: adding the identifier of the target service node that has returned to normal to the proxy service node list again.
[0075] In addition, in the case of detecting the availability of the proxy service node by establishing a TCP connection, the service failure processing method provided by the embodiment of the present invention may include the following steps: Figure 5 Steps shown:
[0076] Step S501: Acquire a proxy service node list of a proxy server, where the proxy service node list includes identifiers of multiple proxy service nodes.
[0077] Step S502: Determine the correspondence between the network monitoring port of the proxy server and the proxy service node.
[0078] Step S503: Establish TCP connections with corresponding proxy service nodes through network monitoring ports using multiple threads according to the corresponding relationship. If the connection is successful, execute step S504; if the connection fails, execute step S505.
[0079] Step S504: determine that the proxy service node is available, and continue to execute step S503 according to the execution cycle.
[0080] Step S505: Determine that the proxy service node is unavailable, and use it as the target service node of the failure.
[0081] Step S506: after the number of consecutive detected failures of the target service node reaches a preset third threshold, the identifier of the target service node is deleted from the proxy service node list.
[0082] Step S507: Continue to try to establish a TCP connection with the target service node through the network monitoring port according to a preset period.
[0083] Step S508: When the number of successful connections and consecutive successes reaches a preset second threshold, it is determined that the target service node has returned to normal.
[0084] Step S509: adding the identifier of the target service node that has returned to normal to the proxy service node list again.
[0085] In addition, in order to solve the problem that the development or test personnel cannot log in to the address of the Nginx server and need the assistance of the Nginx operation and maintenance personnel to perform network testing, interface testing or configuration verification on the server, thereby causing the problem of high labor cost of Nginx operation and maintenance, an embodiment of the present invention also provides an automatic testing service. Specifically, a test request for a proxy server is obtained through a web page, and the test request indicates at least one or more of the following: network testing, interface testing and configuration verification; a method corresponding to the network testing, interface testing and / or configuration verification is called according to the test request to test the proxy server; and then the test result is fed back through the web page. Exemplarily, a web application can be written based on the Flask framework of Python to facilitate the rapid implementation of web page services through the Python language. In addition, the telnetlib module and subprocess module of Python are configured on the proxy server, wherein the telnetlib module is a built-in module of Python, which can remotely log in and interact through the Telnet protocol process, and it provides a set of methods that can realize functions such as connecting to a remote host, sending commands and receiving responses. The subprocess module is also a built-in module of Python, which allows new processes to be generated, connected to their input, output or error reporting pipes, and obtain their return codes. Thus, through the cooperation of the telnetlib module and the subprocess module, remote login and interactive operation can be realized and the corresponding results can be returned. Further, the embodiment of the present invention uses HTML to realize a web page for obtaining a test request, on which the user can enter the required operation, and the web page can submit the user's requirements in the form of a form, and then the background program realized by Python Flask can perform corresponding operations on the Nginx server, so that the proxy server can call the method corresponding to the test request. For example, when the test request indicates a network test, the proxy server calls the network test method accordingly, such as the proxy server establishes a process requesting the web server and obtains the corresponding results, or detects the network connectivity, or analyzes the network speed, or performs network management operations such as querying the DNS domain name and IP address, or locates the router between itself and the target computer to perform a network test. For another example, when the test request indicates an interface test, the proxy server attempts to perform a remote login through the specified interface to perform an interface test. If the test request indicates configuration verification, the proxy server can view the verification configuration file. Thus, the automatic testing service of the proxy server is realized through the web page, without the need for the operation and maintenance personnel to log in to the proxy server to perform a black screen operation, thereby reducing the workload during the test and improving the efficiency of development and testing.
[0086] According to the above embodiments, by actively detecting the availability of multiple proxy service nodes in the proxy service node list of the proxy server, determining the failed target service node based on the availability, and deleting the identifier of the target service node from the proxy service node list, the proxy service node will not continue to try to forward the request to the failed target service node, reducing the number of invalid forwardings of the proxy server, thereby improving the request processing efficiency. In addition, after the target service node returns to normal, the identifier of the target service node is re-added to the proxy service node list, so that the proxy server can continue to forward the request to the target proxy node that has returned to normal, thereby not only further improving the request processing efficiency, but also facilitating the load balancing of the proxy server. In addition, network testing and configuration file verification are performed through web pages, which reduces the workload problem in the development and testing process, reduces the operation and maintenance costs, and improves the development and testing efficiency.
[0087] Based on the inventive concept of the above-mentioned method for processing service failure, the embodiment of the present invention further provides a device 600 for processing service failure, which can be applied to a proxy server, such as Figure 6 As shown, the device mainly includes: a list acquisition module 601, a detection module 602 and a processing module 603; wherein,
[0088] The list acquisition module 601 is configured to acquire a proxy service node list of the proxy server, the proxy service node list including identifiers of multiple proxy service nodes;
[0089] The detection module 602 is configured to detect the availability of multiple proxy service nodes; determine the failed target service node from the multiple proxy service nodes according to the availability;
[0090] The processing module 603 is configured to delete the identifier of the target service node from the proxy service node list; when the target service node recovers to normal, add the identifier of the target service node back into the proxy service node list.
[0091] In one embodiment of the present invention, continue to refer to Figure 6 The device also includes a request acquisition module 604 and a feedback module 605; wherein,
[0092] The request acquisition module 604 is configured to acquire a test request for the proxy server through a web page, where the test request indicates one or more of a network test, an interface test, and a configuration verification;
[0093] The processing module 603 is further configured to call a method corresponding to a network test, an interface test and / or a configuration verification according to the test request to test the proxy server;
[0094] The feedback module 604 is configured to feedback the test result via a web page.
[0095] In one embodiment of the present invention, the detection module 602 is configured to determine the correspondence between the network listening port of the proxy server and the proxy service node; based on the correspondence, perform connection detection on the proxy service node through the network listening port to detect the availability of the proxy service node.
[0096] In one embodiment of the present invention, the detection module 602 is configured to send an HTTP request to the corresponding proxy service node through a network monitoring port, and receive a response status code returned by the proxy service node; and determine the availability of the proxy service node according to the response status code.
[0097] In one embodiment of the present invention, the detection module 602 is configured to establish a TCP connection with the proxy service node through a network monitoring port; if the connection is successful, it is determined that the proxy service node is available, otherwise it is determined that the proxy service node is faulty.
[0098] In one embodiment of the present invention, the detection module 602 is also configured to send an HTTP request and / or establish a TCP connection to the target service node through the network listening port according to a preset period; and determine whether the target service node has returned to normal based on the response status code of the HTTP request and / or the TCP connection status.
[0099] In one embodiment of the present invention, the detection module 602 is configured to determine that the target service node has returned to normal when the number of consecutive receipts of response status codes indicating success reaches a preset first threshold and / or the number of consecutive successful TCP connections established reaches a preset second threshold.
[0100] In one embodiment of the present invention, the detection module 602 is configured to delete the identifier of the target service node from the proxy service node list after the number of consecutive detections of the target service node failure reaches a preset third threshold.
[0101] In one embodiment of the present invention, the detection module 602 is configured to detect the availability of multiple proxy service nodes respectively through multiple threads.
[0102] According to the above embodiment, by actively detecting the availability of multiple proxy service nodes in the proxy service node list of the proxy server, determining the failed target service node based on the availability, and deleting the identifier of the target service node from the proxy service node list, the proxy service node will not continue to try to forward the request to the failed target service node, reducing the number of invalid forwardings of the proxy server, thereby improving the request processing efficiency. In addition, after the target service node returns to normal, the identifier of the target service node is re-added to the proxy service node list, so that the proxy server can continue to forward the request to the target proxy node that has returned to normal, thereby not only further improving the request processing efficiency, but also facilitating the load balancing of the proxy server. In addition, network testing and configuration file verification are performed through web pages, which reduces the workload problem in the development and testing process, reduces the operation and maintenance costs, and improves the development and testing efficiency.
[0103] Figure 7 An exemplary system architecture 700 is shown to which a method for processing a fault service or an apparatus for processing a fault service according to an embodiment of the present invention may be applied.
[0104] like Figure 7 As shown, the system architecture 700 may include terminal devices 701, 702, 703, a network 704 and servers 705, 706, 707. The network 704 is used to provide a medium for communication links between the terminal devices 701, 702, 703 and the servers 705, 706, 707. The network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc. The servers 705, 706, 707 may include proxy servers 705 and backend service nodes 706, 707. Users may use the terminal devices 701, 702, 703 to interact with the server 705 through the network 704 to initiate a request, and the server 705 may forward the request to the backend service nodes 706, 707 through the network.
[0105] Various client applications may be installed on the terminal devices 701, 702, and 703, such as shopping applications, payment applications, instant messaging tools, social platform software, etc. The terminal devices 701, 702, and 703 may be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0106] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0107] Reference below Figure 8, which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0108] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0109] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0110] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0111] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0112] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0113] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The described system may also be set in a processor, for example, it may be described as: a processor includes a list acquisition module, a detection module and a processing module. The names of these modules do not constitute a limitation on the system itself in some cases, for example, the detection module may also be described as a "module for detecting the availability of a proxy service node".
[0114] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining a proxy service node list of a proxy server, the proxy service node list includes identifiers of multiple proxy service nodes; detecting the availability of the proxy service node; determining a failed target service node from multiple proxy service nodes based on the availability; deleting the identifier of the target service node from the proxy service node list; and when the target service node returns to normal, re-adding the identifier of the target service node to the proxy service node list.
[0115] According to the technical solution of the embodiment of the present invention, by actively detecting the availability of multiple proxy service nodes in the proxy service node list of the proxy server, determining the failed target service node according to the availability, and deleting the identifier of the target service node from the proxy service node list, the proxy service node will not continue to try to forward the request to the failed target service node, reducing the number of invalid forwardings of the proxy server, thereby improving the request processing efficiency. Moreover, after the target service node returns to normal, the identifier of the target service node is re-added to the proxy service node list, so that the proxy server can continue to forward the request to the target proxy node that has returned to normal, thereby not only further improving the request processing efficiency, but also facilitating the load balancing of the proxy server.
[0116] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for handling service failures, characterized in that: Applicable to proxy servers, including: Acquire a proxy service node list of the proxy server, wherein the proxy service node list includes identifiers of multiple proxy service nodes; Detecting the availability of multiple proxy service nodes; Determine a failed target service node from the plurality of proxy service nodes according to the availability; Deleting the identifier of the target service node from the proxy service node list; When the target service node returns to normal, the identifier of the target service node is added back into the proxy service node list.
2. The method according to claim 1, characterized in that Also includes: Obtaining a test request for the proxy server through a web page, the test request indicating at least one or more of the following: a network test, an interface test, and a configuration verification; Invoke a method corresponding to the network test, interface test and / or configuration verification according to the test request, so as to test the proxy server using the invoked method; Feedback the test results through the web page.
3. The method according to claim 1, characterized in that The detecting the availability of the plurality of proxy service nodes comprises: Determine the correspondence between the network monitoring port of the proxy server and the proxy service node; According to the corresponding relationship, a connection detection is performed on the proxy service node through the network monitoring port to detect the availability of the proxy service node.
4. The method according to claim 3, characterized in that The performing connection detection on the proxy service node through the network monitoring port according to the corresponding relationship includes: Sending an HTTP request to the corresponding proxy service node through the network listening port, and receiving a response status code returned by the proxy service node; determining the availability of the proxy service node according to the response status code; and / or, A TCP connection is established with the proxy service node through the network monitoring port; if the connection is successful, it is determined that the proxy service node is available, otherwise it is determined that the proxy service node is faulty.
5. The method according to claim 4, characterized in that Before re-adding the identifier of the target service node to the proxy service node list, the method further includes: Sending an HTTP request and / or establishing a TCP connection to the target service node through the network listening port according to a preset period; determining whether the target service node has returned to normal according to a response status code of the HTTP request and / or a TCP connection status.
6. The method according to claim 5, characterized in that When the number of times the response status code indicating success is received continuously reaches a preset first threshold, and / or the number of times the TCP connection is successfully established continuously reaches a preset second threshold, it is determined that the target service node has returned to normal.
7. The method according to any one of claims 1 to 6, characterized in that: After the number of consecutive detections of the target service node failures reaches a preset third threshold, the identifier of the target service node is deleted from the proxy service node list.
8. The method according to any one of claims 1 to 6, characterized in that: The availability of the plurality of proxy service nodes is detected respectively through a plurality of threads.
9. A device for processing service failure, characterized in that: Applied to proxy server; including: list acquisition module, detection module and processing module; wherein, The list acquisition module is configured to acquire a proxy service node list of the proxy server, wherein the proxy service node list includes identifiers of multiple proxy service nodes; The detection module is configured to detect the availability of the plurality of proxy service nodes; determine the failed target service node from the plurality of proxy service nodes according to the availability; The processing module is configured to delete the identifier of the target service node from the proxy service node list; and when the target service node recovers to normal, add the identifier of the target service node back into the proxy service node list.
10. A server for handling service failures, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the service fault handling method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, when the instructions in the computer-readable storage medium are executed by a processor of a server for processing service failures, the server for processing service failures can execute the method for processing service failures as described in any one of claims 1 to 8.
