A distributed channel automatic switching method and storage medium
Through the combination of polling detection and distributed flow control locks, automatic switching and retouching of channels are achieved, solving the waste and business failure caused by channel switching in 24-hour high concurrent account opening scenarios, and improving the reliability and efficiency of the system.
Patent Information
- Application Number
- CN202210593309.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2042-05-27
AI Technical Summary
The existing technology is difficult to meet the needs of 24-hour high concurrent account opening scenarios, and it is easy to have waste or business failure when manually switching channels.
Through polling health detection and availability monitoring, automatic switching and back-cut channels, and diverting traffic step by step through distributed flow locks, ensuring high availability of channels and precise control of traffic.
Automatic switching and switching back of channels in 24-hour high-concurrency scenarios are achieved, avoiding waste and business failure caused by manual switching, and improving system reliability and efficiency.
Smart Images

Figure CN114928563B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a distributed channel automatic switching method and a storage medium. Background Art
[0002] With the rapid development of business, the online two-factor identity verification API encapsulated by the RPA robot could not meet the needs of high-concurrency online account opening scenarios. The bank further connected to the People's Bank of China's PICP system to provide a full API-level online two-factor identity verification service that supports high concurrency and high availability.
[0003] With the further development of the business, the service hours of the People's Bank of China's PICP system (7:30-19:30) could not meet the needs of online 24-hour account opening scenarios. Further, a high-concurrency and high-availability API service with 24-hour service was connected through a third-party online two-factor identity verification service provider with public security qualification certification.
[0004] Since the third-party online identity verification service provider is not the People's Bank of China and has a high service fee, while the data of the People's Bank of China is more accurate and free, but the service time is 7*12 hours, and the switching service is not on time, when manually switching channels, it is often the case that the People's Bank of China channel is still available after the switch, resulting in waste, or the People's Bank of China channel has been closed before the switch, resulting in business failure. Therefore, a set of channel weights is needed, which can automatically switch back and forth step by step according to the health of the channel and control the flow of each channel. Summary of the invention
[0005] The purpose of the present invention is to provide a distributed channel automatic switching method and storage medium in view of the deficiencies in the prior art.
[0006] To achieve the above object, in a first aspect, the present invention provides a distributed channel automatic switching method, comprising:
[0007] Step 1: Monitor the health status of the main channel in use through polling health detection. If the health monitoring result of the main channel is unhealthy, switch to the backup channel;
[0008] Step 2: After switching to the backup channel, monitor and determine whether the health status of the main channel is restored through polling availability monitoring. If restored, switch back to the main channel;
[0009] Step 3: Through the channel tags maintained by health detection and availability monitoring, the highest priority channel currently available is instantly obtained in the real-time process, and the traffic is diverted to the lower priority channels step by step through the distributed flow control lock;
[0010] Step 4: Maintain an abnormal request pool by executing the results of the specified channel to assist in the health detection and availability monitoring.
[0011] Furthermore, it also includes: monitoring the health status of the currently used channel through polling health detection, if the currently used channel is unhealthy, downgrading and maintaining the channel mark, as follows:
[0012] Obtain the tFlag of the currently used main channel from the distributed memory storage middleware, and use the tFlag to determine whether the currently used channel is the expected switch-back channel. If it is the expected switch-back channel, the process ends directly, otherwise, the process proceeds to the next step.
[0013] Get the current error set from the distributed memory storage middleware. If the error set is empty, it means that the current channel is healthy and exits directly. Otherwise, get the error request from the error set.
[0014] The error request is executed through the detection channel. If the result is still an error, multiple attempts are requested in the replacement error set. After reaching the preset number of times, the tFlag of the current main channel in use will be downgraded and its value will be adjusted to a lower-level channel.
[0015] Furthermore, the step 2 specifically includes:
[0016] Step 2.1 obtains the tFlag of the currently used channel from the distributed memory storage middleware, and determines whether the currently used channel is a monitoring channel based on the tFlag of the currently used channel. If it is a monitoring channel, proceed to the next step, otherwise end directly;
[0017] Step 2.2: Execute the error request in the error set through the expected switching back channel. If the execution result is successful, multiple attempts are requested in the replacement error set. After reaching the preset number of times, the specified channel tFlag will be switched back and its value will be adjusted to the expected switching back channel value.
[0018] Furthermore, the step 3 specifically includes:
[0019] Step 3.1, obtain the currently used channel tFlag from the distributed memory storage middleware;
[0020] Step 3.2, obtain the current specified channel token from the distributed memory storage middleware;
[0021] Step 3.3: If the specified channel token is obtained, execute the task through the current specified channel to obtain the result;
[0022] Step 3.4: If the specified channel token cannot be obtained, switch to a lower-level channel and try to obtain the channel token until the corresponding channel token is obtained or it is downgraded to the lowest-level channel;
[0023] Step 3.5: If the channel execution result is failure, the request is placed in the error collection of the corresponding channel.
[0024] Furthermore, the distributed flow control lock is implemented based on the token bucket algorithm, as follows:
[0025] Step 4.1: Preload the number of tokens supported by each channel into the distributed memory storage middleware;
[0026] Step 4.2: When the request is diverted to the corresponding channel, try to obtain the token from the token bucket corresponding to the channel;
[0027] Step 4.3: If the token is successfully obtained, the task can be executed from the corresponding channel. After the task is completed and the result is obtained, the token will be returned regardless of success or failure.
[0028] In a second aspect, the present invention provides a storage medium storing a computer program, which, when loaded by a processor, implements the distributed channel automatic switching method as claimed above.
[0029] Beneficial effects: 1. Through polling of the health of the channels in use, the channels are monitored asynchronously, with high sensitivity and parameter configurability, and downgraded and switched sensitively when they are unhealthy;
[0030] 2. Through polling, the expected channel availability is monitored asynchronously, with high sensitivity and parameter configurability, and the expected switching back channels are monitored, and the switching back is sensitive when they are restored;
[0031] 3. Improve monitoring efficiency by implementing abnormal pool-assisted health detection and availability monitoring;
[0032] 4. Through hierarchical flow control based on the token bucket algorithm, the flow of each channel is accurately and parameter-configured;
[0033] 5 Based on distributed memory storage middleware, it can support distributed applications, high availability, fast and lightweight. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 is a structural diagram of a distributed channel automatic switching method according to an embodiment of the present invention;
[0035] Figure 2 This is a schematic diagram of the health detection process of the currently used channel according to an embodiment of the present invention;
[0036] Figure 3 The figure is a schematic diagram of the expected channel availability monitoring process according to an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. The embodiments are implemented based on the technical solution of the present invention. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0038] like Figures 1 to 3 As shown, an embodiment of the present invention provides a distributed channel automatic switching method, including:
[0039] Step 1: Monitor the health status of the main channel in use through polling health detection. If the health monitoring result of the main channel is unhealthy, switch to the backup channel. It should be noted that the M channel in the figure refers to the main channel, that is, the channel with the highest weight level. The S channel refers to the backup channel, that is, the channel with a lower weight level. The Sn channel refers to a channel in the backup channel, where n is a positive integer greater than 0, and the smaller n is, the higher the weight level; health refers to whether the current state of the channel is stable. If there are many abnormalities, it is considered unhealthy, and if it tends to be fully successful, it is considered healthy.
[0040] It is also preferred to monitor the health status of the currently used channel through polling health detection. If the currently used channel is unhealthy, the channel tag is downgraded for maintenance, as follows:
[0041] Obtain the tFlag of the main channel currently in use from the distributed memory storage middleware, and use the tFlag to determine whether the channel currently in use is the expected switch-back channel. If it is the expected switch-back channel, end directly; otherwise, execute the next step.
[0042] Get the current error set from the distributed memory storage middleware. If the error set is empty, it means that the current channel is healthy and exits directly. Otherwise, get the error request from the error set.
[0043] The error request is executed through the detection channel. If the result is still an error, multiple attempts are requested in the replacement error set. After reaching the preset number of times, the tFlag of the current main channel in use will be downgraded and its value will be adjusted to a lower-level channel.
[0044] Step 2: After switching to the backup channel, monitor and determine whether the health status of the main channel has been restored through polling availability monitoring. If restored, switch back to the main channel. Specifically, the following steps are included:
[0045] Step 2.1 obtains the tFlag of the currently used channel from the distributed memory storage middleware, and determines whether the currently used channel is a monitoring channel based on the tFlag of the currently used channel. If it is a monitoring channel, proceed to the next step, otherwise end directly.
[0046] Step 2.2: Execute the error request in the error set through the expected switching back channel. If the execution result is successful, multiple attempts are requested in the replacement error set. After reaching the preset number of times, the specified channel tFlag will be switched back and its value will be adjusted to the expected switching back channel value.
[0047] Step 3: Through the channel tags maintained by health detection and availability monitoring, the highest priority channel currently available is instantly obtained in the real-time process, and the traffic is diverted to the low-priority channels step by step through the distributed flow control lock. The specific steps include:
[0048] Step 3.1, obtain the currently used channel tFlag from the distributed memory storage middleware.
[0049] Step 3.2: Get the current specified channel token from the distributed memory storage middleware.
[0050] Step 3.3: If the specified channel token is obtained, execute the task through the current specified channel to obtain the result.
[0051] Step 3.4: If the specified channel token cannot be obtained, switch to a lower-level channel and try to obtain the channel token until the corresponding channel token is obtained or it is downgraded to the lowest-level channel.
[0052] Step 3.5: If the channel execution result is failure, the request is placed in the error collection of the corresponding channel.
[0053] The above distributed flow control lock is preferably implemented based on the token bucket algorithm, as follows:
[0054] Step 4.1: Preload the number of tokens supported by each channel into the distributed memory storage middleware.
[0055] Step 4.2: When the request is diverted to the corresponding channel, try to obtain the token from the token bucket corresponding to the channel.
[0056] Step 4.3: If the token is successfully obtained, the task can be executed from the corresponding channel. After the task is completed and the result is obtained, the token will be returned regardless of success or failure.
[0057] Step 4: Maintain an abnormal request pool by executing the results of the specified channel to assist in the health detection and availability monitoring.
[0058] Based on the above embodiments, those skilled in the art can easily understand that the present invention also provides a storage medium storing a program, which implements the above-mentioned distributed channel automatic switching method when loaded by the processor. It should be understood that the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0059] The above is only a preferred embodiment of the present invention. It should be noted that for ordinary technicians in this technical field, other parts not specifically described belong to the prior art or common knowledge. Several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered as the protection scope of the present invention.
Claims
1. A distributed channel automatic switching method, characterized in that: include: Step 1: Monitor the health status of the main channel in use through polling health detection. If the health monitoring result of the main channel is unhealthy, switch to the backup channel; Step 2: After switching to the backup channel, monitor and determine whether the health status of the main channel is restored through polling availability monitoring. If restored, switch back to the main channel; Step 3: The channel mark tFlag maintained by health detection and availability monitoring is used to instantly obtain the currently available highest priority channel in the real-time process, and then divert the traffic to the low-priority channels step by step through the distributed flow control lock; Step 4: Maintain an error set by executing the results of the specified channel to assist in the health detection and availability monitoring; It also includes: monitoring the health status of the currently used channel through polling health detection. If the currently used channel is unhealthy, the channel mark tFlag is downgraded and maintained, as follows: Obtain the currently used channel flag tFlag from the distributed memory storage middleware, and determine whether the channel corresponding to the currently used channel flag tFlag is the lowest priority channel according to the channel flag tFlag. If it is the lowest priority channel, end directly, otherwise execute the next step; Obtain the error set of the channel corresponding to the currently used channel tag tFlag from the distributed memory storage middleware. If the error set is empty, it means that the channel corresponding to the currently used channel tag tFlag is healthy, and exit directly. Otherwise, obtain the error request from the error set; Execute the error request through the channel corresponding to the currently used channel flag tFlag. If the result is still an error, request multiple attempts. After reaching the preset number of attempts, the currently used channel flag tFlag will be downgraded and its value will be adjusted to a lower-level channel flag tFlag. The step 2 specifically includes: Step 2.1 obtains the currently used channel flag tFlag from the distributed memory storage middleware, and determines whether the channel corresponding to the currently used channel flag tFlag is the main channel according to the currently used channel flag tFlag. If it is the main channel, the process ends, otherwise, proceed to the next step; Step 2.2: Execute the error request in the corresponding error set through the main channel. If the execution result is successful, the request is tried multiple times. After reaching the preset number of times, the channel flag tFlag currently in use is switched back and its value is adjusted to the channel flag tFlag of the main channel.
2. A distributed channel automatic switching method according to claim 1, characterized in that: The step 3 specifically includes: Step 3.1, obtain the currently used channel flag tFlag from the distributed memory storage middleware; Step 3.2, according to the channel flag tFlag currently in use, obtain the channel token token corresponding to the channel flag tFlag currently in use from the distributed memory storage middleware; Step 3.3, if the channel token is obtained, execute the task and obtain the result through the channel corresponding to the currently used channel flag tFlag; Step 3.4: If the channel token cannot be obtained, switch to a lower-level channel and try to obtain the channel token until the corresponding channel token is obtained or it is downgraded to the lowest priority channel; Step 3.5: If the channel execution result is failure, the corresponding request is placed in the error collection of the corresponding channel.
3. A distributed channel automatic switching method according to claim 1, characterized in that: The distributed flow control lock is implemented based on the token bucket algorithm, as follows: Step 4.1: Preload the number of tokens supported by each channel into the distributed memory storage middleware; Step 4.2: When the request is diverted to the corresponding channel, try to obtain the token from the token bucket corresponding to the channel; Step 4.3: If the token is successfully obtained, the task will be executed from the corresponding channel. After the task is completed and the result is obtained, the token will be returned regardless of whether the result is successful or not.
4. A storage medium storing a computer program, characterized in that: When the program is loaded by the processor, the distributed channel automatic switching method described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Processing method and device for recovery of payment channel
CN108665251A
Data transmission method and device and processor
CN112260895A
