Data backup and recovery method, device, storage medium and computer equipment
By monitoring the health status of the Redis cluster in real time and performing data backup and snapshots in the event of failure, combined with the activity-level data recovery strategy, the data recovery time-consuming problem of Redis cluster failure is solved, and the stability and user experience of the activity system of the e-commerce platform are improved.
Patent Information
- Application Number
- CN202411332896.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2044-09-24
AI Technical Summary
In the prior art, the data recovery method in the case of failure of Redis cluster is time-consuming and complex, and cannot meet the needs of fast response, affecting the stability and user experience of the e-commerce platform activity system.
Monitor the health status of the Redis cluster in real time, use preset backup and snapshot mechanisms to back up data in the event of failure, and determine the target data recovery strategy based on the activity level, and use the method of switching between the primary and secondary clusters or recreating activity rules for data recovery.
It significantly improves the availability and data security of the Redis cluster, reduces business interruption time, and improves the reliability and user experience of the e-commerce activity system.
Smart Images

Figure CN119105913B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data backup and recovery method, device, storage medium, and computer equipment. Background Art
[0002] In the high-traffic internet e-commerce environment, the stability and responsiveness of the event system are crucial to user experience. Because the event system relies heavily on Redis cache, any failure or data consistency issue in the Redis cluster will cause business interruption, severely impacting service quality and user engagement.
[0003] Currently, when a Redis cluster fails, data is mainly restored manually. This data recovery method is time-consuming and complex, and cannot meet the needs of rapid response. Summary of the Invention
[0004] The purpose of this application is to solve at least one of the above-mentioned technical deficiencies, especially the technical deficiencies that the data recovery methods in the prior art are time-consuming and complex and cannot meet the needs of rapid response.
[0005] The present application provides a data backup and recovery method, which includes:
[0006] During the target event held on the e-commerce platform, real-time monitoring of the health status of the Redis cluster associated with the target event;
[0007] When an abnormality in the Redis cluster service is detected, data backup and snapshot of the Redis cluster are performed through a preset backup and snapshot mechanism;
[0008] A target data recovery strategy corresponding to the activity level of the target activity is determined, and the activity data stored in the Redis cluster is recovered using the target data recovery strategy.
[0009] Optionally, during the period when the target activity is held on the e-commerce platform, real-time monitoring of the health status of the Redis cluster associated with the target activity includes:
[0010] When creating a target activity on an e-commerce platform, a corresponding Redis cluster is allocated to the target activity according to the activity level of the target activity, and the association between the activity ID of the target activity and the Redis cluster is recorded;
[0011] During the period when the target activity is held on the e-commerce platform, the Redis cluster associated with the target activity is determined according to the association relationship between the activity ID and the Redis cluster, and the health status of the Redis cluster is monitored in real time.
[0012] Optionally, allocating a corresponding Redis cluster to the target activity according to the activity level of the target activity includes:
[0013] determining an activity magnitude of the target activity;
[0014] Obtaining an activity cluster association record table, wherein the activity cluster association record table records the association between all activities on the e-commerce platform whose end time does not exceed a preset time threshold and the assigned Redis clusters;
[0015] According to the activity cluster association record table and the activity quantity conversion relationship between different activity levels, the number of activities associated with each Redis cluster is counted;
[0016] According to the number of activities associated with each Redis cluster and the activity level of the target activity, a corresponding Redis cluster is allocated to the target activity. When the activity level of the target activity is a big promotion activity, the Redis cluster allocated to the target activity includes a primary cluster and a secondary cluster.
[0017] Optionally, determining the activity level of the target activity includes:
[0018] Determine user engagement levels and channel order types for the target campaign;
[0019] The activity level of the target activity is determined according to the user participation level and the channel order type.
[0020] Optionally, the real-time monitoring of the health status of the Redis cluster associated with the target activity includes:
[0021] Using a pre-defined cluster anomaly detection method, the health status of the Redis cluster associated with the target activity is monitored in real time;
[0022] Alternatively, a pre-configured health monitoring model is used to monitor the health status of the Redis cluster associated with the target activity in real time.
[0023] Optionally, determining a target data recovery strategy corresponding to the activity level of the target activity, and using the target data recovery strategy to recover the activity data stored in the Redis cluster includes:
[0024] When the activity level of the target activity is a major promotion activity, the access priority between the primary cluster and the secondary cluster associated with the target activity is modified to switch the primary cluster and the secondary cluster.
[0025] Optionally, determining a target data recovery strategy corresponding to the activity level of the target activity, and using the target data recovery strategy to recover the activity data stored in the Redis cluster includes:
[0026] When the activity level of the target activity is not a big promotion activity, a replacement activity with the same activity rules as the target activity is recreated, and the corresponding Redis cluster is reallocated for the replacement activity. Then, the activity registration records of the target activity and all order MQ messages during the activity are synchronized to the reallocated Redis cluster.
[0027] This application also provides a data backup and recovery device, including:
[0028] A real-time monitoring module is used to monitor the health status of the Redis cluster associated with the target activity in real time during the target activity held on the e-commerce platform;
[0029] A backup and snapshot module is used to perform data backup and snapshot of the Redis cluster through a preset backup and snapshot mechanism when an abnormality in the Redis cluster service is detected;
[0030] The data recovery module is used to determine a target data recovery strategy corresponding to the activity level of the target activity, and to recover the activity data stored in the Redis cluster using the target data recovery strategy.
[0031] The present application also provides a computer-readable storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the data backup and recovery method described in any of the above embodiments.
[0032] The present application also provides a computer device, comprising: one or more processors, and a memory;
[0033] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the data backup and recovery method described in any one of the above embodiments are performed.
[0034] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0035] The data backup and recovery method, device, storage medium and computer equipment provided by the present application can monitor the health status of the Redis cluster associated with the target activity in real time during the target activity held on the e-commerce platform; when a Redis cluster service abnormality is detected, the Redis cluster can be backed up and snapshotted through a preset backup and snapshot mechanism, which can not only effectively reduce the risk of data loss, but also improve the availability and data security of the Redis cluster; then, the present application can also determine the target data recovery strategy corresponding to the activity level of the target activity, and use the target data recovery strategy to restore the activity data stored in the Redis cluster, thereby significantly improving the reliability and stability of the Internet e-commerce activity system, reducing the business interruption time caused by Redis cluster failure, and thus improving user experience and enterprise operation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0037] Figure 1 A flowchart of a data backup and recovery method provided in an embodiment of the present application;
[0038] Figure 2 A schematic diagram of the Redis cache-A policy recovery process provided in an embodiment of the present application;
[0039] Figure 3 A schematic diagram of the Redis cache-B policy recovery process provided in an embodiment of the present application;
[0040] Figure 4 This is a diagram of the active Redis cluster business architecture provided in the embodiment of this application;
[0041] Figure 5 A schematic diagram of the structure of a data backup and recovery device provided in an embodiment of the present application;
[0042] Figure 6 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0044] In one embodiment, Figure 1 As shown, Figure 1 A flowchart of a data backup and recovery method provided in an embodiment of the present application; the present application provides a data backup and recovery method, which may include:
[0045] S110: During a target event held on the e-commerce platform, monitor the health status of the Redis cluster associated with the target event in real time.
[0046] In this step, since the activity system is highly dependent on Redis cache, any failure or data consistency issues in the Redis cluster will cause business interruption, which will seriously affect service quality and user engagement. Based on this, when creating a target activity, this application can allocate a corresponding Redis cluster for it. This allocation process can dynamically adjust resource allocation based on activity traffic, thereby avoiding system overload during the recovery process.
[0047] After allocating a specific Redis cluster to the target activity to store activity data, this application can also associate the target activity with the Redis cluster. In this way, during the target activity held by the e-commerce platform, the health status of the Redis cluster associated with the target activity can be monitored in real time, so that timely intervention can be made when its health status is poor, thereby quickly restoring the activity data.
[0048] Among them, when monitoring the health status of the Redis cluster associated with the target activity, the present application can determine the common fault types of the Redis cluster and perform fault detection based on the fault type. For example, common Redis cluster fault types may include node failure: detecting whether a single Redis node has failed; cluster failure: detecting whether the entire Redis cluster has failed; network failure: detecting whether there is a problem with the network connection; performance bottleneck: detecting whether the Redis cluster has a performance bottleneck, such as excessive CPU or memory usage. The present application can adopt a variety of detection methods for the above-mentioned fault types, such as heartbeat monitoring: detecting the online status of the Redis node through heartbeat packets; command response: regularly sending simple commands (such as PING) to Redis to check the response time and command execution; performance indicators: monitoring Redis performance indicators, such as CPU usage, memory usage, etc.; log analysis: analyzing Redis log files to identify potential signs of failure. The present application can select one or more detection methods for detection based on actual conditions, and there is no limitation here.
[0049] S120: When a Redis cluster service anomaly is detected, data backup and snapshot of the Redis cluster are performed through a preset backup and snapshot mechanism.
[0050] In this step, after real-time monitoring of the health status of the Redis cluster associated with the target activity during the target activity on the e-commerce platform through S110, if a Redis cluster service anomaly is detected, data backup and snapshot of the Redis cluster can be performed through the preset backup and snapshot mechanism, thereby reducing the risk of data loss.
[0051] Specifically, when monitoring the health status of the Redis cluster associated with the target activity, the present application can use an automatic triggering mechanism to detect whether the health status of the current Redis cluster meets the triggering conditions for triggering the backup and snapshot mechanism, and when the conditions are met, trigger the backup and snapshot mechanism to perform data backup and snapshot on the Redis cluster.
[0052] Among them, the triggering condition of the present application can be a fault threshold: defining the threshold for fault triggering, such as the response time exceeding the preset value, the CPU usage exceeding 80%, etc.; it can also be the number of consecutive failures: defining the number of consecutive failures as a triggering condition, such as three consecutive heartbeat detection failures are considered to be a fault; it can also be other triggering conditions, which can be set according to the actual situation. After the present application sets the triggering conditions, it can determine whether to trigger the backup and snapshot mechanism according to the corresponding trigger logic. For example, when the monitored indicators of the present application exceed the preset threshold, the backup and snapshot mechanism is triggered. The number of consecutive failures can also be recorded. When the recorded number reaches the preset number, the backup and snapshot mechanism is triggered.
[0053] Furthermore, the backup and snapshot mechanism of this application includes but is not limited to Redis configuration, backup scripts, and backup storage. Redis configuration refers to enabling AOF persistence and periodic snapshot generation in the Redis configuration file; backup scripts refer to writing scripts or using existing backup tools (such as redis-backup) to automate backups and snapshots; and backup storage refers to storing backup files in persistent storage media, such as NAS or cloud storage services. The specific backup and snapshot mechanism can be set based on actual circumstances and is not limited here.
[0054] In addition, this application can not only start the backup and snapshot mechanism when the Redis cluster service is abnormal, but also regularly start the backup and snapshot mechanism under normal circumstances to regularly back up the active data stored in the Redis cluster.
[0055] For example, the backup mechanism of the present application may include full backup and incremental backup. Specifically, the present application may perform full backups regularly to save all data of the Redis cluster, or perform incremental backups after the full backup to save only the data changes since the last backup. The snapshot mechanism of the present application may include snapshot files, AOF logs, etc. Since Redis itself supports the generation of snapshot files (.rdb), the present application may generate snapshots regularly or when a failure occurs, and the present application may also use the Append Only File (AOF) persistence method to record all write commands executed by Redis, and then replay these commands when the failure is recovered.
[0056] Furthermore, when this application detects a fault in the Redis cluster, it can trigger an alarm through real-time fault detection on the operation and maintenance platform; it can also trigger an SLS log alarm through business anomalies in the MQ consumer service process; it can also trigger DingTalk / Feishu alarms by accessing redis cluster data anomalies through the front-end interface. The specific alarm method can be set according to the actual situation and is not restricted here.
[0057] S130: Determine a target data recovery strategy corresponding to the activity level of the target activity, and use the target data recovery strategy to recover the activity data stored in the Redis cluster.
[0058] In this step, when a Redis cluster service anomaly is detected through S120, data backup and snapshot of the Redis cluster can be performed through the preset backup and snapshot mechanism. A target data recovery strategy corresponding to the activity level of the target activity can also be determined, and the target data recovery strategy can be used to restore the activity data stored in the Redis cluster, thereby improving the availability and data security of the Redis cluster.
[0059] It is understandable that, since the e-commerce platform of this application needs to access different CPS channel orders when holding events, and implement the corresponding events through CPS channel orders, the CPS channel orders here refer to orders from major e-commerce platforms on the Internet, such as JD.com, Taobao, Vipshop, etc. When creating different activities, this application can set different user groups for user participation and statistical rules for the activities. Through the above rules, based on the number of users of this platform, the user participation level and order level of this activity can be preliminarily evaluated, and then the activity level of this activity can be determined.
[0060] Next, the present application can formulate different data recovery strategies for different activity levels, so that the preset data recovery strategy can be used in combination with incremental synchronization technology to quickly restore the affected Redis instance. For example, when the activity level of the present application is a big promotion activity, since the user participation level and order level of this type of activity are the highest, therefore, for this type of activity, the present application can pre-formulate a corresponding data recovery strategy; and when the activity level of the present application is a non-big promotion activity, since the user participation level and order level of this type of activity are relatively low, therefore, for this type of activity, the present application can also pre-formulate a corresponding data recovery strategy. In this way, after determining the activity level of the target activity, the corresponding target data recovery strategy can be determined, and the activity data stored in the Redis cluster can be restored according to the target data recovery strategy, which can significantly improve the reliability and stability of the activity system.
[0061] In the above embodiment, during the period when the e-commerce platform holds a target activity, the health status of the Redis cluster associated with the target activity can be monitored in real time; when a Redis cluster service anomaly is detected, the Redis cluster can be backed up and snapshotted through a preset backup and snapshot mechanism, which can not only effectively reduce the risk of data loss, but also improve the availability and data security of the Redis cluster; then, the present application can also determine a target data recovery strategy corresponding to the activity level of the target activity, and use the target data recovery strategy to restore the activity data stored in the Redis cluster, thereby significantly improving the reliability and stability of the Internet e-commerce activity system, reducing the business interruption time caused by Redis cluster failures, and thus improving user experience and enterprise operation efficiency.
[0062] In one embodiment, during the period when the e-commerce platform hosts a target activity, real-time monitoring of the health status of a Redis cluster associated with the target activity in S110 may include:
[0063] S111: When creating a target activity on an e-commerce platform, a corresponding Redis cluster is allocated to the target activity according to the activity level of the target activity, and an association between the activity ID of the target activity and the Reids cluster is recorded.
[0064] S112: During the period when the target activity is held on the e-commerce platform, a Redis cluster associated with the target activity is determined according to the association relationship between the activity ID and the Reids cluster, and a health status of the Redis cluster is monitored in real time.
[0065] In this embodiment, before monitoring the health status of the Redis cluster associated with the target activity, the target activity can be created first, and a corresponding Redis cluster can be assigned to the target activity according to the activity level of the target activity, and the association between the activity ID of the target activity and the Redis cluster can be recorded. In this way, during the target activity held on the e-commerce platform, the Redis cluster associated with the target activity can be determined according to the association between the activity ID of the target activity and the Redis cluster, and the health status of the Redis cluster can be monitored in real time, so that data backup and snapshots can be performed in time, and data recovery can be performed when the health status is poor.
[0066] In one embodiment, allocating a corresponding Redis cluster to the target activity according to the activity level of the target activity in S111 may include:
[0067] S1111: Determine the activity level of the target activity.
[0068] S1112: Obtain an activity cluster association record table, wherein the activity cluster association record table records the association relationship between all activities in the e-commerce platform whose end time does not exceed a preset time threshold and the assigned Redis clusters.
[0069] S1113: Count the number of activities associated with each Redis cluster according to the activity cluster association record table and the activity quantity conversion relationship between different activity levels.
[0070] S1114: Allocate a corresponding Redis cluster to the target activity according to the number of activities associated with each Redis cluster and the activity level of the target activity. When the activity level of the target activity is a major promotion activity, the Redis cluster allocated to the target activity includes a primary cluster and a secondary cluster.
[0071] In this embodiment, when assigning a corresponding Redis cluster to a target activity, the activity level of the target activity can be determined first, and an activity cluster association record table can be obtained. The record table records the association relationship between all activities in the e-commerce platform whose end time does not exceed the preset time threshold and the assigned Redis cluster. In this way, the activity level corresponding to the activity associated with each Redis cluster can be queried based on the activity cluster association record table, and then the number of activities associated with each Redis cluster can be counted based on the activity number conversion relationship between different activity levels. In this way, the current activity load of each Redis cluster can be quickly evaluated based on the number of activities associated with each Redis cluster, and then the target activity can be assigned to the corresponding Redis cluster based on the activity load of each Redis cluster.
[0072] In a specific implementation method, the capacity of each Redis cluster in this application is fixed, and each cluster is currently associated with several activities, which can be queried through the activity cluster association record table. In addition, since the front-end list only displays activity information for the last three months, and the system sets the cache time of each active Redis cluster to be up to four months after the end of the activity. Therefore, this application can query all activities that have an end time of no more than four months based on the above information, and group and count the number of activities associated with each cluster, as well as the number of activities of different activity levels under each cluster.
[0073] For example, this application can divide the activity levels into S, A, B and C, and stipulate that one S-level activity is equivalent to 10 C-level activities, one A-level activity is equivalent to 5 C-level activities, and one B-level activity is equivalent to 3 C-level activities. In this way, the number of activities in each Redis cluster can be normalized to obtain the number of activities at the same activity level. Then, this application can sort the number of activities in each cluster to determine the cluster with the least number of activities, and use it as the cluster with the least load. After allocating the target activity to this cluster, system overload during the recovery process can be avoided.
[0074] In addition, the present application can allocate different numbers of Redis clusters to activities of different scales. For example, when the target activity of the present application is a big promotion activity, the present application can allocate two Redis clusters for it, one as the primary cluster and the other as the secondary cluster; and when the target activity of the present application is a non-big promotion activity, it can be allocated one Redis cluster, which can dynamically adjust resources and quickly recover data.
[0075] In one embodiment, determining the activity level of the target activity in S1111 may include:
[0076] S11111: Determine the user participation level of the target activity and the channel order type.
[0077] S11112: Determine the activity level of the target activity based on the user participation level and the channel order type.
[0078] In this embodiment, when determining the activity level of the target activity, the user participation level and the channel order type of the target activity can be determined first, so that the activity level of the target activity can be determined based on the user participation level and the channel order type.
[0079] Specifically, the degree of user participation in the target activity in this application can be determined by the user group in which the user participates. For example, the user group in which the user participates in this application includes but is not limited to all users, designated whitelist users, designated user tag users, and newly registered users; and the channel order type of the target user in this application can be determined by the statistical rules of the activity. For example, this application can divide the channel order type into all CPS channel orders, designated channel orders, designated channel category orders, designated channel brands, designated channel stores, and designated product IDs. The specific settings can be made according to actual conditions and are not restricted here.
[0080] After determining the user participation level and channel order type of the target activity, the application can preliminarily assess the user participation level and order level of the activity based on the number of users on the platform, and divide the specific activity level according to the user participation level and order level. Specifically, it can be divided into the following levels:
[0081] S level: All CPS channel order activities participated by all users
[0082] Level A: All users participate in activities with specified statistical rules
[0083] Level B: All channel order activities in which the specified user participates
[0084] Level C: Activities with specified statistical rules and participation of specified users
[0085] Of course, the present application can also divide the activity levels through other division methods, and the types of divided activity levels can also be different from the above types. The specific settings can be made according to actual conditions and are not limited here.
[0086] In one embodiment, real-time monitoring of the health status of the Redis cluster associated with the target activity in S110 may include:
[0087] S210: Using a preset cluster anomaly detection method, monitor the health status of the Redis cluster associated with the target activity in real time.
[0088] S211: Alternatively, a pre-configured operation status monitoring model is used to monitor the health status of the Redis cluster associated with the target activity in real time.
[0089] In this embodiment, when monitoring the health status of the Redis cluster associated with the target activity, it is possible to monitor it using a preset cluster anomaly detection method or to use a pre-configured health monitoring model for real-time monitoring. The specific selection can be made based on the actual situation and is not limited here.
[0090] When this application uses a preset cluster anomaly detection method to detect the health status of a Redis cluster, it can first determine the common fault types of the Redis cluster and perform fault detection based on the fault type. For example, common Redis cluster fault types may include node failure: detecting whether a single Redis node has failed; cluster failure: detecting whether the entire Redis cluster has failed; network failure: detecting whether there is a problem with the network connection; performance bottleneck: detecting whether there is a performance bottleneck in the Redis cluster, such as excessive CPU or memory usage. This application can use a variety of detection methods for the above-mentioned fault types, such as heartbeat monitoring: detecting the online status of the Redis node through heartbeat packets; command response: regularly sending simple commands (such as PING) to Redis to check the response time and command execution; performance indicators: monitoring Redis performance indicators, such as CPU usage, memory usage, etc.; log analysis: analyzing Redis log files to identify potential signs of failure. This application can select one or more detection methods for detection based on actual conditions, and there is no limitation here.
[0091] When this application uses a pre-configured health monitoring model to monitor the health status of the Redis cluster, you can configure the health monitoring model in the following ways and use the model to monitor the health status, including the following:
[0092] 1. Data Collection
[0093] First, you need to collect performance metrics about the Redis cluster. These metrics include, but are not limited to, CPU usage, memory usage, network latency, request processing time, requests per second (QPS), and error rate. This data can be collected using Redis's built-in monitoring tools or third-party monitoring systems such as Prometheus and Grafana.
[0094] 2. Feature Engineering
[0095] Extract useful features from the collected data. This may involve cleaning, transforming, and aggregating the raw data. For example, statistics such as the average, peak value, and standard deviation over a period of time can be calculated as features.
[0096] 3. Model Selection and Training
[0097] Choose an appropriate machine learning algorithm to train the model. For time series forecasting, consider using models such as ARIMA, LSTM (Long Short-Term Memory), or Prophet. For classification tasks, consider using random forests, support vector machines (SVM), or neural networks. When training the model, divide the historical data into training and test sets, and adjust the model parameters based on the test results to optimize performance.
[0098] 4. Anomaly Detection
[0099] Once the model is trained, it can be deployed in a production environment to monitor the status of the Redis cluster in real time. If the observed metrics deviate from the model's predictions, an anomaly is considered. To more accurately detect anomalies, this application can also use statistical methods (such as Z-Score) or density-based methods (such as Isolation Forest) for further confirmation.
[0100] 5. Early warning mechanism
[0101] When an abnormal pattern is detected, the system can trigger an early warning notification to the operation and maintenance personnel or developers. The early warning notification can be sent via email, SMS or messaging platform.
[0102] 6. Data Recovery Strategy
[0103] Different data recovery strategies can be used for different abnormal modes to reduce the probability of sudden failure points.
[0104] In one embodiment, determining a target data recovery strategy corresponding to the activity level of the target activity in S130 and recovering the activity data stored in the Redis cluster using the target data recovery strategy may include:
[0105] S131: When the activity level of the target activity is a big promotion activity, modify the access priority between the primary cluster and the secondary cluster associated with the target activity to switch the primary cluster and the secondary cluster.
[0106] In this embodiment, when determining the target data recovery strategy corresponding to the target activity, the activity level of the target activity can be determined first, and the target data recovery strategy can be determined based on the activity level. For example, when the activity level of the target activity of this application is a big promotion activity, since this application allocates a primary cluster and a secondary cluster to it when creating this type of activity, and performs double-write records during the activity, each cluster corresponds to a different consumer service, and registers the processing version number of each order MQ message. Therefore, when the Redis cluster service associated with this type of activity is abnormal, the access priority between the primary cluster and the secondary cluster associated with the target activity can be modified to switch the primary cluster and the secondary cluster, thereby achieving data recovery.
[0107] Schematically, as Figure 2 As shown, Figure 2 A schematic diagram of the Redis cache-A policy recovery process provided in the embodiment of this application is provided by Figure 2 It can be seen that each activity in this application will perform double record writing when monitoring the consumption order MQ. At the same time, the processing version number size of the same user activity message in the two clusters will be compared. When the system determines that the cluster needs to be switched, such as the version number of the primary cluster is smaller than the version number of the secondary cluster, or other service abnormalities occur, the access priority of the cluster record associated with the activity will be modified. The higher the priority field value, the higher the primary cluster. Therefore, as long as the priority of the secondary cluster is adjusted to be greater than the priority field value of the primary cluster, switching can be achieved in seconds.
[0108] In this application, the active Redis cluster resource configuration association table is as follows:
[0109]
[0110] Table 1 Redis cluster resource configuration association table
[0111] As can be seen from Table 1, when allocating a Redis cluster to a target activity, the present application can set a corresponding priority for the Redis cluster. In this way, when switching between the primary and secondary clusters, the secondary cluster's priority field value can be adjusted to be greater than the primary cluster's priority field value to achieve a second-level switch.
[0112] In one embodiment, determining a target data recovery strategy corresponding to the activity level of the target activity in S130 and recovering the activity data stored in the Redis cluster using the target data recovery strategy may include:
[0113] S132: When the activity level of the target activity is a non-promotional activity, a replacement activity with the same activity rules as the target activity is recreated, and the corresponding Redis cluster is reallocated for the replacement activity. Then, the activity registration record of the target activity and all order MQ messages during the activity are synchronized to the reallocated Redis cluster.
[0114] In this embodiment, when determining the target data recovery strategy corresponding to the target activity, the activity level of the target activity can be determined first, and the target data recovery strategy can be determined based on the activity level. For example, when the activity level of the target activity of this application is a non-big promotion activity, since the system only allocates one cluster when creating the activity, when a cluster service anomaly is detected, an alarm will be triggered. The activity system can copy an activity with the same rules and specify a new Redis cluster, automatically synchronize the activity registration records and resend all order MQ messages during the activity for fast consumption. Since the amount of daily activity data of this type of activity is small, the recovery speed is relatively fast, and fast recovery can be achieved within 10 minutes.
[0115] Schematically, as Figure 3 、 4 As shown, Figure 3 A schematic diagram of the Redis cache-B strategy recovery process provided in an embodiment of the present application, Figure 4 The active Redis cluster business architecture diagram provided for the embodiment of the present application; in the present application, when the system detects a cluster abnormality, the system service will automatically send a cluster service abnormality MQ message to monitor the cluster service abnormality MQ message and reconfirm whether the cluster service has an abnormality. Abnormal situations include: cluster access failure, non-existence of activity progress data, and other pre-determined abnormal judgment logic. After confirming the cluster abnormality, it is determined again whether there is a cluster record associated with the newly added activity. If there is a second unopened cluster record, it means that the activity is already being restored, but the data has not been restored, so it is not turned on. When it is confirmed that recovery is required, the configuration information and registered records associated with the activity are obtained again, and a new activity is created, and a new Redis cluster is allocated, and the registered records are re-registered under the name of the new activity.
[0116] Next, this application retrieves all original order messages within the activity start and end time period, resends the order MQ messages in batches chronologically, reconsumes the activity statistics logic, and automatically calculates the activity progress. Once all order MQ messages are resent, a new cluster record is opened and the old cluster state is closed, completing the final Redis cluster replacement and restoring the activity data.
[0117] The data backup and recovery device provided in an embodiment of the present application is described below. The data backup and recovery device described below and the data backup and recovery method described above can be referenced to each other.
[0118] In one embodiment, Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of a data backup and recovery device provided in an embodiment of the present application. The present application also provides a data backup and recovery device, which may include:
[0119] The real-time monitoring module 210 is used to monitor the health status of the Redis cluster associated with the target activity in real time during the target activity held on the e-commerce platform.
[0120] The backup and snapshot module 220 is configured to perform data backup and snapshot of the Redis cluster through a preset backup and snapshot mechanism when a service anomaly of the Redis cluster is detected.
[0121] The data recovery module 230 is configured to determine a target data recovery strategy corresponding to the activity level of the target activity, and to recover the activity data stored in the Redis cluster using the target data recovery strategy.
[0122] In the above embodiment, during the period when the e-commerce platform holds a target activity, the health status of the Redis cluster associated with the target activity can be monitored in real time; when a Redis cluster service anomaly is detected, the Redis cluster can be backed up and snapshotted through a preset backup and snapshot mechanism, which can not only effectively reduce the risk of data loss, but also improve the availability and data security of the Redis cluster; then, the present application can also determine a target data recovery strategy corresponding to the activity level of the target activity, and use the target data recovery strategy to restore the activity data stored in the Redis cluster, thereby significantly improving the reliability and stability of the Internet e-commerce activity system, reducing the business interruption time caused by Redis cluster failures, and thus improving user experience and enterprise operation efficiency.
[0123] In one embodiment, the present application also provides a computer-readable storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the data backup and recovery method described in any of the above embodiments.
[0124] In one embodiment, the present application further provides a computer device, including: one or more processors, and a memory.
[0125] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the data backup and recovery method described in any one of the above embodiments are performed.
[0126] Schematically, as Figure 6 As shown, Figure 6 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 can be provided as a server. Figure 6 Computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by memory 301 for storing instructions executable by processing component 302, such as an application. The application stored in memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, processing component 302 is configured to execute the instructions to perform the data backup and recovery method of any of the above-described embodiments.
[0127] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, or the like.
[0128] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0129] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0130] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referenced to each other.
[0131] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data backup and recovery method, characterized in that: The method comprises: During the target event held on the e-commerce platform, real-time monitoring of the health status of the Redis cluster associated with the target event; When an abnormality in the Redis cluster service is detected, data backup and snapshot of the Redis cluster are performed through a preset backup and snapshot mechanism; Determining a target data recovery strategy corresponding to the activity level of the target activity, and recovering the activity data stored in the Redis cluster using the target data recovery strategy; During the period when the target activity is held on the e-commerce platform, real-time monitoring of the health status of the Redis cluster associated with the target activity includes: When creating a target activity on an e-commerce platform, a corresponding Redis cluster is allocated to the target activity according to the activity level of the target activity, and the association between the activity ID of the target activity and the Redis cluster is recorded; During the period when the target activity is held on the e-commerce platform, determining the Redis cluster associated with the target activity based on the association relationship between the activity ID and the Redis cluster, and monitoring the health status of the Redis cluster in real time; Allocating a corresponding Redis cluster to the target activity according to the activity level of the target activity includes: determining an activity magnitude of the target activity; Obtaining an activity cluster association record table, wherein the activity cluster association record table records the association between all activities on the e-commerce platform whose end time does not exceed a preset time threshold and the assigned Redis clusters; According to the activity cluster association record table and the activity quantity conversion relationship between different activity levels, the number of activities associated with each Redis cluster is counted; Based on the number of activities associated with each Redis cluster and the activity level of the target activity, the current activity load of each Redis cluster is evaluated, and the target activity is allocated to the corresponding Redis cluster based on the activity load of each Redis cluster. When the activity level of the target activity is a major promotion activity, the Redis cluster allocated to the target activity includes a primary cluster and a secondary cluster. Determining the activity level of the target activity includes: Determine user engagement levels and channel order types for the target campaign; Determining the activity level of the target activity according to the user participation level and the channel order type; Among them, the activity levels include S, A, B and C. S is all CPS channel order activities participated by all users, A is the specified statistical rule activities participated by all users, B is all channel order activities participated by specified users, and C is the specified statistical rule activities participated by specified users.
2. The data backup and recovery method according to claim 1, wherein: The real-time monitoring of the health status of the Redis cluster associated with the target activity includes: Using a pre-defined cluster anomaly detection method, the health status of the Redis cluster associated with the target activity is monitored in real time; Alternatively, a pre-configured health monitoring model is used to monitor the health status of the Redis cluster associated with the target activity in real time.
3. The data backup and recovery method according to claim 1, wherein: Determining a target data recovery strategy corresponding to the activity level of the target activity, and using the target data recovery strategy to recover the activity data stored in the Redis cluster, includes: When the activity level of the target activity is a major promotion activity, the access priority between the primary cluster and the secondary cluster associated with the target activity is modified to switch the primary cluster and the secondary cluster.
4. The data backup and recovery method according to claim 1, wherein: Determining a target data recovery strategy corresponding to the activity level of the target activity, and using the target data recovery strategy to recover the activity data stored in the Redis cluster, includes: When the activity level of the target activity is not a big promotion activity, a replacement activity with the same activity rules as the target activity is recreated, and the corresponding Redis cluster is reallocated for the replacement activity. Then, the activity registration records of the target activity and all order MQ messages during the activity are synchronized to the reallocated Redis cluster.
5. A data backup and recovery device, characterized in that: include: A real-time monitoring module is used to monitor the health status of the Redis cluster associated with the target activity in real time during the target activity held on the e-commerce platform; A backup and snapshot module is used to perform data backup and snapshot of the Redis cluster through a preset backup and snapshot mechanism when an abnormality in the Redis cluster service is detected; a data recovery module, configured to determine a target data recovery strategy corresponding to the activity level of the target activity, and recover the activity data stored in the Redis cluster using the target data recovery strategy; The real-time monitoring module includes: When creating a target activity on an e-commerce platform, a corresponding Redis cluster is allocated to the target activity according to the activity level of the target activity, and the association between the activity ID of the target activity and the Redis cluster is recorded; During the period when the target activity is held on the e-commerce platform, determining the Redis cluster associated with the target activity based on the association relationship between the activity ID and the Redis cluster, and monitoring the health status of the Redis cluster in real time; Allocating a corresponding Redis cluster to the target activity according to the activity level of the target activity includes: determining an activity magnitude of the target activity; Obtaining an activity cluster association record table, wherein the activity cluster association record table records the association between all activities on the e-commerce platform whose end time does not exceed a preset time threshold and the assigned Redis clusters; According to the activity cluster association record table and the activity quantity conversion relationship between different activity levels, the number of activities associated with each Redis cluster is counted; Based on the number of activities associated with each Redis cluster and the activity level of the target activity, the current activity load of each Redis cluster is evaluated, and the target activity is allocated to the corresponding Redis cluster based on the activity load of each Redis cluster. When the activity level of the target activity is a major promotion activity, the Redis cluster allocated to the target activity includes a primary cluster and a secondary cluster. Determining the activity level of the target activity includes: Determine user engagement levels and channel order types for the target campaign; Determining the activity level of the target activity according to the user participation level and the channel order type; Among them, the activity levels include S, A, B and C. S is all CPS channel order activities participated by all users, A is the specified statistical rule activities participated by all users, B is all channel order activities participated by specified users, and C is the specified statistical rule activities participated by specified users.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the data backup and recovery method according to any one of claims 1 to 4.
7. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the data backup and recovery method according to any one of claims 1 to 4 are executed.
Citation Information
Patent Citations
Cluster service calling method and device, electronic equipment, storage medium and product
CN113111123A
Data processing method and device
CN114138732A
Virtual room distribution method and device and electronic equipment
CN114979164A