Dynamic shunting method under double data sources, electronic equipment and storage medium
By monitoring the heartbeat and real-time quality indicators of the data source, dynamically adjusting the traffic switching rate, solving the problem of inability to flexibly switch in the existing technology, realizing priority and smooth switching of the main data source, improving the flexibility and reliability of the system.
Patent Information
- Application Number
- CN202510663426.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-07-29
AI Technical Summary
In the prior art, in the dual data source scenario, the switching rate cannot be dynamically changed based on the current use data source and the expected quality, resulting in inflexible traffic allocation and unstable system.
By monitoring the heartbeat status of the data source and obtaining the average response time and error rate in real time, calculating the data source quality change weight, dynamically adjusting the traffic switching rate, realizing priority and smooth switching of the main data source.
Improves traffic allocation flexibility and system reliability in dual data source scenarios, avoids extensive switching in fixed configurations, and ensures service stability and recovery efficiency.
Smart Images

Figure CN120389984A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of dynamic shunting of data sources, and particularly to a dynamic shunting method, an electronic device and a storage medium under dual data sources. Background Art
[0002] In the case of introducing dual data sources in a service, since data source A is reliable and data source B has relatively poor quality, in the routing strategy, data source A is used as the primary data source and data source B is used as the backup data source. However, when data source A occasionally fails to be called or times out, it is necessary to switch to data source B; in the prior art, generally, middleware configuration is used to switch half or all of the traffic to data source B at one time, rather than using a probe method to slowly switch to data source B; when data source A recovers, currently all traffic is switched to data source A, rather than using a probe method to quickly switch to data source A; in the existing data source routing strategy, generally, middleware such as nacos is used to implement, and the strategy switch is performed according to the fixed configuration of the middleware, and it cannot be dynamically switched according to the quality of the current data source; in the case where the priorities of the dual data sources called in the traffic allocation are not equal, a distribution method that biases towards switching the primary data source cannot be provided; therefore, how to dynamically change the data source switching rate according to the comparison between the currently used data source and the expected quality has become an urgent technical problem to be solved. Summary of the Invention
[0003] For the above technical problems, the technical solution adopted by the present invention is as follows: According to the first aspect of the present application, a dynamic shunting method under dual data sources is provided, and the method includes the following steps: S100, at each preset monitoring time point, determine whether the heartbeats of the primary data source and the backup data source are alive; S200, if the heartbeat of the primary data source is alive and the current traffic is not all allocated to the primary data source, then cut back a part of the traffic allocated to the backup data source to the primary data source; S300, if the heartbeat of the primary data source is alive and the current traffic is all allocated to the backup data source, then obtain the average response duration and error rate currently corresponding to the primary data source; S400, according to the average response duration and error rate corresponding to the primary data source at the current monitoring time point, determine the data source quality change weight E of the primary data source z ; where E z is used to predict the direction of the quality change of the primary data source; S500, if E z < 0, then accelerate cutting back a part of the traffic allocated to the backup data source to the primary data source; S600, if E z > 0, then slow down cutting back a part of the traffic allocated to the backup data source to the primary data source.
[0004] According to another aspect of the present application, a non-transitory computer-readable storage medium is further provided, in which at least one instruction or at least one program segment is stored, and the at least one instruction or at least one program segment is loaded and executed by a processor to implement the above-mentioned dynamic shunting method under dual data sources.
[0005] According to another aspect of the present application, an electronic device is further provided, including a processor and the above-mentioned non-transitory computer-readable storage medium.
[0006] The present invention has at least the following beneficial effects: The dynamic shunting method under dual data sources of the present invention aims at the problems in the prior art that it is impossible to dynamically switch according to the data source quality, the switching rate is fixed and it is impossible to bias towards the primary data source, etc. By gradually switching back the traffic when the heartbeat of the primary data source is alive, it avoids the extensive operation of all or half switching at one time under the fixed configuration of the middleware; uses the average response time and error rate to determine the weight of the change in data source quality, and can real-time sense the change direction of the primary data source quality. When the weight of the change in data source quality is less than 0, it speeds up the switching back of the traffic to quickly utilize the high-quality service of the restored primary data source. When the weight of the change in data source quality is greater than 0, it slows down the switching back of the traffic to avoid the influence of the quality fluctuation of the primary data source on the service stability, and realizes the adjustment of the dynamic switching rate based on the actual quality of the data source; at the same time, when the primary data source is available, it preferentially switches back the traffic, which meets the business requirements of the high reliability of the primary data source, provides an intelligent allocation strategy that biases towards the primary data source, effectively solves the problem in the prior art that it is impossible to dynamically change the switching rate according to the comparison between the currently used data source and the expected quality, and improves the flexibility, rationality of traffic allocation and the overall service reliability of the system in the dual data source scenario. Description of the Drawings
[0007] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0008] Figure 1 It is a flowchart of the dynamic shunting method under dual data sources provided by the embodiments of the present invention. Detailed Embodiments
[0009] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention.
[0010] It should be noted that based on this disclosure, those skilled in the art should understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement the device and / or practice the method. In addition, this device can be implemented and this method can be practiced using other structures and / or functions in addition to one or more of the aspects described herein.
[0011] The following will refer to Figure 1 the flowchart of the dynamic traffic splitting method under a dual data source shown below to introduce a dynamic traffic splitting method under a dual data source.
[0012] The dynamic traffic splitting method under this dual data source may include the following steps: S100, at each arrival of a preset monitoring time point, determine whether the heartbeats of the primary data source and the backup data source are alive.
[0013] In this embodiment, there are a preset primary data source and a backup data source, and both the primary data source and the backup data source can perform the current allocation; the heartbeat monitoring is performed at a preset time interval, such as monitoring the heartbeat status of the primary data source and the backup data source every second / minute, and confirming whether the data source is alive through network detection or interface call, providing a basic judgment basis for traffic switching.
[0014] S200, if the heartbeat of the primary data source is alive and the current traffic is not all allocated to the primary data source, then switch back a part of the traffic allocated to the backup data source to the primary data source.
[0015] In this embodiment, the traffic is gradually switched back when the primary data source is available. If the primary data source is alive and the current traffic is not all allocated to the primary data source, that is, part or all of the traffic is in the backup data source, then the traffic of the backup data source is gradually switched back to the primary data source to avoid service fluctuations caused by a one-time full switch.
[0016] Further, step S200 includes the following steps: S210, obtain a preset traffic dynamic factor n; where n is used to represent the allocation situation of the current traffic to the primary data source and the backup data source; 0 ≤ n ≤ K; K is the maximum value of the preset traffic dynamic factor.
[0017] In this embodiment, a traffic dynamic factor n is preset. n is an integer from 0 to K, and is used to represent the current traffic allocation state. When n = 0, all traffic is allocated to the standby data source. When n = K, all traffic is allocated to the primary data source. The value range of K can be from 5 to 10. For example, K = 7.
[0018] S220, update n = n + 1.
[0019] In this embodiment, by adjusting the value of n, traffic switching is realized. That is, n increases each time the traffic is switched back, and the switching amplitude is controlled. The larger n is, the higher the proportion of traffic switched back to the primary data source.
[0020] S230, according to n, switch back a part of the traffic allocated to the standby data source to the primary data source, so that the traffic allocated to the primary data source is L z =(1 - 1 / 2 n ) × LU, and the traffic L allocated to the standby data source b = 1 / 2 n × LU; where LU is the current total traffic.
[0021] In this embodiment, the traffic of the primary data source: L z =(1 - 1 / 2ⁿ) × LU, approaching the total traffic LU as n increases; the traffic of the standby data source: L b = 1 / 2ⁿ × LU, approaching 0 as n increases. For example, when n = 1, A is allocated 50% of the traffic and B is allocated 50%; when n = 2, A is allocated 75% and B is allocated 25%, achieving an exponential progressive switch-back.
[0022] The above steps have the following beneficial effects: Fine-grained traffic control: Achieve a smooth "less first and then more" switch through an exponential function, avoiding data source load imbalance caused by sudden traffic changes.
[0023] Quantify the allocation state: n, as an intermediate variable, clearly reflects the current switching progress, facilitating system monitoring and policy adjustment.
[0024] S300, if the heartbeat of the primary data source is alive and all the current traffic is allocated to the standby data source, obtain the current average response time and error rate corresponding to the primary data source.
[0025] In this embodiment, when the primary data source recovers but all the current traffic is on the standby data source, it is necessary to collect the average response time and error rate of the primary data source in real time as the core parameters for quality evaluation. The average response time can reflect the processing speed of the corresponding data source, and the error rate can reflect the service stability of the corresponding data source.
[0026] S400, according to the average response time and error rate corresponding to the primary data source at the current monitoring time point, determine the data source quality change weight E corresponding to the primary data sourcez ; Among them, E z is used to predict the direction of the change in the quality of the primary data source.
[0027] In this embodiment, by the changing trends of the response duration and the error rate, the direction of the quality change of the primary data source is quantified, that is, rising or falling. E z Positive and negative values respectively indicate that the quality becomes better or worse.
[0028] Furthermore, E z = M×(Y1 - Y) / Y + (1 - M)×(X1 - X) / X; where X1 is the current average response duration corresponding to the primary data source, Y1 is the current error rate corresponding to the primary data source, X is the maximum response duration corresponding to the primary data source, and Y is the maximum error rate corresponding to the primary data source.
[0029] In this embodiment, the maximum response duration and the maximum error rate corresponding to the primary data source can be obtained by analyzing a large amount of historical data; if X1 < X and Y1 < Y (the performance is better than the threshold), then (E1 - E) / E is a negative value. E z < 0, indicating that the quality of the primary data source becomes better; on the contrary, E z > 0, indicating that the quality of the primary data source becomes worse.
[0030] Combining the two indicators of response speed and error rate, it comprehensively reflects the service quality of the data source; by adjusting the index priority through M (for example, if emphasizing the error rate, M takes 0.8), it adapts to different business scenarios.
[0031] S500, if E z < 0, then accelerate to switch back a part of the traffic allocated to the standby data source to the primary data source.
[0032] Furthermore, step S500 may include the following steps: S510, update n = n + 2.
[0033] Compared with the normal switch-back (n + 1), when accelerating, n increases by 2 each time, accelerating the switch-back process.
[0034] S520, according to n, switch back a part of the traffic allocated to the standby data source to the primary data source, so that the traffic allocated to the primary data source is L z = (1 - 1 / 2 n )×LU, and the traffic L b allocated to the standby data source = 1 / 2 n ×LU; where LU is the current total traffic.
[0035] Recalculate L using n = current value + 2 z and L b, enabling the primary data source to obtain more traffic. For example, when n increases from 2 to 4, the traffic of the primary data source increases from 75% to 93.75%.
[0036] S530, if n > K, then all the traffic allocated to the backup data source is switched back to the primary data source.
[0037] If n exceeds the maximum threshold K, directly switch all traffic to the primary data source to avoid formula failure.
[0038] The above steps have at least the following beneficial effects: Quickly restore high-quality services: When the quality of the primary data source improves significantly, accelerate the switch-back by incrementing n in a jump manner, reducing the inefficient use of the backup data source.
[0039] Boundary condition handling: By restricting n ≤ K, ensure that the traffic allocation formula is always valid and avoid logical errors.
[0040] S600, if E z > 0, then slow down the process of switching back a part of the traffic allocated to the backup data source to the primary data source.
[0041] Furthermore, step S600 may include the following steps: S610, update n = n + 1.
[0042] S620, according to n, switch back a part of the traffic allocated to the primary data source to the primary data source, such that the traffic allocated to the primary data source is L z = ω × (1 - 1 / 2 n ) × LU, and the traffic allocated to the backup data source L b = LU - L z ; where LU is the current total traffic, ω is a preset weight, and 0 < ω < 1.
[0043] In this embodiment, by reducing the allocation ratio of the primary data source through ω (e.g., ω = 0.8, L z = 0.8 × (1 - 1 / 2ⁿ) × LU), the switching-back speed is slowed down.
[0044] S630, if n > K, then all the traffic allocated to the backup data source is switched back to the primary data source.
[0045] If n exceeds the maximum threshold K, directly switch all traffic to the primary data source to avoid formula failure.
[0046] When the quality of the primary data source is unstable, by reducing the allocation ratio or slowing down the increment speed, avoid routing more traffic to the primary data source with degraded performance; ω provides a configurable slowdown amplitude to adapt to business scenarios with different risk tolerances.
[0047] Furthermore, after step S600, the method further includes the following steps: S700, if E z = 0, then maintain the switching rate of the current traffic.
[0048] In this embodiment, if E z = 0, it means that there is no obvious change in the quality of the primary data source. Therefore, do not adjust n or the traffic allocation ratio, maintain the current switching speed, and avoid meaningless frequent adjustments. Avoid triggering unnecessary traffic adjustments due to short-term fluctuations in the quality of the data source, reduce system overhead; maintain the existing policy during the period of stable quality to prevent service instability caused by policy oscillations.
[0049] Further, after step S600, the method may further include the following steps: S800, if the heartbeat of the primary data source is not alive and the heartbeat of the standby data source is alive, and the current traffic is not all allocated to the standby data source, then switch back a part of the traffic allocated to the primary data source to the standby data source.
[0050] S810, if the heartbeat of the primary data source is not alive and the heartbeat of the standby data source is alive, and the current traffic is all allocated to the primary data source, then obtain the average response duration and error rate corresponding to the standby data source currently.
[0051] In this embodiment, if the heartbeat of the primary data source is not alive and the heartbeat of the standby data source is alive, and the traffic is not all in the standby data source, then gradually switch the traffic of the primary data source to the standby data source; if all the traffic is in the primary data source, then collect the quality indicators (response duration, error rate) of the standby data source.
[0052] S820, determine the data source quality change weight E corresponding to the standby data source according to the average response duration and error rate corresponding to the standby data source at the current monitoring time point b ; where E b is used to predict the direction of the quality change of the standby data source.
[0053] In this embodiment, the method for determining the data source quality change weight E corresponding to the standby data source is the same as the method for determining the data source quality change weight E of the primary data source in the above embodiment, and will not be elaborated here. b is the same as the method for determining the data source quality change weight E of the primary data source in the above embodiment, and will not be elaborated here. z will not be elaborated here.
[0054] S830, if E b < 0, then accelerate switching back a part of the traffic allocated to the primary data source to the standby data source.
[0055] S840, if E z > 0, then slow down switching back a part of the traffic allocated to the primary data source to the standby data source.
[0056] In this embodiment, the switching logic of steps S830-S840 is the same as the switching logic of steps S500-S600 in the above embodiment, that is, the weight E of the backup data source quality change is changed by b Dynamically adjust the speed of the tangential backup data source, that is, E b <0 Speed up cutting, E b >0 slows down the cutting, which will not be described here.
[0057] The method of this embodiment not only supports master-to-standby switching, but also supports standby-to-master reverse adjustment, building a complete dual-data source mutual backup mechanism; avoiding blind reliance on the standby data source, dynamically determining the switching rate based on its actual performance, and improving the rationality of the fault-tolerant strategy.
[0058] Furthermore, after step S600, the method further includes the following steps: S900: If the heartbeat of the primary data source and the heartbeat of the backup data source are both not alive, an alarm is generated and the current traffic distribution is maintained.
[0059] In this embodiment, when the heartbeats of both the primary data source and the backup data source are not alive, an alarm is generated to alert the administrator, and the current traffic distribution is maintained without switching, to prevent meaningless retries from causing system crashes.
[0060] When dual data sources fail, alarms are triggered quickly, while invalid switching operations are avoided, buying time for manual intervention. By maintaining existing allocations, chain reactions are prevented, minimizing the impact on core businesses in extreme failures.
[0061] Heartbeat monitoring and gradual switchback replace the one-time switching of the middleware's fixed configuration, reducing the impact of sudden traffic surges on the primary data source. Ez is calculated based on real-time performance indicators, linking the switching strategy to the actual quality of the data source rather than relying on preset rules. Intelligent rate adjustment is supported: the switchback speed is dynamically adjusted according to the direction of quality changes, taking into account both recovery efficiency and stability.
[0062] By calculating weights based on real-time quality indicators (response time, error rate), a "data-driven" switching strategy is implemented, rather than relying on fixed configurations. Progressive switching utilizes the traffic dynamic factor n to achieve exponentially smooth segmentation, avoiding service fluctuations caused by sudden increases or decreases in traffic. Bidirectional adaptation supports dynamic adjustment of both master-to-slave and slave-to-master traffic, and flexibly adjusts the rate based on changes in data source quality. Full-link fault tolerance covers all scenarios, including data source survival detection, quality assessment, and extreme fault handling, improving system reliability and fault tolerance.
[0063] The method of this embodiment effectively solves the problems of "inability to dynamically switch, fixed rate, lack of bias" in the background technology through a closed loop of "monitoring, evaluation, and adjustment", and provides an accurate, intelligent, and reliable solution for traffic distribution in dual data source scenarios.
[0064] The method of this embodiment addresses the problems in the prior art, such as the inability to dynamically switch according to the data source quality, the fixed switching rate, and the inability to bias towards the primary data source. By gradually switching back the traffic when the primary data source is heartbeat alive, it avoids the rough operation of a one-time all or half switching under the fixed configuration of the middleware. Using the average response time and error rate to determine the weight of the data source quality change, it can sense the change direction of the primary data source quality in real time. When the weight of the data source quality change is less than 0, it speeds up the switching back of the traffic to quickly utilize the high-quality service of the restored primary data source. When the weight of the data source quality change is greater than 0, it slows down the switching back of the traffic to avoid the impact of the primary data source quality fluctuation on the service stability, realizing the dynamic switching rate adjustment based on the actual quality of the data source. At the same time, when the primary data source is available, it preferentially switches back the traffic, meeting the business requirements of the high reliability of the primary data source, providing an intelligent allocation strategy that biases towards the primary data source, effectively solving the problem in the prior art that the switching rate cannot be dynamically changed according to the comparison between the currently used data source and the expected quality, and improving the flexibility, rationality of the traffic allocation and the overall service reliability of the system in the dual data source scenario.
[0065] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that these steps must be performed in that specific order, or that all the shown steps must be performed to achieve the desired result. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.
[0066] The embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one segment of program related to a method in the method embodiment. The at least one instruction or the at least one segment of program is loaded and executed by the processor to implement the method provided in the above embodiment.
[0067] The program product can adopt any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include: an electrical connection with one or more wires, a portable 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0068] A computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The readable signal medium may also be any readable medium other than a readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.
[0069] The program code contained on the readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0070] The program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or, it can be connected to an external computing device (e.g., by using an Internet service provider to connect through the Internet).
[0071] Embodiments of the present invention also provide an electronic device, including a processor and the aforementioned non-transitory computer-readable storage medium.
[0072] The electronic device is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of this application.
[0073] The electronic device is presented in the form of a general-purpose computing device. The components of the electronic device may include but are not limited to: the aforementioned at least one processor, the aforementioned at least one memory, and a bus connecting different system components (including the memory and the processor).
[0074] Wherein, the memory stores program code, and the program code can be executed by the processor, so that the processor executes the steps in various embodiments described in this specification.
[0075] The memory may include a readable medium in the form of volatile memory, such as random access memory (RAM) and / or cache memory, and may further include read-only memory (ROM).
[0076] The memory may also include program / utility with a set (at least one) of program modules, such as but not limited to: an operating system, one or more application programs, other program modules, and program data, and the implementation of a network environment may be included in each or some combination of these examples.
[0077] The bus may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus structures.
[0078] The electronic device may also communicate with one or more external devices (such as a keyboard, a pointing device, a Bluetooth device, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device, and / or communicate with any device that enables the electronic device to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication may be carried out through an input / output (I / O) interface. Also, the electronic device may communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter. The network adapter communicates with other modules of the electronic device through the bus. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0079] Through the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software, or can be implemented by a combination of software and necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which may be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0080] An embodiment of the present invention also provides a computer program product, which includes program code. When the program product runs on an electronic device, the program code is used to cause the electronic device to execute the steps in the methods according to various exemplary embodiments of the present invention described above in this specification.
[0081] Although some specific embodiments of the present invention have been described in detail by way of examples, those skilled in the art should understand that the above examples are for illustrative purposes only and not for limiting the scope of the present invention. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the present invention.
Claims
1. A dynamic shunting method under a dual data source, characterized in that, The method includes the following steps: S100. At each preset monitoring time point, determine whether the heartbeats of the primary data source and the backup data source are alive; S200. If the heartbeat of the primary data source is alive and the current traffic is not fully allocated to the primary data source, then switch back a part of the traffic allocated to the backup data source to the primary data source; S300. If the heartbeat of the primary data source is alive and the current traffic is fully allocated to the backup data source, then obtain the current average response time and error rate corresponding to the primary data source; S400, determine the data source quality change weight E corresponding to the primary data source according to the average response duration and error rate corresponding to the current monitoring time point of the primary data source z ; where E z is used to predict the direction of the quality change of the primary data source; S500, if E z <0, then accelerate the process of switching back a portion of the traffic allocated to the backup data source to the primary data source; S600, if E z > 0, then slow down and switch back a part of the traffic allocated to the standby data source to the primary data source.
2. The dynamic shunt method under the dual data sources according to claim 1, wherein Step S200 includes the following steps: S210. Obtain a preset traffic dynamic factor n; where n is used to represent the allocation situation of the current traffic to the primary data source and the backup data source; 0 ≤ n ≤ K; K is the maximum value of the preset traffic dynamic factor; S220. Update n = n + 1; S230. According to n, switch back a part of the traffic allocated to the backup data source to the primary data source, so that the traffic allocated to the primary data source is L z = (1 - 1 / 2 n ) × LU, and the traffic L allocated to the backup data source b = 1 / 2 n × LU; where LU is the current total traffic.
3. The dynamic shunt method under the dual data sources according to claim 1, characterized in that, E z = M×(Y1 - Y) / Y + (1 - M)×(X1 - X) / X; where X1 is the average response time currently corresponding to the main data source, Y1 is the error rate currently corresponding to the main data source, X is the maximum response time corresponding to the main data source, and Y is the maximum error rate corresponding to the main data source.
4. The dynamic shunt method under dual data sources according to claim 1, wherein Step S500 includes the following steps: S510. Update n = n + 2; S520, according to n, switch back a part of the traffic allocated to the backup data source to the primary data source, so that the traffic allocated to the primary data source is L z = (1 - 1 / 2 n ) × LU, and the traffic L allocated to the backup data source b = 1 / 2 n × LU; where LU is the current total traffic S530. If n > K, then switch all the traffic allocated to the backup data source back to the primary data source.
5. The dynamic shunting method under dual data sources according to claim 1, characterized in that Step S600 includes the following steps: S610. Update n = n + 1; S620, according to n, switch back a part of the traffic allocated to the primary data source to the primary data source, so that the traffic allocated by the primary data source is L z = ω × (1 - 1 / 2 n ) × LU, the traffic L allocated by the backup data source b = LU - L z ; where LU is the current total traffic, ω is a preset weight, and 0 < ω < 1; S630. If n > K, then switch all the traffic allocated to the backup data source back to the primary data source.
6. The dynamic shunt method under the dual data sources according to claim 1, wherein After step S600, the method further includes the following steps: S700, if E z = 0, then maintain the switching rate of the current flow rate.
7. The dynamic shunt method under dual data sources according to claim 1, characterized in that After step S600, the method further includes the following steps: S800. If the heartbeat of the primary data source is not alive, the heartbeat of the backup data source is alive, and the current traffic is not fully allocated to the backup data source, then switch back a part of the traffic allocated to the primary data source to the backup data source; S810. If the heartbeat of the primary data source is not alive, the heartbeat of the backup data source is alive, and the current traffic is fully allocated to the primary data source, then obtain the current average response time and error rate corresponding to the backup data source; S820. Determine the data source quality change weight E corresponding to the standby data source according to the average response duration and error rate corresponding to the points within the current monitoring time of the standby data source b ; where E b is used to predict the direction of the change in the quality of the standby data source; S830, if E b <0, then accelerate the process of switching back a portion of the traffic allocated to the primary data source to the standby data source; S840, if E z > 0, then slow down and switch back a part of the traffic allocated to the primary data source to the standby data source.
8. The dynamic shunting method under dual data sources according to claim 1, wherein After step S600, the method further includes the following steps: S900. If the heartbeats of both the primary data source and the backup data source are not alive, then generate an alarm prompt and maintain the current traffic allocation.
9. A non-transitory computer-readable storage medium storing at least one instruction or at least one program segment, characterized in that, The at least one instruction or the at least one program is loaded and executed by a processor to implement the dynamic traffic splitting method under a dual data source as described in any one of claims 1-8.
10. An electronic device, characterized in that, It includes a processor and the non-transitory computer-readable storage medium described in claim 9.