Method, device and equipment for automatically switching access server side and storage medium

CN120017711APending Publication Date: 2025-05-16DUXIAOMAN TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411953999.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-05-16

Smart Images

  • Figure CN120017711A_ABST
    Figure CN120017711A_ABST
Patent Text Reader

Abstract

The invention provides a method, device and equipment for automatically switching access to a server side and a storage medium, and relates to the technical field of the Internet, the method is applied to a client side, reverse proxy service is deployed in the client side, and the method comprises the steps that an active detection request is sent to a first server side through the reverse proxy service by using a first private line path; if the number of continuous failures of the active detection request exceeds a first number threshold, triggering a fault switching request of a special line path; and after the fault switching request is triggered, a business service request is sent to a second server side through a reverse proxy service by using a second private line path, the first server side is different from the second server side, and the first server side and the second server side have the same business service function. According to the method, the client can be automatically switched to access the server when the client fails, and the loss stopping timeliness is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a method, apparatus, device and storage medium for automatically switching access to a server. Background Art

[0002] The entire link of client access to the server is usually divided into three parts: cloud, pipe, and end. The cloud is the server, the pipe is the pipeline, which can use a dedicated line or a public network link, and the end is the client.

[0003] In the related art, in order to ensure the high availability of the client access to the server, redundant design and switching capability are used to achieve this. For example, two dedicated lines form a network path. Since the dedicated line gateway can only be configured with a single peer service address, one of the dedicated lines is used as the main path and the other as the backup path. Under normal circumstances, the main dedicated line is used to exchange traffic with the server. When the main dedicated line is terminated, the backup dedicated line is bound to the dedicated line gateway by modifying the peer service address configured by the dedicated line gateway, thereby realizing the switching operation of the dedicated line in the network channel.

[0004] When using the methods in related technologies, cloud vendors usually do not open up the configuration permissions of dedicated gateways to users. This results in the dedicated network being in active / standby mode, and the affected business services need to contact the cloud vendors to stop the loss. This process has many nodes and is very time-consuming, so the timeliness of stopping the loss is poor. Summary of the invention

[0005] The present application provides a method, apparatus, device and storage medium for automatically switching access to a server. The technical solution is as follows:

[0006] According to one aspect of the present application, a method for automatically switching access to a server is provided, the method being applied to a client, wherein a reverse proxy service is deployed in the client, the method comprising:

[0007] Sending an active detection request to the first server using the first dedicated line through the reverse proxy service;

[0008] If the number of consecutive failures of the active detection request exceeds the first number threshold, a failover request for the dedicated line is triggered;

[0009] After triggering the failover request, a business service request is sent to a second server via the reverse proxy service using a second dedicated line, the first server is different from the second server, and the first server and the second server have the same business service function.

[0010] According to another aspect of the present application, a device for automatically switching access to a server is provided, the device being applied to a client, wherein a reverse proxy service is deployed in the client, and the device comprising:

[0011] A first sending module, used for sending an active detection request to a first server end through the reverse proxy service using a first dedicated line;

[0012] A first trigger module, configured to trigger a failover request for a dedicated line if the number of consecutive failures of the active detection request exceeds a first number threshold;

[0013] The second sending module is used to send a business service request to a second server end through the reverse proxy service using a second dedicated line after triggering the failover request. The first server end is different from the second server end, and the first server end and the second server end have the same business service function.

[0014] According to another aspect of the present application, an electronic device is provided, including: a processor and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes the method of automatically switching access to a server as described above.

[0015] According to another aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method for automatically switching access to a service end as described above.

[0016] According to another aspect of the present application, a computer program product is provided, the computer program product comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned method of automatically switching access to a server.

[0017] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:

[0018] By configuring the reverse proxy service, when a dedicated line fails, the traffic access path of the reverse proxy service can be switched, that is, from the first dedicated line to the second dedicated line. This allows the client to automatically switch access to the server in the event of a failure, thereby achieving the purpose of stopping the failure. Moreover, by switching the traffic access path, the dedicated line can be switched indirectly without changing the server address bound to the gateway, saving the business service from contacting the cloud vendor to perform multiple process nodes for stop-loss operations such as changing the gateway server configuration, thereby improving the timeliness of stopping the loss. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Further details, features and advantages of the present application are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:

