A data processing method, device, apparatus, and storage medium
By deploying a backup component at the front end of the time-series database, and determining the data write location based on the database status and the proportion to be written, the problem of data loss caused by time-series database failures is solved, and higher data storage reliability is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2023-03-29
- Publication Date
- 2026-07-21
AI Technical Summary
A failure in a time-series database may cause the writing of time-series data to fail, leading to data loss.
A backup component is deployed in front of the time-series database. After receiving a data write request, the database status and the proportion to be written are determined. The data write location is determined based on the status and proportion. In case of severe anomalies, the data is written to the backup component. In case of partial anomalies, the data is written to the database or the backup component based on the device information.
This reduces the probability of data write failures, ensures that relatively complete time-series data is stored in the database, and reduces the risk of data loss.
Smart Images

Figure CN116361303B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data processing method, apparatus, device and storage medium. Background Technology
[0002] Time series databases, short for time-series databases, contain timestamps for indexing, aggregation, and sampling for each time series data point. They support the collection, compression, and aggregation of massive amounts of time series data, leading to their increasing application in the Internet of Things (IoT) field.
[0003] In the prior art, the user terminal directly sends a data write request to the time series database to write the data to be written contained in the data write request into the time series database.
[0004] In the process of realizing this invention, the inventors discovered at least the following technical problems in the prior art:
[0005] Because time-series data is characterized by the continuous generation of new time-series data over time, a failure in the time-series database may lead to the failure of writing time-series data, resulting in the loss of time-series data. Summary of the Invention
[0006] This invention provides a data processing method, apparatus, device, and storage medium to reduce the probability of data write failure and the risk of data loss.
[0007] In a first aspect, embodiments of the present invention provide a data processing method, which is applied to an electronic device including a backup component, comprising:
[0008] Upon receiving a data write request, determine the database status and the proportion of data to be written;
[0009] When the database is in an abnormal state and the write-to-be-written ratio is the first ratio, the write-to-be-written data contained in the data write request is written to the backup component.
[0010] When the database is in an abnormal state and the write-to-be-written ratio is the second ratio, the write-to-be-written data contained in the write-to-be-written request is determined to be written to the database or the backup component based on the device information contained in the write-to-be-written request.
[0011] In a second aspect, embodiments of the present invention also provide a data processing apparatus, which is configured in an electronic device including a backup component, comprising:
[0012] The determination module is used to determine the database status and the proportion of data to be written after receiving a data write request;
[0013] The first direct write module is used to write the data to be written contained in the data write request to the backup component when the database is in an abnormal state and the write ratio is a first ratio.
[0014] The first selection module is used to determine, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the database or the backup component when the database is in an abnormal state and the write ratio is the second ratio.
[0015] Thirdly, embodiments of the present invention also provide an electronic device, including: one or more processors; a storage device for storing one or more programs; and a backup component for storing data to be written contained in a data write request.
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method as described in any of the first aspects.
[0017] Fourthly, embodiments of the present invention also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the data processing method as described in any of the first aspects.
[0018] The embodiments of the above invention have the following advantages or beneficial effects:
[0019] This invention provides a data processing method applied to an electronic device including a backup component, comprising: upon receiving a data write request, determining the state of the database and the write-to-be-written ratio; when the database state is abnormal and the write-to-be-written ratio is a first ratio, writing the write-to-be-written data contained in the data write request to the backup component; when the database state is abnormal and the write-to-be-written ratio is a second ratio, determining, based on the device information contained in the data write request, to write the write-to-be-written data contained in the data write request to the database or the backup component. The above technical solution uses the database status and the write-to-be-written ratio to determine the write location of the data to be written in the data write request. Therefore, upon receiving a data write request, the database status and write-to-be-written ratio can be determined first. If the database status is abnormal and the write-to-be-written ratio is the first ratio, it indicates a severe database error, and data writing cannot continue. In this case, the data to be written in the data write request can be written to the backup component. If the database status is abnormal and the write-to-be-written ratio is the second ratio, it indicates a partial database error, and some of the data to be written in the data write request can be written. At this point, the device information included in the data write request can be used to determine whether the data to be written in the data write request can be written to the database. If the device information indicates that the data to be written in the data write request can be written to the database, then the data to be written in the data write request is written to the database. If the device information indicates that the data to be written in the data write request cannot be written to the database, then the data to be written in the data write request is written to the backup component, reducing the probability of data write failure and achieving relatively complete storage of the data to be written in the database, thus reducing the risk of data loss. Attached Figure Description
[0020] Figure 1a This is a data flow diagram of the process of writing data to a database in existing technologies;
[0021] Figure 1b This is a data flow diagram of the data to be written to the database in the data processing method proposed in this application;
[0022] Figure 2 A schematic diagram of a pre-plugin provided in an embodiment of the present invention;
[0023] Figure 3 A flowchart of a data processing method provided in an embodiment of the present invention;
[0024] Figure 4 A flowchart of another data processing method provided in an embodiment of the present invention;
[0025] Figure 5 A flowchart illustrating the implementation of another data processing method provided in an embodiment of the present invention;
[0026] Figure 6 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention;
[0027] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0028] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0029] Before discussing the exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the figures. The process can correspond to a method, function, procedure, subroutine, subroutine, etc. Moreover, embodiments and features in the embodiments of the present invention can be combined with each other without conflict.
[0030] Figure 1a This is a data flow diagram in existing technologies when writing data to a database, such as... Figure 1a As shown, the user terminal sends a data write request to the time-series database to write the data to be written contained in the data write request into the time-series database. Improper operation methods of the time-series database, data volume exceeding the estimated range, or potential bugs in the time-series database itself that are triggered may cause the time-series database to malfunction. Since the data to be written is continuously generated over time, a failure in the time-series database may result in the writing of the data failing, leading to the undesirable consequence of data loss.
[0031] Figure 1b This is a data flow diagram of the data to be written to the database in the data processing method proposed in this application, such as... Figure 1bAs shown, an electronic device including a backup component is deployed at the front end of the time series database. This electronic device can be a front-end plug-in. The user terminal can first send a data write request to the front-end plug-in. The front-end plug-in writes the data to be written contained in the data write request into the database or the backup component, reducing the probability of data write failure and realizing the storage of relatively complete data to be written in the database, thereby reducing the risk of data loss.
[0032] Figure 2 A schematic diagram of the pre-plugin provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the front-end plugin may include a gateway component, a status monitoring component, a transmission component, a status control component, a degradation component, a backup component, and a loading component.
[0033] The data processing method proposed in this application will be described in detail below with reference to the illustrations and various embodiments.
[0034] Figure 3 This is a flowchart illustrating a data processing method provided by an embodiment of the present invention. This embodiment is applicable to situations requiring a reduction in the probability of data write failure and the risk of data loss. The method can be executed by a data processing device, which can be implemented in software and / or hardware, such as an electronic device including backup components. Figure 3 The method specifically includes the following steps:
[0035] Step 310: After receiving the data write request, determine the database status and the proportion to be written.
[0036] The database can be a time-series database, and its status can be normal or abnormal. When the time-series database is in a normal state, the write-pending ratio is 100%, indicating that the database can successfully write data to requests. When the time-series database is in an abnormal state, the write-pending ratio is either a first ratio or a second ratio. A write-pending ratio of the first ratio indicates that the database cannot write data normally, while a write-pending ratio of the second ratio indicates that the database can write the data to be written for the second proportion of write requests.
[0037] Specifically, upon receiving a data write request from a user terminal, the electronic device containing the backup component, i.e., the front-end module, first determines whether the time-series database is in a normal or abnormal state. When the time-series database is in a normal state, its write-to-be-completed ratio is 100%, and it can write the data to be written normally. When the time-series database is in an abnormal state, its write-to-be-completed ratio is either a first ratio or a second ratio. If the write-to-be-completed ratio is the first ratio, the time-series database cannot write the data to be written normally; if the write-to-be-completed ratio is the second ratio, the time-series database can write the data to be written included in the second ratio of the data write requests.
[0038] In this embodiment of the invention, the front-end plugin deployed at the front-end position of the time-series database can, after receiving a data write request sent by a user terminal, determine the status and write ratio of the time-series database used to determine the write position of the data to be written contained in the data write request, thus providing a data basis for determining the write position of the data to be written contained in the data write request.
[0039] Step 320: When the database is in an abnormal state and the write ratio is the first ratio, the write data contained in the data write request is written to the backup component.
[0040] Specifically, when the time series database is in an abnormal state and the write-to-be-written ratio is the first ratio, the time series database is severely abnormal and cannot write the write-to-be-written data normally. At this time, the front-end plugin can write the write-to-be-written data contained in the received data write request to the included backup component.
[0041] In this embodiment of the invention, when the time-series database is in an abnormal state and the write-to-be-written ratio is the first ratio, the front-end plugin can write the write-to-be-written data contained in the received data write request into the backup component, thereby reducing the probability of data write failure.
[0042] Step 330: When the database is in an abnormal state and the write ratio is the second ratio, determine, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the database or the backup component.
[0043] Specifically, when the time-series database is in an abnormal state and the write-to-be-written ratio is the second ratio, the time-series database can write the write-to-be-written data contained in the second ratio's data write request. In this case, the write-to-be-written data contained in the second ratio's data write request can be written to the time-series database, while the write-to-be-written data contained in other data write requests can be written to the backup component contained in the front-end plugin. Therefore, it is necessary to determine whether the write-to-be-written data contained in the data write request can be written to the time-series database. Specifically, this can be determined based on the device information contained in the data write request.
[0044] Device information can be device type or device identifier, etc. When the device information is device type, the device type of the second proportion can be determined as the device type corresponding to the time-series database. Then, it can be determined whether the device type included in the data write request is the device type corresponding to the time-series database. If the device type included in the data write request is the device type corresponding to the time-series database, the data to be written included in the data write request can be written to the time-series database. If the device type included in the data write request is another device type, the data to be written included in the data write request can be written to the backup component. When the device information is device identifier, the modulo remainder of the device identifier of the second proportion can be determined as the modulo remainder corresponding to the time-series database. Then, it can be determined whether the modulo remainder of the device identifier included in the data write request is the modulo remainder corresponding to the time-series database. If the modulo remainder of the device identifier included in the data write request is the modulo remainder corresponding to the time-series database, the data to be written included in the data write request can be written to the time-series database. If the modulo remainder of the device identifier included in the data write request is another modulo remainder, the data to be written included in the data write request can be written to the backup component.
[0045] In this embodiment of the invention, when the time-series database is in an abnormal state and the write-to-be-written ratio is the second ratio, the front-end plugin can determine whether the write-to-be-written data contained in the data write request can be written to the time-series database based on the device information contained in the data write request. After determining that the write-to-be-written data contained in the data write request cannot be written to the time-series database, the plugin further writes the write-to-be-written data contained in the data write request to the backup component, thereby further reducing the probability of data write failure and realizing the storage of relatively complete write-to-be-written data in the database, thus reducing the risk of data loss.
[0046] The data processing method provided in this embodiment of the invention is applied to an electronic device including a backup component, and includes: after receiving a data write request, determining the status of the database and the write ratio; when the database status is abnormal and the write ratio is a first ratio, writing the write data contained in the data write request to the backup component; when the database status is abnormal and the write ratio is a second ratio, determining, based on the device information contained in the data write request, to write the write data contained in the data write request to the database or the backup component. The above technical solution uses the database status and the write-to-be-written ratio to determine the write location of the data to be written in the data write request. Therefore, upon receiving a data write request, the database status and write-to-be-written ratio can be determined first. If the database status is abnormal and the write-to-be-written ratio is the first ratio, it indicates a severe database error, and data writing cannot continue. In this case, the data to be written in the data write request can be written to the backup component. If the database status is abnormal and the write-to-be-written ratio is the second ratio, it indicates a partial database error, and some of the data to be written in the data write request can be written. At this point, the device information included in the data write request can be used to determine whether the data to be written in the data write request can be written to the database. If the device information indicates that the data to be written in the data write request can be written to the database, then the data to be written in the data write request is written to the database. If the device information indicates that the data to be written in the data write request cannot be written to the database, then the data to be written in the data write request is written to the backup component, reducing the probability of data write failure and achieving relatively complete storage of the data to be written in the database, thus reducing the risk of data loss.
[0047] Figure 4This is a flowchart of another data processing method provided by an embodiment of the present invention. This embodiment is applicable to situations where it is necessary to reduce the probability of data write failure and the risk of data loss. Based on the above embodiments, after determining the database status and the write ratio, this embodiment adds: "When the database status is normal, write the data to be written contained in the data write request into the database." After writing the data to be written contained in the data write request into the database, it adds: "Receive the write response from the database; after determining that the write response is a write failure, write the data to be written contained in the data write request into the backup component." Before determining whether to write the data to be written contained in the data write request into the database or the backup component based on the device information contained in the data write request, it adds: "Determine the standard modulo remainder of the second ratio as..." The modulo remainder corresponding to the database. After the database status is abnormal and the write-to-be-written ratio is the first ratio, and the data to be written contained in the data write request is written to the backup component, the following is added: "Store the data to be written contained in the data write request based on the first file in the backup component;" After determining that the write response is a write failure, and the data to be written contained in the data write request is written to the backup component, the following is added: "Store the data to be written contained in the data write request based on the second file in the backup component." The following is also added: "Write the data to be written written in the backup component to the database." Explanations of terms that are the same as or corresponding to those in the above embodiments are not repeated here. See [link to documentation]. Figure 4 The data processing method provided in this embodiment of the invention includes:
[0048] Step 410: After receiving the data write request, determine the database status and the proportion to be written.
[0049] The time series database is in a normal state by default, and the write-to-write ratio is 100% by default.
[0050] Upon receiving a data write request, the front-end plugin can determine whether the database status is normal or abnormal. If the time-series database is normal, the write-to-be-completed ratio is 100%. If the time-series database is abnormal, the write-to-be-completed ratio is either the first ratio or the second ratio. When the write-to-be-completed ratio is the first ratio, the time-series database cannot write data normally. When the write-to-be-completed ratio is the second ratio, the time-series database can write the data included in the second ratio of the data write requests. The first ratio can be 0, and the second ratio can be N%. N can be set according to actual needs; for example, N can be 50 or 20.
[0051] After the front-end plugin writes the data to be written contained in the data write request to the database, it can receive a write response from the database, which can be either a write success response or a write failure response. The front-end plugin can determine the status of the database and the proportion of data to be written based on the write responses from the database within a preset time period.
[0052] In one implementation, determining the state and write-to-be-written ratio of the database based on write responses received from the database within a preset time period includes:
[0053] The write success rate of the database within the current preset time period is determined by the ratio of the number of successful write responses to the total number of write responses. When the write success rate of the database within the current preset time period is greater than or equal to a preset threshold, the database is determined to be in a normal state. When the write success rate of the database within the current preset time period is less than the preset threshold, the database is determined to be in an abnormal state. Based on the write success rate of the database within the previous preset time period, the proportion of the database to be written within the current preset time period is determined to be either a first proportion or a second proportion.
[0054] The current preset time period is the preset time period before the current moment, and the previous preset time period is the preset time period before the current preset time period. The preset time period, preset threshold, first ratio and second ratio can all be configured according to the actual situation. For example, the preset time period can be five minutes, that is, the current preset time period can be five minutes before the current moment, the previous preset time period can be five minutes before the current moment, the preset threshold can be 98%, the first ratio can be 0, and the second ratio can be 50%.
[0055] Specifically, the total number of write responses from the time-series database within the five minutes preceding the current moment, along with the number of successful write responses, can be determined. The write success rate of the time-series database within the five minutes preceding the current moment is then determined based on the ratio of successful write responses to the total number of write responses. If the write success rate is greater than or equal to a preset threshold, the time-series database is considered to be in a normal state; if the write success rate is less than the preset threshold, the time-series database is considered to be in an abnormal state. Based on the write success rate of the time-series database in the previous preset time period, the proportion of data to be written to the time-series database in the current preset time period is determined to be either a first proportion or a second proportion.
[0056] Furthermore, based on the write success rate of the database in the previous preset time period, the proportion of the database to be written in the current preset time period is determined as a first proportion or a second proportion, including:
[0057] If the write success rate of the database in the previous preset time period is less than a preset threshold, the write ratio of the database in the current preset time period is determined as the first ratio; if the write success rate of the database in the previous preset time period is greater than or equal to the preset threshold, the write ratio of the database in the current preset time period is determined as the second ratio.
[0058] Specifically, if the write success rate of the time-series database is less than a preset threshold within a preset time period, the time-series database is determined to be abnormal, and the write-to-be-written ratio is set to the second ratio. If the write success rate of the time-series database is less than the preset threshold for two consecutive preset time periods, the time-series database is determined to be severely abnormal, and the write-to-be-written ratio is set to the first ratio. After determining the write-to-be-written ratio to the second ratio, if the write success rate is less than the preset threshold in the next preset time period, the write-to-be-written ratio is set to 0. If, after determining the write-to-be-written ratio to the second ratio, the write success rate is greater than the preset threshold in the next preset time period, the state of the time-series database cannot be restored to normal, and the write-to-be-written ratio cannot be restored to 100%, remaining at the second ratio until the time-series database is repaired or the write-to-be-written ratio reaches 0. After determining the write-to-be-written ratio to be 0, the time-series database is severely abnormal, and the write-to-be-written ratio remains 0 during subsequent operation.
[0059] In this embodiment of the invention, during the process of writing data to a time-series database, write responses from the database can be received. The write success rate is determined based on the ratio of the number of successful write responses to the total number of write responses. Then, the state of the time-series database is determined to be normal or abnormal based on the write success rate of the time-series database within the current preset time period. If the state of the time-series database is determined to be abnormal, the write success rate of the database within the current preset time period and the previous preset time period is used to determine the proportion of data to be written in the time-series database. This enables the determination of the state of the time-series database and the proportion of data to be written, providing a data basis for determining whether the front-end plugin will write the data to be written contained in the received data write request to the time-series database or backup component.
[0060] Step 420: When the database is in a normal state, write the data to be written contained in the data write request into the database.
[0061] In this embodiment of the invention, when the time series database is in a normal state, the time series database can write data normally. At this time, the data to be written contained in the data write request can be directly written to the time series database.
[0062] Step 430: When the database is in an abnormal state and the write-to-be-written ratio is the first ratio, write the write-to-be-written data contained in the data write request to the backup component.
[0063] When the database status is abnormal and the write-to-be-written ratio is the highest, the time-series database is severely abnormal. At this time, the time-series database cannot write the data to be written normally.
[0064] After the database is in an abnormal state and the write-to-be-written ratio is the first ratio, and the data to be written contained in the data write request is written to the backup component, the process further includes:
[0065] The data to be written is contained in the data write request based on the first file in the backup component.
[0066] Specifically, when an anomaly is detected in the time-series database and the write-to-be-written ratio is the first ratio, the data to be written included in the data write request can be written to the backup component, and the data to be written included in the data write request can be stored in the first file in the backup component. The first file can be Bfile.date.sequence number, for example, Bfile.20220901.1. When the data file volume reaches the storage threshold on the same day, a new file is written, and the file sequence number is incremented by 1, for example, Bfile.20220901.2.
[0067] In this embodiment of the invention, when the time-series database is in an abnormal state and the write-to-be-written ratio is the first ratio, the front-end plugin can write the write-to-be-written data contained in the received data write request into the backup component, thereby reducing the probability of data write failure.
[0068] Step 440: When the database is in an abnormal state and the write ratio is the second ratio, determine, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the database or the backup component.
[0069] In one embodiment, the device information includes a device identifier. Accordingly, determining whether to write the data to be written contained in the data write request to the database or the backup component based on the device information contained in the data write request includes:
[0070] Perform a modulo operation on the device identifier included in the data write request to obtain the modulo remainder corresponding to the device identifier; if the modulo remainder is the modulo remainder corresponding to the database, then write the data to be written in the data write request containing the device identifier corresponding to the modulo remainder into the database; if the modulo remainder is another modulo remainder, then write the data to be written in the data write request containing the device identifier corresponding to the modulo remainder into the backup component.
[0071] When the write ratio is the second ratio, the data to be written in the data write request containing the second ratio can be written to the time-series database based on preset write rules, while the data to be written in other data write requests can be written to the backup component. The preset write rules are as follows: determine the device identifier contained in the data write request, and perform a modulo operation on the device identifier to determine the modulo remainder. If the modulo remainder is the same as the modulo remainder corresponding to the time-series database, then the data to be written in the data write request containing the device identifier corresponding to the modulo remainder is written to the time-series database; if the modulo remainder is any other modulo remainder, then the data to be written in the data write request containing the device identifier corresponding to the modulo remainder is written to the backup component.
[0072] In practical applications, the standard modulo remainder of the second ratio can be determined as the modulo remainder corresponding to the time-series database. Specifically, the device identifier is moduloed by 10 to determine the modulo remainder as 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. The modulo remainder of the second ratio is the modulo remainder corresponding to the time-series database. When the second ratio is 50%, any five remainders can be determined as the modulo remainder corresponding to the time-series database; for example, 0, 2, 6, 7, and 8 can be determined as the modulo remainder corresponding to the time-series database.
[0073] Furthermore, after determining, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the backup component when the database status is abnormal and the write-to-be-written ratio is the second ratio, the method further includes:
[0074] The data to be written contained in the data write request is stored in the first file of the backup component;
[0075] Specifically, if it is determined that the time-series database is abnormal and the write ratio is the second ratio, the write data to be written contained in the write requests of the second ratio can be written to the time-series database, and the write data to be written contained in other write requests can be written to the backup component. After determining to write the write data contained in the write requests to the backup component, the write data contained in the write requests can also be stored based on the first file in the backup component. As mentioned above, the first file can also be Bfile.date.serial number, for example, Bfile.20220901.1. Moreover, when the data file volume reaches the storage threshold on the same day, a new file is written, and the file serial number is incremented by 1, for example, Bfile.20220901.2.
[0076] In this embodiment of the invention, when the time-series database is in an abnormal state and the write-to-be-written ratio is the second ratio, the front-end plugin can write the write-to-be-written data contained in the data write request to the database or backup component according to the device information contained in the data write request, thereby reducing the probability of data write failure.
[0077] Step 450: Receive the write response from the database; after determining that the write response is a write failure, write the data to be written contained in the data write request to the backup component.
[0078] After the front-end plugin writes the data to be written contained in the data write request to the time series database, the time series database can send a write response back to the front-end plugin, indicating whether the write was successful or failed.
[0079] Even when the time-series database appears to be in a normal state, issues such as the database service process crashing, the database service failing to connect, and the database service refusing to connect may still occur. In these cases, although the time-series database appears to be in a normal state, it is still unable to write data, and the write response sent back to the front-end plugin by the time-series database will be "write failed".
[0080] When the time series database is in an abnormal state and the write ratio is the second ratio, writing the write data to be written included in the write request of the second ratio to the time series database may still fail. In this case, the write response sent back by the time series database to the front-end plugin will also be a write failure.
[0081] Specifically, after writing the data to be written contained in the data write request to the time series database, the front-end plugin can receive a write response from the time series database. If the write response indicates a successful write, it means that the data to be written contained in the data write request has been successfully stored in the time series database; if the write response indicates a write failure, it means that the data to be written contained in the data write request has not been successfully stored in the time series database. Therefore, when the front-end plugin determines that the write response received from the time series database indicates a write failure, it can write the data to be written contained in the data write request to the backup component, and store the data to be written contained in the data write request based on the backup component.
[0082] Furthermore, after determining that the write response is a write failure and writing the data to be written contained in the data write request to the backup component, the method further includes:
[0083] The data to be written, contained in the data write request, is stored in the second file of the backup component.
[0084] After a failure to write the data to the time-series database as determined by the write request, the data to be written is rewritten to the backup component. This data is then stored in a second file within the backup component. The second file can be named Tfile.date.sequence number, for example, Tfile.20220901.1. If the data file size reaches the storage threshold within the same day, a new file is written, and the file sequence number is incremented by 1, for example, Tfile.20220901.2.
[0085] In this embodiment of the invention, after the front-end plugin writes the data to be written contained in the data write request to the time-series database, it can receive a write response from the time-series database. When the write response is successful, it indicates that the data to be written contained in the data write request has been successfully stored in the time-series database. When the write response is unsuccessful, it indicates that the data to be written contained in the data write request has not been successfully stored in the time-series database. At this time, the front-end plugin can continue to write the data to be written contained in the data write request to the backup component contained in the front-end plugin. The backup component stores the data to be written contained in the data write request. When the data to be written contained in the data write request cannot be successfully written to the time-series database, the data to be written contained in the data write request can be written to the backup component, thereby reducing the risk of data loss and improving the stability and reliability of the time-series database.
[0086] Step 460: After determining that the database status has returned to normal or after a preset time, write the data to be written from the backup component into the database.
[0087] Specifically, after determining that the time-series database has recovered to normal or that the pre-processor components have run for the preset time, the data to be written in the first and second files of the backup components can be loaded into memory. The data to be written in the first and second files of the backup components is then merged according to the device identifier. Because time-series data has idempotency, the merged data belonging to the same device can be written to the time-series database in batches. For example, 1000 data entries belonging to the same device can be written to the time-series database in batches, reducing the number of requests to the time-series database and achieving rapid data recovery.
[0088] In addition, after loading the data to be written from the first and second files into memory, add the "done" suffix to the filenames of the first and second files, for example, Bfile.20220901.1.done, to indicate that the data to be written from the first and second files has been processed.
[0089] It should be noted that after receiving a data query request, the front-end plugin can directly send the data query request to the time series database for data querying.
[0090] When the front-end plugin is running, it is usually used in conjunction with disk file monitoring technology commonly used in operations and maintenance. When a Tfile or Bfile file is detected, it can send an alarm message to the operations and maintenance terminal to remind the operations and maintenance personnel to check whether the time-series database is normal.
[0091] In this embodiment of the invention, the data to be written in the backup component is further written into the time series database, thereby storing complete time series data in the time series database and further reducing the risk of data loss.
[0092] The data processing method provided in this embodiment of the invention includes: upon receiving a data write request, determining the state of the database and the write-to-be-written ratio; when the database state is normal, writing the write-to-be-written data contained in the data write request into the database; when the database state is abnormal and the write-to-be-written ratio is a first ratio, writing the write-to-be-written data contained in the data write request into the backup component; when the database state is abnormal and the write-to-be-written ratio is a second ratio, determining, based on the device information contained in the data write request, to write the write-to-be-written data contained in the data write request into the database or the backup component; receiving a write response from the database; after determining that the write response is a write failure, writing the write-to-be-written data contained in the data write request into the backup component; and after determining that the database state has returned to normal or after a preset time, writing the write-to-be-written data written in the backup component into the database. In the above technical solution, after the front-end plugin of the time-series database receives a data write request from the user terminal, it can determine whether to write the data to be written contained in the data write request to the time-series database or the backup component contained in the front-end plugin, based on the status of the time-series database and the proportion of data to be written. Therefore, it can first determine the write success rate of the database within the current preset time period based on the ratio of the number of successful write responses to the total number of write responses fed back by the time-series database within the current preset time period. Then, it can determine whether the status of the time-series database is normal or abnormal based on the write success rate of the time-series database within the current preset time period. When it is determined that the status of the time-series database is normal, the data to be written contained in the data write request is written. When entering a time-series database, if the database is determined to be in an abnormal state, the write success rate within the current and previous preset time periods is used to determine the write-to-write ratio of the time-series database. A first write-to-write ratio indicates a severe database anomaly, making further data writing impossible. In this case, the data to be written included in the write request can be written to the backup component. A second write-to-write ratio indicates a partial database anomaly, and the second proportion of data to be written included in the write request can be written. Based on the device information included in the write request, the system can determine whether to write the data to be written to the time-series database or the backup component, reducing the probability of write failure. However, even when writing the data to be written to the time-series database, there is still a possibility of write failure. Therefore, if a write failure is confirmed based on the write response from the time-series database to the front-end plugin, the system continues to write the data to be written to the backup component, reducing the risk of data loss. Once the time-series database has returned to normal or the preceding components have run for the preset time, the data to be written in the backup components can be written to the time-series database, thus storing complete time-series data in the time-series database and further reducing the risk of data loss.
[0093] Figure 5 The flowchart illustrates another data processing method provided in this embodiment of the invention, exemplarily showing one implementation method that can be applied to, for example, Figure 2 The pre-installation plugin is shown. For example... Figure 5 As shown, this implementation method includes:
[0094] Step 510: The gateway component receives the data request sent by the user terminal.
[0095] Step 511: The gateway component determines whether the data request type is a data write request.
[0096] Specifically, the gateway component can determine whether a data request is a data query request or a data write request.
[0097] If the data request type is determined to be a data write request, proceed to step 513; otherwise, proceed to step 512.
[0098] Step 512: The gateway component sends the data query request to the time series database through the transport component to perform data query in the time series database.
[0099] Specifically, because time-series databases are write-heavy and read-light, data query requests are usually not the key factor causing database performance issues. Therefore, when a data request is a query request, it can be directly sent to the time-series database via the transport component for data retrieval. After the time-series database performs the query and obtains the results, it can then send the results to the user terminal via the transport and gateway components.
[0100] Step 513: The gateway requests to forward the data write request to the status monitoring component.
[0101] Step 514: The status monitoring component obtains the status of the time series database from the status control component and determines whether the status of the time series database is normal.
[0102] If the time series database is determined to be in a normal state, proceed to step 515; otherwise, proceed to step 516.
[0103] Step 515: The status monitoring component writes the data to be written contained in the data write request into the time series database through the transmission component.
[0104] Step 515 is followed by step 522.
[0105] Step 516: The status monitoring component forwards the data write request to the degradation component.
[0106] Step 517: The degradation component obtains the write ratio of the time series database from the state control component and determines whether the write ratio is the first ratio.
[0107] If the writing ratio is determined to be the first ratio, proceed to step 518; otherwise, proceed to step 519.
[0108] Step 518: The degradation component writes the data to be written contained in the data write request to the first file of the backup component.
[0109] Step 518 is followed by step 523.
[0110] Step 519: The degradation component performs a modulo operation on the device identifier contained in the data write request to obtain the modulo remainder corresponding to the device identifier, and determines whether the modulo remainder is the same as the modulo remainder corresponding to the time series database.
[0111] If the modulo remainder is determined to be the same as the modulo remainder corresponding to the time series database, proceed to step 520; otherwise, proceed to step 521.
[0112] Step 520: The degradation component writes the data to be written contained in the data write request that includes the device identifier corresponding to the modulo remainder into the time series database.
[0113] Step 522 is executed after step 520.
[0114] Step 521: The downgrade component writes the data to be written contained in the data write request that includes the device identifier corresponding to the modulo remainder to the first file of the backup component.
[0115] Step 523 is executed after step 521.
[0116] Step 522: The transmission component receives the write response from the time-series database. After determining that the write response is a write failure, it writes the data to be written contained in the data write request into the second file of the backup component.
[0117] Step 523: The backup component loads the data to be written into the loading component, and then writes the data to be written into the time series database through the loading component.
[0118] Specifically, after confirming that the time-series database has returned to normal or that the preceding components have run for the preset time, the data to be written to the backup components can be loaded into the loading components. The loading components then call their exposed loading interfaces (APIs or the `load` function) to load the data to be written from the first and second files into memory and merge them according to device identifiers. Finally, the merged data belonging to the same device is written in batches to the time-series database.
[0119] In addition, the reset interface, API, or reset function exposed by the control component can be called to restore the time series database to normal, restore the write ratio to 100%, and restore the time series database to its initial state.
[0120] In practical applications, the transmission component can send the write responses fed into the time series database to the status control component. The status control component can update the status of the time series database and the proportion of responses to be written based on the ratio of the number of successful write responses to the total number of write responses within a preset time period.
[0121] The alternative data processing method provided in this embodiment of the invention has the same beneficial effects as any of the aforementioned data processing methods.
[0122] Figure 6 This is a schematic diagram of a data processing device provided in an embodiment of the present invention. The device is configured in an electronic device including a front-end module. This device belongs to the same inventive concept as the data processing methods in the above embodiments. Details not described in detail in the embodiments of the data processing device can be found in the embodiments of the above data processing methods.
[0123] The specific structure of the data processing device is as follows: Figure 6 As shown, it includes:
[0124] The determination module 610 is used to determine the status of the database and the proportion to be written after receiving a data write request;
[0125] The first direct write module 620 is used to write the data to be written contained in the data write request to the backup component when the database is in an abnormal state and the write ratio is a first ratio.
[0126] The first selection write module 630 is used to determine, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the database or the backup component when the database is in an abnormal state and the write ratio is a second ratio.
[0127] Based on the above embodiments, the device further includes:
[0128] The second direct write module is used to write the data to be written contained in the data write request into the database when the database is in a normal state.
[0129] Based on the above embodiments, the device further includes:
[0130] The second selective write module is used to receive the write response from the database; after determining that the write response is a write failure, it writes the data to be written contained in the data write request to the backup component.
[0131] Based on the above embodiments, module 610 is specifically used for:
[0132] The status and write-to-be-written ratio of the database are determined based on the write responses received from the database within a preset time period.
[0133] In one implementation, determining the state and write-to-be-written ratio of the database based on write responses received from the database within a preset time period includes:
[0134] The write success rate of the database within the current preset time period is determined by the ratio of the number of successful write responses to the total number of write responses. When the write success rate of the database within the current preset time period is greater than or equal to a preset threshold, the database is determined to be in a normal state. When the write success rate of the database within the current preset time period is less than the preset threshold, the database is determined to be in an abnormal state. Based on the write success rate of the database within the previous preset time period, the proportion of the database to be written within the current preset time period is determined to be either a first proportion or a second proportion.
[0135] In one implementation, determining the proportion of the database to be written in the current preset time period as a first proportion or a second proportion based on the write success rate of the database in the previous preset time period includes:
[0136] If the write success rate of the database in the previous preset time period is less than a preset threshold, the write ratio of the database in the current preset time period is determined as the first ratio; if the write success rate of the database in the previous preset time period is greater than or equal to the preset threshold, the write ratio of the database in the current preset time period is determined as the second ratio.
[0137] Based on the above embodiments, the device information includes a device identifier. Accordingly, the first selection writing module 630 is specifically used for:
[0138] When the database is in an abnormal state and the write ratio is the second ratio, a modulo operation is performed on the device identifier contained in the data write request to obtain the modulo remainder corresponding to the device identifier; if the modulo remainder is the modulo remainder corresponding to the database, then the data to be written contained in the data write request containing the device identifier corresponding to the modulo remainder is written to the database; if the modulo remainder is another modulo remainder, then the data to be written contained in the data write request containing the device identifier corresponding to the modulo remainder is written to the backup component.
[0139] Based on the above embodiments, the device further includes:
[0140] The execution module is configured to, before determining, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the database or the backup component, further include: determining the standard modulo remainder of the second ratio as the modulo remainder corresponding to the database.
[0141] Based on the above embodiments, the device further includes:
[0142] A storage module is configured to: after writing the data to be written contained in the data write request to the backup component when the database status is abnormal and the write-to-be-written ratio is a first ratio; and after determining, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the backup component when the database status is abnormal and the write-to-be-written ratio is a second ratio, store the data to be written contained in the data write request in a first file in the backup component; and after determining that the write response is a write failure, writing the data to be written contained in the data write request to the backup component, store the data to be written contained in the data write request in a second file in the backup component.
[0143] The data processing apparatus provided in the embodiments of the present invention can execute the data processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the data processing method.
[0144] It is worth noting that in the embodiments of the above data processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy distinction between each other and are not used to limit the scope of protection of the present invention.
[0145] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Figure 7A block diagram of an exemplary electronic device 7 suitable for implementing embodiments of the present invention is shown. Figure 7 The electronic device 7 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0146] like Figure 7 As shown, the electronic device 7 is represented in the form of a general-purpose computing electronic device. The components of the electronic device 7 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0147] Electronic device 7 also includes a backup component for storing the data to be written contained in the data write request.
[0148] Bus 18 represents one or more of several bus architectures, 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 architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0149] Electronic device 7 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 7, including volatile and non-volatile media, removable and non-removable media.
[0150] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 7 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 7 Not shown; usually referred to as a "hard drive"). Although Figure 7 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0151] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.
[0152] Electronic device 7 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with electronic device 7, and / or with any device that enables electronic device 7 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed through input / output (I / O) interface 22. Furthermore, electronic device 7 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) through network adapter 20. Figure 7 As shown, network adapter 20 communicates with other modules of electronic device 7 via bus 18. It should be understood that, although... Figure 7 Not shown, it can be combined with electronic device 7 to use other hardware and / or software modules, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0153] Processing unit 16 executes various functional applications and page displays by running programs stored in system memory 28, such as implementing the data processing method provided in this embodiment, which includes:
[0154] Upon receiving a data write request, determine the database status and the proportion of data to be written;
[0155] When the database is in an abnormal state and the write-to-be-written ratio is the first ratio, the write-to-be-written data contained in the data write request is written to the backup component.
[0156] When the database is in an abnormal state and the write-to-be-written ratio is the second ratio, the write-to-be-written data contained in the write-to-be-written request is determined to be written to the database or the backup component based on the device information contained in the write-to-be-written request.
[0157] Of course, those skilled in the art will understand that the processor can also implement the technical solutions of the data processing methods provided in any embodiment of the present invention.
[0158] This invention provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the program implements, for example, the data processing method provided in this invention, which includes:
[0159] Upon receiving a data write request, determine the database status and the proportion of data to be written;
[0160] When the database is in an abnormal state and the write-to-be-written ratio is the first ratio, the write-to-be-written data contained in the data write request is written to the backup component.
[0161] When the database is in an abnormal state and the write-to-be-written ratio is the second ratio, the write-to-be-written data contained in the write-to-be-written request is determined to be written to the database or the backup component based on the device information contained in the write-to-be-written request.
[0162] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0163] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0164] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0165] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0166] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computing device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0167] Furthermore, the acquisition, storage, use, and processing of data in the technical solution of this invention all comply with the relevant provisions of national laws and regulations.
[0168] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A data processing method, characterized in that, Applied to an electronic device including a backup component, the method includes: Upon receiving a data write request, the write success rate of the database within the current preset time period is determined based on the ratio of the number of successful write responses to the total number of write responses within the current preset time period. If the write success rate of the database within the current preset time period is less than a preset threshold, the database is determined to be in an abnormal state. If the write success rate of the database within the previous preset time period is less than the preset threshold, the write-to-be-written ratio is determined to be a first ratio. If the write success rate of the database within the previous preset time period is greater than or equal to the preset threshold, the write-to-be-written ratio is determined to be a second ratio. When the write-to-be-written ratio is the first ratio, the database cannot write the data to be written normally. When the write-to-be-written ratio is the second ratio, the database writes the data to be written included in the write-to-be-written request for the second ratio. The first ratio is 0, and the second ratio is N%, where N is a positive integer. When the database is in an abnormal state and the write-to-be-written ratio is the first ratio, the write-to-be-written data contained in the data write request is written to the backup component. When the database is in an abnormal state and the write-to-be-written ratio is the second ratio, the write-to-be-written data contained in the data write request is written to the database or the backup component based on the device information contained in the data write request. The device information includes a device identifier. Accordingly, determining whether to write the data to be written in the data write request to the database or the backup component based on the device information included in the data write request includes: Perform a modulo operation on the device identifier included in the data write request to obtain the modulo remainder corresponding to the device identifier; if the modulo remainder is the modulo remainder corresponding to the database, then write the data to be written in the data write request containing the device identifier corresponding to the modulo remainder into the database; if the modulo remainder is another modulo remainder, then write the data to be written in the data write request containing the device identifier corresponding to the modulo remainder into the backup component.
2. The data processing method according to claim 1, characterized in that, After determining the database status and the proportion of data to be written, the following steps are also included: When the database is in a normal state, the data to be written contained in the data write request is written to the database.
3. The data processing method according to claim 2, characterized in that, After writing the data to be written contained in the data write request into the database, the process further includes: Receive the write response from the database; After determining that the write response is a write failure, the data to be written contained in the data write request is written to the backup component.
4. The data processing method according to claim 1, characterized in that, Also includes: Once the database status is determined to have returned to normal or after a preset time, the data to be written from the backup component is written into the database.
5. The data processing method according to claim 3, characterized in that, After determining the write success rate of the database within the current preset time period based on the ratio of the number of successful write responses to the total number of write responses received from the database within the current preset time period, the method further includes: When the write success rate of the database within the current preset time period is greater than or equal to a preset threshold, the database is determined to be in a normal state.
6. The data processing method according to claim 5, characterized in that, Before determining, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the database or the backup component, the method further includes: The standard modulo remainder of the second ratio is determined as the modulo remainder corresponding to the database.
7. The data processing method according to claim 3, characterized in that, After the database is in an abnormal state and the write-to-be-written ratio is a first ratio, and after writing the data to be written contained in the data write request to the backup component, and after determining, based on the device information contained in the data write request, to write the data to be written contained in the data write request to the backup component when the database is in an abnormal state and the write-to-be-written ratio is a second ratio, the method further includes: The data to be written contained in the data write request is stored in the first file of the backup component; After determining that the write response is a write failure and writing the data to be written contained in the data write request to the backup component, the method further includes: The data to be written, contained in the data write request, is stored in the second file of the backup component.
8. A data processing apparatus, characterized in that, Configured in an electronic device including a backup component, the device includes: The determination module is used to, upon receiving a data write request, determine the write success rate of the database within the current preset time period based on the ratio of the number of successful write responses to the total number of write responses within the current preset time period; when the write success rate of the database within the current preset time period is determined to be less than a preset threshold, the database status is determined to be abnormal; when the write success rate of the database within the previous preset time period is determined to be less than the preset threshold, the write-to-be-written ratio is determined to be a first ratio; when the write success rate of the database within the previous preset time period is determined to be greater than or equal to the preset threshold, the write-to-be-written ratio is determined to be a second ratio. Where the write-to-be-written ratio is the first ratio, the database cannot write the data to be written normally; when the write-to-be-written ratio is the second ratio, the database writes the data to be written included in the write-to-be-written request for the second ratio. The first ratio is 0, and the second ratio is N%, where N is a positive integer. The first direct write module is used to write the data to be written contained in the data write request to the backup component when the database is in an abnormal state and the write ratio is a first ratio. The first write selection module is configured to, when the database is in an abnormal state and the write ratio is a second ratio, determine, based on the device information contained in the data write request, to write the data to be written in the database or the backup component; wherein, the device information includes a device identifier, and correspondingly, determining to write the data to be written in the database or the backup component based on the device information contained in the data write request includes: performing a modulo operation on the device identifier contained in the data write request to obtain a modulo remainder corresponding to the device identifier; if the modulo remainder is the modulo remainder corresponding to the database, then writing the data to be written in the data write request containing the device identifier corresponding to the modulo remainder into the database; if the modulo remainder is another modulo remainder, then writing the data to be written in the data write request containing the device identifier corresponding to the modulo remainder into the backup component.
9. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs; Backup component, used to store the data to be written contained in the data write request; When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method as described in any one of claims 1-7.
10. A storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to perform the data processing method as described in any one of claims 1-7.