Multi-redis cluster query data automatic fault tolerance and routing policy management method
Through the automated fault tolerance and routing policy management method of multi-redis cluster query data, the problem of insufficient performance of traditional databases under high traffic is solved, and the system is stable and efficient query under high traffic conditions is realized, ensuring fast response to business data and servers reliability.
Patent Information
- Application Number
- CN202410799340.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-11-01
AI Technical Summary
Traditional database queries are difficult to meet system performance requirements under high traffic conditions, resulting in long-term requests and server downtime, affecting user experience.
The automatic fault tolerance and routing policy management methods of multi-redis cluster query data are adopted. Through the design and visual configuration of microservice architecture, combined query, exception detection and automatic fault tolerance of redis cluster are realized, ensuring that the system provides stable and efficient services under high traffic.
It improves the concurrency capability and stability of the system, ensures that some redis clusters can still provide stable query services when they are unavailable, realizes automatic fault tolerance and activation of multiple redis clusters, and ensures the efficiency and stability of business query data.
Smart Images

Figure CN118890384A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of microservice cache technology, and in particular to a multi-redis cluster query data automatic fault tolerance and routing strategy management method. Background Art
[0002] With the continuous development of the company's products and business, the number of customer requests is increasing, and the average daily access requests have gradually increased from tens of millions to hundreds of millions. The use of traditional database queries will not be able to meet the system performance, and may even directly lead to time-consuming business processing requests, which is more likely to cause server downtime, thus affecting user experience. Summary of the invention
[0003] In view of the problems existing in the prior art, the present invention provides a multi-redis cluster query data automatic fault tolerance and routing strategy management method, introduces the redis cluster query data technology, and responds the business data to the business caller in a timely, fast and efficient manner through memory query. In order to ensure the high efficiency and stability of the business, the technical architecture will have different servers, and form multiple redis cluster query data to ensure that the system can still provide services to the outside efficiently, stably and normally under the huge traffic peak scheduling.
[0004] The technical solution of the present invention is: a multi-redis cluster query data automatic fault tolerance and routing strategy management method, comprising the following steps:
[0005] S1. Configure multiple redis cluster addresses, multiple redis clusters free combination, the percentage of each redis cluster scheduling, the number of times and seconds of query exceptions, and cluster fuse processing configuration rules on the visualization page;
[0006] S2. The system dynamically loads and parses the redis cluster information and cluster fuse processing configuration rule information configured on the visualization page in step S1 into the system memory in real time;
[0007] S3, through the microservice technology architecture design, provides a single redis cluster query cache data interface and multiple redis cluster combination query cache data microservice interface;
[0008] S4. During the process of querying cache data in the redis cluster, the number of abnormal cache data queries in each redis cluster within a period of time is recorded. When the cumulative number of abnormal cache data queries within a certain period of time reaches the fuse configuration value, the redis cluster is removed and set to unavailable;
[0009] S5. Scan the unavailable redis cluster through a scheduled task triggered every ten seconds to detect whether it has been restored. If it has been restored, rejoin it to the available redis cluster to provide query cache data services, thereby realizing automatic detection of redis cluster services.
[0010] Furthermore, the step S1 includes the following steps:
[0011] S11. Visually add / delete / modify / check redis cluster groups, including attributes: cluster group name, cluster group code, and status;
[0012] S12. Visualization: Under the cluster group configuration, multiple redis cluster information can be dynamically added / deleted / modified, including attributes: redis cluster address, and percentage information of each redis cluster route;
[0013] S13. Visually configure the fault tolerance information of the redis cluster. If a certain number of query exceptions occur within a certain period of time, the cluster will be offline and will not provide business services.
[0014] Furthermore, the step S2 includes the following sub-steps:
[0015] S21, dynamically read the cluster group configuration, cyclically read each redis cluster to instantiate and detect whether the redis cluster is in an available state;
[0016] S22, dynamically read the redis cluster fault tolerance configuration information and load it into the application memory;
[0017] S23. Monitor cluster information, cluster combination configuration, and cluster fault tolerance configuration in real time. If the configuration changes, immediately instantiate the changed configuration into a redis cluster or reload the redis cluster fault tolerance information into the application memory.
[0018] Furthermore, the step S3 includes the following sub-steps:
[0019] S31. Provide a specified single redis cluster query microservice interface, match the redis cluster code passed in through the interface, and communicate with the corresponding redis cluster instance to query cache data;
[0020] S32. Provide a specified multi-redis cluster combination query microservice interface, match all redis cluster instances through the redis cluster combination code passed in through the interface, and then generate the priority level of the redis cluster used by the current query according to the percentage of multi-cluster routing scheduling, and obtain the value in redis according to the priority. If the redis cluster query is abnormal, poll the next redis cluster query, and so on. If the selected redis cluster query is normal, query the cached data response result.
[0021] Furthermore, the step S4 includes the following sub-steps:
[0022] S41. When the redis cluster queries cache data abnormally, the application system captures the abnormal information;
[0023] S42. In the exception capture logic, the time when the first abnormal query cache data of the redis cluster occurred is read from the application memory. If the data does not exist in the application memory, the current time is assigned and stored in the application memory, and the number of abnormal queries of the current redis cluster is obtained in the application memory. If the number of abnormal queries of the current redis cluster does not exist in the application memory, it is assigned to 1 and stored in the application memory;
[0024] S43. In the exception capture logic, the time when the first query cache data exception occurred in the redis cluster is obtained from the application memory. If it exists in the application memory, the query cache data exception time in the application memory is subtracted from the current time. When the difference is greater than or equal to the number of milliseconds in the fault tolerance configuration, the number of exceptions recorded in the application memory is reassigned to 1.
[0025] S44. In the exception capture logic, the time of the first query cache data exception of the redis cluster and the number of query cache data exceptions accumulated in the application memory are obtained from the application memory. If they exist, the query cache data exception time in the application memory is subtracted from the current time. When their difference is less than the number of milliseconds in the fault tolerance configuration, and the number of query cache data exceptions accumulated in the application memory is less than the number of tolerated exceptions in the fault tolerance configuration, the number of query cache data exceptions accumulated in the application memory is increased by 1 and stored in the application memory again;
[0026] S45. In the exception capture logic, the time of the first query cache data exception of the redis cluster and the number of query cache data exceptions accumulated in the memory are obtained from the application memory. If any, the query cache data exception time in the cache is subtracted from the current time. When the difference is greater than or equal to the number of milliseconds in the fault tolerance configuration, the current redis cluster is taken offline, and the application cache records the redis cluster information as unavailable.
[0027] Furthermore, the step S5 includes the following sub-steps:
[0028] S51. The scheduled task is triggered every ten seconds to read the unavailable set of redis cluster in the application cache;
[0029] S52, loop reading abnormal redis cluster set, through the ping (cluster availability detection command) instruction, detect whether the cluster is available; if available, remove it from the unavailable redis cluster set, reload it into the available redis cluster set and delete the redis cluster query cache data abnormality count and query data abnormality count start time from the memory; if the redis cluster is still unavailable, wait for the next scheduled task to continue detection.
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] 1. Improve concurrency capabilities and increase overall response time through caching technology.
[0032] 2. Improve stability and use a multi-redis cluster architecture mode to ensure that stable and efficient query services can still be provided even when some redis clusters are unavailable.
[0033] 3. Multiple redis clusters automatically tolerate faults and detect activity, and multiple redis clusters automatically go online and offline, thus ensuring efficient and stable business query data. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 The figure shows the visualized redis cluster configuration implemented by the present invention.
[0035] Figure 2 The figure shows the overall design architecture diagram of multiple redis cluster sets implemented by the present invention.
[0036] Figure 3 Shown is a memory diagram of a redis cluster dynamically loaded application implemented by the present invention.
[0037] Figure 4 The figure shows a fault-tolerant architecture diagram of a redis cluster implemented in the present invention. DETAILED DESCRIPTION
[0038] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings and embodiments of the present invention.
[0039] like Figure 1 , 2 As shown in , 3, and 4, the present invention provides a multi-redis cluster query data automatic fault tolerance and routing strategy management method, which includes the following steps S1 to S4:
[0040] S1. Based on the actual business situation, the technical staff maintains the currently available redis cluster set on the unified management platform, and configures the cluster call ratio value and the query data abnormality fuse value (if a certain number of query abnormalities occur within a certain period of time, the redis cluster will not provide services).
[0041] Step S1 includes the following sub-steps:
[0042] S11. The technical staff will build multiple redis clusters in the planned servers, and maintain the configuration information of multiple redis cluster groups through visual addition / deletion / modification / query, including the attributes: cluster group name, cluster group code, and status.
[0043] S12. According to the performance of each redis cluster, the percentage information of dynamic redis cluster routing (the percentage of query data carried by each redis cluster) under the cluster group configuration is visualized.
[0044] S13. Business personnel estimate the amount of data requests for each business. When the query cache data in the redis cluster is unstable, they visually configure the redis cluster query data abnormality fault tolerance information (if a certain number of query abnormalities occur within a certain period of time, the cluster will be offline and will not provide business services).
[0045] In the implementation of the present invention, Figure 1 Visually configure redis cluster information:
[0046] A. Visually add / delete / modify / query redis cluster group information (group code, group name, query abnormal fault tolerance value).
[0047] B. Visually add / delete / modify / check redis cluster information (cluster address, proportion of query data carried).
[0048] S2. As the visualization configuration changes, the application dynamically initializes the redis cluster connection pool and loads the cluster data volume ratio configuration and redis cluster query data abnormality tolerance value into the application memory.
[0049] Step S2 includes the following sub-steps:
[0050] S21. Monitor the visualization configuration information in real time, dynamically obtain the redis cluster configuration information, and then instantiate each redis cluster into a connection pool and detect the redis cluster as an available service.
[0051] S22. Dynamically load the redis cluster query exception fault tolerance configuration and load it into the application memory. If it exists in the application memory, it is overwritten again.
[0052] In the implementation of the present invention, the process is implemented in the application service Figure 3 , Figure 2 :
[0053] A. Visual operation configuration information is sent to the kafka (asynchronous message queue) cluster.
[0054] B. The application cluster system acts as a consumer of Kafka (asynchronous message queue) cluster messages. When there is a visual operation data change message, Kafka (asynchronous message queue) distributes the message to each business application system. The business application system dynamically loads the Redis cluster instantiation, cluster query exception tolerance, and cluster data carrying ratio configuration into the application system memory. If it exists in the application system memory, it will be overwritten.
[0055] S3, through the microservice technology architecture design, provides a single redis cluster data query function and multiple redis cluster combined data query function services.
[0056] Step S3 includes the following sub-steps:
[0057] S31. Based on the microservice technology architecture design, a single redis cluster data query service is provided. The business application system matches the corresponding redis cluster instance through the incoming redis cluster code to query the data. If no match is found or the cluster is abnormally offline, the business system query data abnormality is responded.
[0058] S32. Based on the microservice technology architecture design, a multi-redis cluster combination query data interface is provided. Through the incoming redis cluster combination code, the application system matches all the redis cluster instances of the combination, and then sorts the priority of the redis cluster combination corresponding to the data query according to the percentage of multi-cluster routes (the proportion of data carried by each cluster). The cached data is queried through the redis cluster according to the priority. If the query result is empty, the next redis cluster query is performed.
[0059] S33. When the redis cluster query cache data is abnormal, the next redis cluster in the sorting is polled for query, and so on. If the redis cluster query cache data is normal, the query result value is responded.
[0060] In the implementation of the present invention, the corresponding implementation process is as follows Figure 2 , the description is as follows:
[0061] A. Based on the microservice technology architecture design, the business application system triggers the redis cluster data query service.
[0062] B. The redis cluster query application system obtains the redis cluster instance through rule configuration.
[0063] C. Get the cached data stored in the redis cluster. If the query data is successful, directly respond to the query result of the business end. If the query data is abnormal, re-configure the rule to obtain the next new available redis cluster instance, and then re-execute the process of step B.
[0064] D. If a redis query data exception occurs in step C, the query data exception information is sent to the exception handling module.
[0065] S4. Redis cluster query data exception fuse processing: During the business data query process, the corresponding redis cluster query data exception information is recorded in the application memory and the occurrence time is recorded. When the cumulative number of query exceptions within a period of time reaches the query exception fuse configuration value, the redis cluster is kicked out of the business query and set to unavailable.
[0066] Step S4 includes the following sub-steps:
[0067] S41. When the redis cluster query data response is abnormal during the query process, the application system captures the exception.
[0068] S42. After the application system captures the exception, it obtains the time when the first exception occurred in the redis cluster from the application memory. If it does not exist in the application memory, it assigns the current time, sets the cumulative number of cluster query data exceptions to 1, and stores it in the application memory.
[0069] S43. If the time of the first data query exception can be obtained from the application memory, the data query exception time in the application memory is subtracted from the current time. When the difference is greater than or equal to the number of milliseconds in the fault tolerance configuration, the cumulative number of data query exceptions recorded in the application memory is reassigned to 1 and stored in the application memory again.
[0070] S44. If the time of the first query data anomaly and the number of query data anomalies accumulated in the application memory are obtained from the application memory, the anomaly time in the cache is subtracted from the current time. When their difference is less than the number of milliseconds in the fault tolerance configuration, and the accumulated number of query data anomalies in the application memory is less than the number of query anomalies in the fault tolerance configuration, then the accumulated number of query data anomalies in the application memory is increased by 1 and reloaded into the application memory.
[0071] S45. If the time of the first abnormal query data occurrence and the accumulated number of abnormal records in the application memory are obtained from the application memory, the abnormal query data time recorded in the application memory is subtracted from the current time. When their difference is greater than or equal to the number of milliseconds in the abnormal fault tolerance configuration, it means that the abnormal fault tolerance condition is met, the current redis cluster is immediately offline, and the abnormal redis cluster information is recorded in the application memory.
[0072] S5, redis cluster is restored and available for online processing. Circuit breaker recovery: The application starts a scheduled task to scan the abnormal redis cluster set every ten seconds, and uses the ping (cluster availability detection command) command to check whether the redis cluster has recovered and is available. If it has recovered, it will rejoin the business to provide query data services.
[0073] Step S5 includes the following sub-steps:
[0074] S51, circuit breaker recovery processing, the application scans and reads the abnormal redis cluster set in the application memory every ten seconds.
[0075] S52, loop reading the abnormal redis cluster set, and use the ping (cluster availability detection command) instruction to detect whether the cluster has recovered to an available state. If it has recovered to be available, remove the abnormal redis cluster set, reload it into the available redis cluster set, and delete the abnormal count and abnormal count start time of the redis cluster query data from the application memory. If the detection is still in an unavailable state, wait for the next task to continue detection.
[0076] In the implementation of the present invention, the corresponding implementation process of step S4 and step S5 is as follows: Figure 2 , Figure 4 , the description is as follows:
[0077] A. After receiving the redis cluster query data exception notification, the redis exception handling module first obtains the redis cluster query exception fault tolerance configuration information (how many times the query exception is sent within how many seconds)
[0078] B. Processing of abnormal accumulated number of records in application system memory:
[0079] If the number of exception accumulations does not exist, the application memory sets the number of exception accumulations to 1, and the validity period of the exception accumulation storage is the number of seconds in the exception fault tolerance configuration;
[0080] If the number of abnormal cumulative records exists, and the number of abnormal cumulative records plus 1 is less than the number of abnormal records in the fault tolerance configuration, the number of abnormal cumulative records will continue to be increased by 1 and stored in the application memory. The validity period of this value storage remains unchanged.
[0081] If the accumulated number of exceptions exists, and the accumulated number of exceptions plus 1 is greater than or equal to the number of exceptions in the fault-tolerant configuration, the redis rule configuration module is notified to set the redis cluster to be unavailable.
[0082] C. The scheduled task is triggered every ten seconds: query the unavailable cluster set information from the redis rule configuration module and process it in a loop:
[0083] 1. Use ping (cluster availability detection command) to detect whether the redis cluster is available. If it is available, the redis rule configuration module will be notified to reset the redis cluster to be available, continue to provide business query data services, and clear the accumulated records of redis cluster query exceptions from the application memory.
[0084] 2. If the redis cluster is unavailable, wait for the next scheduled task to be triggered.
[0085] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A multi-redis cluster query data automatic fault tolerance and routing strategy management method, characterized in that: The following steps are involved: S1. Configure multiple redis cluster addresses, multiple redis clusters free combination, the percentage of each redis cluster scheduling, the number of times and seconds of query exceptions, and cluster fuse processing configuration rules on the visualization page; S2. The system dynamically loads and parses the redis cluster information and cluster fuse processing configuration rule information configured on the visualization page in step S1 into the system memory in real time; S3, through the microservice technology architecture design, provides a single redis cluster query cache data interface and multiple redis cluster combination query cache data microservice interface; S4. During the process of querying cache data in the redis cluster, the number of abnormal cache data queries in each redis cluster within a period of time is recorded. When the cumulative number of abnormal cache data queries within a certain period of time reaches the fuse configuration value, the redis cluster is removed and set to unavailable; S5. Scan the unavailable redis cluster through a scheduled task triggered every ten seconds to detect whether it has been restored. If it has been restored, rejoin it to the available redis cluster to provide query cache data services, thereby realizing automatic detection of redis cluster services.
2. According to claim 1, a multi-redis cluster query data automatic fault tolerance and routing strategy management method is characterized in that: The step S1 comprises the following steps: S11. Visually add / delete / modify / check redis cluster groups, including attributes: cluster group name, cluster group code, and status; S12. Visualization: Under the cluster group configuration, multiple redis cluster information can be dynamically added / deleted / modified, including attributes: redis cluster address, and percentage information of each redis cluster route; S13. Visually configure the fault tolerance information of the redis cluster. If a certain number of query exceptions occur within a certain period of time, the cluster will be offline and will not provide business services.
3. According to claim 1, a multi-redis cluster query data automatic fault tolerance and routing strategy management method is characterized in that: The step S2 comprises the following sub-steps: S21, dynamically read the cluster group configuration, cyclically read each redis cluster to instantiate and detect whether the redis cluster is in an available state; S22, dynamically read the redis cluster fault tolerance configuration information and load it into the application memory; S23. Monitor cluster information, cluster combination configuration, and cluster fault tolerance configuration in real time. If the configuration changes, immediately instantiate the changed configuration into a redis cluster or reload the redis cluster fault tolerance information into memory.
4. According to claim 1, a multi-redis cluster query data automatic fault tolerance and routing strategy management method is characterized in that: The step S3 comprises the following sub-steps: S31. Provide a single redis cluster query microservice interface, match the corresponding redis cluster instance with the redis cluster code passed in through the interface to communicate and query cache data; S32. Provide a specified multi-redis cluster combination query microservice interface, match all redis cluster instances through the redis cluster combination code passed in through the interface, and then randomly generate the priority level of the redis cluster used for the current query according to the percentage of multi-cluster routes, and obtain the value in redis according to the priority. If the redis cluster query is abnormal, poll the next redis cluster query, and so on. If the selected redis cluster query is normal, query the cached data response result.
5. According to claim 1, a multi-redis cluster query data automatic fault tolerance and routing strategy management method is characterized in that: The step S4 comprises the following sub-steps: S41. When the redis cluster queries cache data abnormally, the application system captures the abnormal information; S42. In the exception capture logic, the memory is read to obtain the time when the first abnormal query cache data of the redis cluster occurs. If the data does not exist in the application memory, the current time is assigned and stored in the application memory, and the current number of abnormal redis cluster queries is obtained in the application memory. If the current number of abnormal redis cluster queries does not exist in the application memory, it is assigned to 1 and stored in the memory; S43. In the exception capture logic, the time when the first query cache data exception occurred in the redis cluster is obtained from the application memory. If it exists in the application memory, the query cache data exception time in the application memory is subtracted from the current time. When the difference is greater than or equal to the number of milliseconds in the fault tolerance configuration, the number of exceptions recorded in the application memory is reassigned to 1. S44. In the exception capture logic, the time of the first query cache data exception of the redis cluster and the number of query cache data exceptions accumulated in the memory are obtained from the application memory. If they exist, the query cache data exception time in the memory is subtracted from the current time. When their difference is less than the number of milliseconds in the fault tolerance configuration, and the number of query cache data exceptions accumulated in the cache is less than the number of tolerable exceptions in the tolerance configuration, the number of query cache data exceptions accumulated in the memory is increased by 1 and stored in the memory again; S45. In the exception capture logic, the time of the first query cache data exception of the redis cluster and the number of query cache data exceptions accumulated in the memory are obtained from the application memory. If any, the query cache data exception time in the cache is subtracted from the current time. When the difference is greater than or equal to the number of milliseconds in the fault tolerance configuration, the current redis cluster is taken offline, and the application cache records the redis cluster information as unavailable.
6. According to claim 1, a multi-redis cluster query data automatic fault tolerance and routing strategy management method is characterized in that: The step S5 comprises the following sub-steps: S51. The scheduled task is triggered every ten seconds to read the unavailable set of redis cluster in the application cache; S52, loop reading the abnormal redis cluster set, and use the ping command to detect whether the cluster is available; if available, remove it from the unavailable redis cluster set, reload it into the available redis cluster set, and delete the redis cluster query cache data abnormality count and query data abnormality count start time from the memory; if the redis cluster is still unavailable, wait for the next scheduled task to continue detection.