[0020] Figure 1 It is a system architecture diagram provided by an embodiment of the present application;

[0021] Figure 2 A flow chart showing a method for automatically switching access to a service end according to an exemplary embodiment of the present application is shown;

[0022] Figure 3 A flowchart showing another method for automatically switching access to a service end according to an exemplary embodiment of the present application is shown;

[0023] Figure 4 A flowchart showing another method for automatically switching access to a service end according to an exemplary embodiment of the present application is shown;

[0024] Figure 5 It is a structural diagram of a device for automatically switching access to a server provided in an embodiment of the present application;

[0025] Figure 6 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present application is shown. DETAILED DESCRIPTION

[0026] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.

[0027] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.

[0028] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc. mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units. It should be noted that the modifications of "one" and "multiple" mentioned in this application are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more". The names of the messages or information exchanged between multiple devices in the embodiments of this application are only for illustrative purposes, and are not used to limit the scope of these messages or information.

[0029] The solution of the present invention is described below with reference to the accompanying drawings, and the technical solution provided by the embodiment of the present invention is explained in detail through specific embodiments and their application scenarios.

[0030] In view of the problem that the failure stop loss service in the related technology has many operation procedures and takes a long time, resulting in poor stop loss timeliness, the embodiment of the present application provides a new service quality maintenance system. The client actively detects the server through the reverse proxy service. In the case of redundant lines, when a single line is abnormal, it can trigger automatic switching of the dedicated line to achieve stop loss in seconds. Please refer to Figure 1 , Figure 1 This is a service quality maintenance system provided by the embodiment of the present application. Figure 1 As shown, the service quality maintenance system includes a client 110 and a server 120. A reverse proxy service is deployed in the client 110. For example, client A corresponds to reverse proxy service A, and client B corresponds to reverse proxy service B.

[0031] Reverse proxy service A sets dedicated line channel A as the main line channel and sets dedicated line channel B as the backup channel; reverse proxy service B sets dedicated line channel B as the main line channel and sets dedicated line channel A as the backup channel.

[0032] Bind the service access entry corresponding to server A to dedicated gateway A, and bind the service access entry corresponding to server B to dedicated gateway B.

[0033] Dedicated line channel A consists of dedicated line gateway A, router, and physical dedicated line A. Dedicated line channel B consists of dedicated line gateway B, router, and physical dedicated line B.

[0034] For example, taking client A accessing the server as an example, client A sends an active detection request to server A using dedicated channel A through reverse proxy service A. If a failure of dedicated channel A is detected, client A sends a business service request using dedicated channel B through reverse proxy service A. There is no need to change the service access entry bound to dedicated gateway A, and the dedicated channel switching is indirectly achieved by switching the traffic path.

[0035] based on Figure 1 The provided service quality maintenance system, the embodiment of the present application provides an improved method for automatically switching access to the server. Please refer to Figure 2 , which shows a flow chart of a method for automatically switching access to a server according to an exemplary embodiment of the present application. Figure 1 The client 110 shown in FIG. Figure 2 As shown, the method includes:

[0036] Step 201: Send an active detection request to a first server via a reverse proxy service using a first dedicated line.

[0037] Among them, the reverse proxy service is an application mode of a proxy server, which is deployed between the client and the server. It can receive and process requests from the client on behalf of the server. For the client, the reverse proxy service is equivalent to the target server, and there is no need to pay attention to the address of the other end that needs to be accessed later. By deploying the reverse proxy service in the client background, and the number of reverse proxy services deployed is consistent with the number of dedicated channels, and making a one-to-many cross-configuration association between the reverse proxy service and the server corresponding to the dedicated channel, it is possible to switch the dedicated channel failure by switching the traffic path from the client to the server, thereby improving the efficiency of fault switching.

[0038] For example, if there are two dedicated lines (dedicated line A and dedicated line B), client A is deployed with reverse proxy service A, and client B is deployed with reverse proxy service B, that is, two reverse proxy services are deployed; then the reverse proxy service and the server-side service are cross-configured in a 1-to-2 manner, for example, reverse proxy service A sets dedicated line A as the primary and dedicated line B as the backup, and proxy B sets dedicated line B as the primary and dedicated line A as the backup. The dedicated gateway A corresponding to client A is bound to the service access entry corresponding to server A, and the dedicated gateway B corresponding to client B is bound to the service access entry corresponding to server B. Under normal circumstances, client A can use dedicated channel A to access server A through reverse proxy service A and dedicated gateway A. In the event of a failure of dedicated channel A, client A can access dedicated gateway B through reverse proxy service A without changing the service access entry bound to dedicated gateway A, thereby using dedicated channel B to access server B. Similarly, under normal circumstances, client B can use dedicated channel B to access server B through reverse proxy service B and dedicated gateway B. In the event of a failure of dedicated channel B, client B can access dedicated gateway A through reverse proxy service B without changing the service access entry bound to dedicated gateway B, thereby using dedicated channel A to access server A. Thus, the switching of dedicated channels is indirectly achieved by switching the traffic path.

[0039] In order to detect whether the currently used main dedicated line is faulty, the client, in addition to normal business service requests, will also use the first dedicated line to send an active detection request to the first server through the reverse proxy service to detect whether the first dedicated line can normally transmit requests and respond to requests. Specifically, the reverse proxy service uses the first dedicated line to send an active detection request to the first server through the first dedicated gateway bound to the first dedicated line.

[0040] Step 202: If the number of consecutive failures of the active detection request exceeds a first threshold, a failover request for the dedicated line is triggered.

[0041] The client will send active detection requests according to the preset detection cycle. If the number of consecutive failures of the active detection requests exceeds the first number threshold, it can be determined that the first dedicated line may have a fault. In order to avoid continuing to use the faulty path and causing business request failures, the path fault switching request will be automatically triggered. The fault switching request is used to instruct the reverse proxy service to switch the client to implement the dedicated line and server for the business request.

[0042] Exemplarily, the first number threshold may be 5 times, that is, if the number of consecutive failures of the active detection request exceeds 5 times, a failover request for the dedicated line is triggered by default.

[0043] Step 203, after triggering the failover request, send a business service request to the second server through the reverse proxy service using the second dedicated line, the first server is different from the second server, and the first server and the second server have the same business service function.

[0044] After triggering the failover request, there is no need to change the server address bound to the dedicated gateway. The client sends a business service request to the reverse proxy service, and the reverse proxy service will switch to using the second dedicated channel to send the business service request to the second server. Specifically, the reverse proxy service will use the second dedicated channel to send the business service request to the second server through the second dedicated gateway bound to the second dedicated channel. The service changes the server address bound to the first dedicated gateway, and the failover function can be implemented by switching the traffic path used by the reverse proxy service (i.e., the second dedicated channel). This saves the business service from contacting the cloud vendor to perform multiple process nodes for stop-loss operations such as changing the gateway server configuration, thereby improving the timeliness of stop-loss.

[0045] In summary, the embodiment of the present application provides a method for automatically switching access to a server by a client: by configuring a reverse proxy service, when a dedicated line fails, by switching the traffic access path of the reverse proxy service, that is, switching from the first dedicated line to the second dedicated line, the client can automatically switch access to the server in the event of a failure, thereby achieving the purpose of stopping the failure; moreover, by switching the traffic access path, the switching of the dedicated line can be indirectly achieved without changing the server address bound to the gateway, thereby saving the multi-process nodes of the business service contacting the cloud vendor to perform stop-loss operations such as changing the gateway server configuration, thereby improving the timeliness of stopping the loss.

[0046] Taking two dedicated lines as an example, in order to ensure load balance, different reverse proxy services will set up different main lines and backup lines, so that when the dedicated lines are normal, the traffic on the two dedicated lines is balanced; correspondingly, after the main line fails and switches to the backup line, it is also necessary to detect in real time whether the main line is restored, so as to switch back to the main line in time after recovery to avoid long-term traffic imbalance.

[0047] Please refer to Figure 3 , which shows a flow chart of another method for automatically switching access to a server according to an exemplary embodiment of the present application. Figure 1 The client 110 shown in FIG. Figure 3 As shown, the method includes:

[0048] Step 301: Send an active detection request to a first server via a reverse proxy service using a first dedicated line.

[0049] Step 302: If the number of consecutive failures of the active detection request exceeds a first threshold, a failover request for the dedicated line is triggered.

[0050] Step 303, after triggering the failover request, send a business service request to the second server through the reverse proxy service using the second dedicated line, the first server is different from the second server, and the first server and the second server have the same business service function.

[0051] The implementation of steps 301 to 303 may refer to steps 201 to 203, and will not be described in detail in this embodiment.

[0052] Taking a case where two dedicated lines are included, with the first dedicated line being the main line and the second dedicated line being the backup line as an example, when the client normally uses the first dedicated line to transmit business service requests, the client will use the first dedicated line to send an active detection request to the first server through the reverse proxy service to detect whether the first dedicated line is faulty; after the number of consecutive failures of the active detection request exceeds the first number threshold, a failover request for the dedicated line can be triggered; after the failover request is triggered, if the client has business service requirements, it will use the second dedicated line (backup line) to send a business service request to the second server through the reverse proxy service.

[0053] Optionally, after triggering the failover request of the dedicated line, an unavailable state or an unavailable mark may be set for the first dedicated line.

[0054] Optionally, in order to avoid the situation where the second dedicated line also fails and causes business service failure, when the failover request is triggered and it is confirmed that the second dedicated line is not faulty, the business service request is sent to the second server through the second dedicated line via the reverse proxy service.

[0055] Optionally, if there are more than two dedicated lines, one of them can be set as the main line, and the other two or more dedicated lines can be set as backup lines. When it is determined that the main line (the first dedicated line) fails, a non-faulty line can be determined from the other multiple backup lines as the second dedicated line, and then the second dedicated line is used to send a business service request to the second server through the reverse proxy service.

[0056] Exemplarily, if there are dedicated line channels A, dedicated line channels B and dedicated line channels C, for client A, the reverse proxy service A deployed thereon sets dedicated line channel A as the main line channel, and sets dedicated line channels B and dedicated line channels C as backup channels. When dedicated line channel A is normal, client A uses dedicated line channel A to send business service requests and active detection requests to server A through reverse proxy A; when active detection determines that dedicated line channel A is faulty, a fault switching request is triggered, and the channel status of dedicated line channel B and dedicated line channel C can be obtained respectively through reverse proxy service A. If the channel statuses are all normal, a dedicated line channel can be randomly selected from dedicated line channel B and dedicated line channel C, so that reverse proxy service A can make business service requests through the dedicated line channel; if dedicated line channel B is abnormal and dedicated line channel C is normal, reverse proxy service A can make business service requests through dedicated line channel C.

[0057] Step 304: After the failover request is triggered, detect whether the first dedicated line is restored through the reverse proxy service.

[0058] In order to avoid traffic imbalance caused by continuing to use the second dedicated line after the first dedicated line returns to normal, thereby reducing the problem of request response failure, after triggering the failover request, the client will continue to detect whether the first dedicated line (main line) has returned to normal through the reverse proxy service, and then can switch back to the main line in time if it returns to normal.

[0059] Considering that after detecting a main line fault, it takes a certain amount of time for the main line to change from an unavailable state to an available state, in order to avoid invalid detection times, an unavailable time is also set so that active detection can be performed after the unavailable time. Correspondingly, in an exemplary example, step 304 may include steps 304A to 304C.

[0060] Step 304A: after triggering the failover request, set the first detection interval duration.

[0061] The first detection interval is the unavailable time set for the main line (first dedicated line). After the failover request is triggered, the first dedicated line will be set to an unavailable state and the first detection interval will be set so that after the first detection interval is reached, the first dedicated line will be actively detected to see if it has returned to normal.

[0062] Optionally, a timer with a timing duration equal to the first detection interval duration may be set, and after the timer reaches the timing duration, it is determined that the first detection interval duration has been reached. Exemplarily, the first detection interval duration may be 900s.

[0063] Step 304B: after the first detection interval is reached, an active detection request is sent to the first server via the reverse proxy service using the first dedicated line.

[0064] After determining that the first detection interval has been reached, the client may use the first dedicated line to send an active detection request to the first server through the reverse proxy service to detect whether the first dedicated line has returned to normal.

[0065] Step 304C: when the number of consecutive successes of the active detection request exceeds a second number threshold, it is determined that the first dedicated line access is restored.

[0066] In order to ensure that the main line can provide services stably, a second number threshold is set. After the number of consecutive successful active detection requests exceeds the second number threshold, it is determined that the first dedicated line has returned to normal, thereby avoiding subsequent invalid recovery switching operations caused by accidental phenomena.

[0067] Optionally, the second number threshold may be smaller than the first number threshold, for example, the second number threshold is 4 times, and the first number threshold is 5 times. That is, the number of consecutive requests from failure to recovery of the server (dedicated line channel) is smaller than the number of consecutive requests from normal to failure of the server.

[0068] On the contrary, if the number of consecutive failures of the active detection request exceeds the third number threshold, that is, the main line is still not restored, then the second detection interval is set, and after the second detection interval is reached, the first dedicated line (main line) is detected again to see if it has returned to normal, that is, the first dedicated line is used again through the reverse proxy to send an active detection request to the first server. The second detection interval is set to be shorter than the first detection interval, so that it is possible to promptly detect whether the main line has returned to normal.

[0069] Exemplarily, the second detection interval may be 450 seconds long. The third number threshold may be the same as the first number threshold, or the third number threshold may be different from the first number threshold. For example, the third number threshold may also be 5 times.

[0070] Step 305: If the first dedicated line is restored, a restoration switch request for the main line is triggered.

[0071] After determining that the first dedicated line (main line) is restored, a restoration switching request for the main line may be immediately triggered, and the restoration switching request is used to instruct the reverse proxy service to switch the traffic path back to the main line.

[0072] Step 306: After the recovery switching request is triggered, a business service request is sent to the first server through the reverse proxy service using the first dedicated line.

[0073] After the recovery switching request is triggered, the client sends a business service request to the reverse proxy service, and the reverse proxy service sends the business service request to the first server through the first dedicated line.

[0074] Optionally, after the main line channel (first dedicated line channel) is confirmed to be restored, the client will continue to actively detect whether the first dedicated line channel is normal according to a specific detection cycle in addition to normal business service requests.

[0075] In this embodiment, after the main line path switches to the backup path due to an abnormality, the client will continue to detect whether the main line path has returned to normal, and after detecting that the main line path has returned to normal, it will switch back to the main line path in time to avoid continuing to use the backup path, resulting in a heavy load on the backup path and affecting the response speed of the service request.

[0076] In order to enable the reverse service proxy to have the above-mentioned fault switching and recovery switching functions, after deploying the reverse proxy service, it is necessary to set various detection parameters and switching strategies for the reverse proxy service so that the corresponding active detection and switching functions can be performed based on the detection parameters and switching parameters when applied.

[0077] Please refer to Figure 4 , which shows a flow chart of another method for automatically switching access to a server according to an exemplary embodiment of the present application. Figure 1 The client 110 shown in FIG. 4 is used as an example for explanation. As shown in FIG. 4 , the method includes:

[0078] Step 401: Based on the first periodic interval, an active detection request is sent to a first server via a reverse proxy service using a first dedicated line.

[0079] In an exemplary example, the process of configuring a reverse proxy service may include the following steps:

[0080] 1. Associating the reverse proxy service with the first dedicated line channel, and associating the reverse proxy service with the second dedicated line channel.

[0081] 2. Set the first dedicated line as the main line, and set the second dedicated line as the backup line.

[0082] 3. Configure the first detection parameter of the first dedicated line channel and the second detection parameter of the second dedicated line channel.

[0083] The reverse proxy service and the server make a one-to-many cross-configuration association, for example, associating the reverse proxy service with the first dedicated line, and associating the reverse proxy service with the second dedicated line, and setting the first dedicated line as the main line, and setting the second dedicated line as the backup line, and then configuring the first detection parameters of the first dedicated line and the second detection parameters of the second dedicated line.

[0084] Exemplarily, the first detection parameters may include the server address, the detection cycle parameters of active detection (first cycle interval length + second cycle interval length, the number of consecutive requests to judge from failure to recovery (i.e., the second number threshold), the number of consecutive requests to judge from normal to failure (i.e., the first number threshold), the link timeout, and the detection interval length; the second detection parameters include: the server address.

[0085] In a possible implementation, the client may send an active detection request to the first server through a reverse proxy service using a first dedicated line according to a pre-configured first detection parameter, specifically a first periodic interval duration.

[0086] Step 402: If the number of consecutive failures of the active detection request exceeds a first threshold, a failover request for the dedicated line is triggered.

[0087] Step 403: After the failover request is triggered, a business service request is sent to the second server through the reverse proxy service using the second dedicated line.

[0088] Step 404: after triggering the failover request, set the first detection interval duration.

[0089] The implementation of step 402 to step 404 can refer to the above embodiment, and this embodiment will not be repeated here.

[0090] Step 405, after the first detection interval is reached, based on the second cycle interval, an active detection request is sent to the first server through the reverse proxy service using the first dedicated line, and the second cycle interval is longer than the first cycle interval.

[0091] A detection cycle used when detecting the recovery of the main line is also configured. After reaching the first detection interval, the client sends an active detection request to the first server through the reverse proxy service using the first dedicated line based on the second cycle interval. In order to reduce the power consumption of the detection recovery and reduce the number of invalid detections, the second cycle interval is set to be longer than the first cycle interval. Exemplarily, the first cycle interval can be 30ms, and the second cycle interval can be 40ms.

[0092] Step 406: When the number of consecutive successes of the active detection request exceeds a second number threshold, it is determined that the first dedicated line access is restored.

[0093] Step 407: If the first dedicated line is restored, a restoration switch request for the main line is triggered.

[0094] Step 408: After the recovery switching request is triggered, a business service request is sent to the first server through the reverse proxy service using the first dedicated line.

[0095] The implementation of steps 406 to 408 may refer to the above embodiments, and will not be described in detail in this embodiment.

[0096] In this embodiment, by pre-configuring the switching parameters of the detection parameters of the reverse proxy service, the reverse proxy service can perform the corresponding detection function and switching function during the application process. Moreover, the detection cycle under normal conditions is shorter than the detection cycle under fault conditions, so that it is possible to timely detect whether the main line path is faulty, and at the same time, it is also possible to reduce the power consumption of detection recovery when the main line path fails.

[0097] Application Figure 1 The system architecture shown in the figure, the complete solution process provided by the embodiment of the present application is as follows:

[0098] 1. This application is different from the traditional network active-standby and application active-active modes. Network detection and switching at the application layer is called application active-standby.

[0099] 2. For business services, use Nginx to deploy reverse proxy services with the same number of dedicated lines, such as reverse proxy service A and reverse proxy service B in the figure;

[0100] 3. The reverse proxy service and the server-side server are cross-configured in a 1:2 relationship. For example, reverse proxy service A sets dedicated line A as the primary and dedicated line B as the backup. Reverse proxy service B sets dedicated line B as the primary and dedicated line A as the backup.

[0101] 4. Bind the service access entry IP provided by the user to the corresponding dedicated gateway. That is, dedicated gateway A binds the service access entry of server A, and dedicated gateway B binds the service access entry of server B.

[0102] 5. Set the upstream configuration file at the reverse proxy service layer, and set the detection parameters and judgment strategy:

[0103] a) peer address 1, failure tolerance = 10 times, backend unavailable mark time length = 900s; #main line;

[0104] b) peer address 2, marked as backup; # backup line;

[0105] c) Switching time parameters and strategies: cycle interval: 1s, number of requests to determine whether the server is recovering from failure: 4 times, number of requests to determine whether the server is normal from failure: 5 times, link timeout: 2s;

[0106] 6. Use the client to continuously send active detection requests to the server;

[0107] 7. When client A and client B access their own reverse proxy services, the default request will be sent to the main line. If the number of failure tolerances is exceeded, the backend service backup is marked as unavailable and the automatic backup address is requested; this triggers the main line failover;

[0108] 8. When the dedicated line A (main line) of the server is interrupted, the effect of the above parameter settings is: switch to the backup line after the main line fails: 10 seconds;

[0109] 9. At this time, the business traffic will use dedicated line channel B for traffic exchange. After 900 seconds, the fault line will be actively detected once every 1 second. If it is normal for 4 consecutive times, the main line will be reset to available status, and subsequent business requests will be forwarded using the main line. At this time, the main line recovery switch is triggered;

[0110] 10. When the server confirms that the main line has recovered from the fault, the effect of the above parameter settings is: the backup line switches back to the main line: 5 seconds;

[0111] 11. This architecture and switching solution uses active detection in the reverse proxy built-in strategy to automatically perform operations without manual intervention. It can achieve automatic switching and recovery at the application layer without modifying the configuration and strategy of the network dedicated gateway. The timeliness is 10 seconds, which is in line with expectations.

[0112] Please refer to Figure 5 , which is a schematic diagram of the structure of a device for automatically switching access to a server provided in an embodiment of the present application. The device is applied to a client, in which a reverse proxy service is deployed, for example, Figure 5 As shown, the device 500 includes:

[0113] A first sending module 501 is used to send an active detection request to a first server end through the reverse proxy service using a first dedicated line;

[0114] A first trigger module 502, configured to trigger a failover request for a dedicated line if the number of consecutive failures of the active detection request exceeds a first number threshold;

[0115] The second sending module 503 is used to send a business service request to a second server end through the reverse proxy service using a second dedicated line after triggering the failover request. The first server end is different from the second server end, and the first server end and the second server end have the same business service function.

[0116] Optionally, the first dedicated line is a main line, the second dedicated line is a backup line, and the device further includes:

[0117] A detection module, used for detecting whether the first dedicated line path is restored through the reverse proxy service after the failover request is triggered;

[0118] A second trigger module, configured to trigger a recovery switching request of the main line channel if the first dedicated line channel is recovered;

[0119] The third sending module is used to send the business service request to the first server through the reverse proxy service using the first dedicated line after the recovery switching request is triggered.

[0120] Optionally, the detection module is further used to:

[0121] After triggering the failover request, setting a first detection interval duration;

[0122] After the first detection interval is reached, sending the active detection request to the first server through the reverse proxy service using the first dedicated line;

[0123] When the number of consecutive successes of the active detection request exceeds a second number threshold, it is determined that the first dedicated line access is restored.

[0124] Optionally, the device further comprises:

[0125] A first setting module, configured to set a second detection interval duration when the number of consecutive failures of the active detection request exceeds a third number threshold, wherein the second detection interval duration is less than the first detection interval duration;

[0126] The fourth sending module is used to send the active detection request to the first server through the reverse proxy using the first dedicated line after the second detection interval is reached.

[0127] Optionally, the first sending module 501 is further configured to:

[0128] Based on the first periodic interval, sending the active detection request to the first server through the reverse proxy service using the first dedicated line;

[0129] The detection module is also used for:

[0130] After the first detection interval is reached, the active detection request is sent to the first server through the reverse proxy service using the first dedicated line based on a second cycle interval, and the second cycle interval is longer than the first cycle interval.

[0131] Optionally, the second sending module 503 is further configured to:

[0132] When the failover request is triggered and it is confirmed that the second dedicated line is not faulty, the business service request is sent to the second server through the reverse proxy service using the second dedicated line.

[0133] Optionally, the device further comprises:

[0134] an association module, used to associate the reverse proxy service with the first dedicated line path, and to associate the reverse proxy service with the second dedicated line path;

[0135] A second setting module, used to set the first dedicated line as a main line, and set the second dedicated line as a backup line;

[0136] The configuration module is used to configure a first detection parameter of the first dedicated line and a second detection parameter of the second dedicated line.

[0137] In summary, the embodiment of the present application provides a method for automatically switching access to a server by a client: by configuring a reverse proxy service, when a dedicated line fails, by switching the traffic access path of the reverse proxy service, that is, switching from the first dedicated line to the second dedicated line, the client can automatically switch access to the server in the event of a failure, thereby achieving the purpose of stopping the failure; moreover, by switching the traffic access path, the switching of the dedicated line can be indirectly achieved without changing the server address bound to the gateway, thereby saving the multi-process nodes of the business service contacting the cloud vendor to perform stop-loss operations such as changing the gateway server configuration, thereby improving the timeliness of stopping the loss.

[0138] The exemplary embodiment of the present application also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, the electronic device executes the method for automatically switching access to a service end according to the embodiment of the present application.

[0139] The exemplary embodiment of the present application also provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method for automatically switching access to a service end according to an embodiment of the present application.

[0140] The exemplary embodiment of the present application further provides a computer program product, including a computer program, wherein when the computer program is executed by a processor of a computer, it is used to enable the computer to execute the method for automatically switching access to a service end according to the embodiment of the present application.

[0141] refer to Figure 6, the structural block diagram of the electronic device 600 that can be used as the server or client of the present application will now be described, which is an example of a hardware device that can be applied to various aspects of the present application. The electronic device is intended to represent various forms of digital electronic computer equipment, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples, and are not intended to limit the implementation of the present application described and / or required herein.

[0142] like Figure 6 As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0143] A plurality of components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. The input unit 606 may be any type of device capable of inputting information to the electronic device 600, and the input unit 606 may receive input digital or character information, and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 607 may be any type of device capable of presenting information, and may include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 608 may include but is not limited to a disk, an optical disk. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and may include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0144] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSP), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above. For example, in some embodiments, Figure 2 , Figure 3 , Figure 4 The method shown may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. In some embodiments, the computing unit 601 may be configured to execute the computer program by any other suitable means (e.g., by means of firmware). Figure 2 , Figure 3 , Figure 4 The method shown.

[0145] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0146] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0147] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0148] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0149] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0150] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.

Claims

1. A method for automatically switching access to a server, characterized in that: The method is applied to a client, in which a reverse proxy service is deployed, and the method includes: Sending an active detection request to the first server using the first dedicated line through the reverse proxy service; If the number of consecutive failures of the active detection request exceeds the first number threshold, a failover request for the dedicated line is triggered; After triggering the failover request, a business service request is sent to a second server via the reverse proxy service using a second dedicated line, the first server is different from the second server, and the first server and the second server have the same business service function.

2. The method according to claim 1, characterized in that The first dedicated line is a main line, and the second dedicated line is a backup line. The method further includes: After triggering the failover request, detecting whether the first dedicated line access is restored through the reverse proxy service; If the first dedicated line is restored, triggering a restoration switch request for the main line; After the recovery switching request is triggered, the business service request is sent to the first service end through the reverse proxy service using the first dedicated line.

3. The method according to claim 2, characterized in that After triggering the failover request, detecting whether the first dedicated line path is restored by the reverse proxy service includes: After triggering the failover request, setting a first detection interval duration; After the first detection interval is reached, sending the active detection request to the first server through the reverse proxy service using the first dedicated line; When the number of consecutive successes of the active detection request exceeds a second number threshold, it is determined that the first dedicated line access is restored.

4. The method according to claim 3, characterized in that The method further comprises: When the number of consecutive failures of the active detection request exceeds a third number threshold, setting a second detection interval duration, wherein the second detection interval duration is less than the first detection interval duration; After the second detection interval is reached, the active detection request is sent to the first server through the reverse proxy using the first dedicated line.

5. The method according to claim 3, characterized in that: The sending of an active detection request to the first server by using the first dedicated line through the reverse proxy service includes: Based on the first periodic interval, sending the active detection request to the first server through the reverse proxy service using the first dedicated line; After the first detection interval is reached, sending the active detection request to the first server through the reverse proxy service using the first dedicated line path includes: After the first detection interval is reached, the active detection request is sent to the first server through the reverse proxy service using the first dedicated line based on a second cycle interval, and the second cycle interval is longer than the first cycle interval.

6. The method according to any one of claims 1 to 5, characterized in that: After triggering the failover request, sending a business service request to the second server through the reverse proxy service using the second dedicated line path includes: When the failover request is triggered and it is confirmed that the second dedicated line is not faulty, the business service request is sent to the second server through the reverse proxy service using the second dedicated line.

7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Associating the reverse proxy service with the first dedicated line access, and associating the reverse proxy service with the second dedicated line access; Setting the first dedicated line as a main line, and setting the second dedicated line as a backup line; A first detection parameter of the first dedicated line channel and a second detection parameter of the second dedicated line channel are configured.

8. A device for automatically switching access to a server, characterized in that: The device is applied to a client, a reverse proxy service is deployed in the client, and the device includes: A first sending module, used for sending an active detection request to a first server end through the reverse proxy service using a first dedicated line; A first trigger module, configured to trigger a failover request for a dedicated line if the number of consecutive failures of the active detection request exceeds a first number threshold; The second sending module is used to send a business service request to a second server end through the reverse proxy service using a second dedicated line after triggering the failover request. The first server end is different from the second server end, and the first server end and the second server end have the same business service function.

9. An electronic device, comprising: processor; as well as Memory for storing programs, The program includes instructions, and when the instructions are executed by the processor, the processor executes the method for automatically switching access to a service end according to any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method for automatically switching access to a service end according to any one of claims 1-7.