Data disaster recovery method and device
By receiving user access requests and judging the diversion conditions of the target recommended bit, if they are satisfied, they will obtain data from the preset storage unit. If they are not satisfied, they will call data services, which solves the pressure problem of data services in burst traffic torrents and improves the system Stability and security reduce data service load.
Patent Information
- Application Number
- CN202011166146.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-27
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2040-10-27
AI Technical Summary
In the prior art, the pressure of data services increases dramatically when the traffic torrent occurs, which may lead to system instability and the recommended data window, causing huge losses.
By receiving user access requests, determine whether the target recommended bit meets the diversion condition, and if it is satisfied, data will be obtained from the preset storage unit; if it is not satisfied, data service will be called to obtain data, and data will be written in the local cache and database system to reduce the Data service pressure.
It improves the stability and security of the system, buys time for data service repair, reduces the pressure on data service, and flexibly adjusts the data service load through disaster recovery recommendation bits and write conditions optimization.
Smart Images

Figure CN113760978B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data disaster recovery method and device. Background Art
[0002] The recommendation position is an important and conspicuous position on the web page, which is easy to attract attention and can be used to push important information. The recommendation position can be divided into different placement positions, and then different content is recommended to different positions for display. In the prior art, the data related to the recommendation position mainly comes from the data service. The availability and performance of the data service are normal in daily life. If there is a sudden traffic torrent, the pressure on the data service will increase dramatically, which is not conducive to the stability of the system. It may cause the data service to be unavailable, and it will also cause the recommendation position data window to be empty, resulting in huge losses. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a data disaster recovery method and device, which can reduce the pressure of data services, improve the stability and security of the system, and buy time for data service repair. Even if the data service is unavailable, there is data to be displayed in the recommended position.
[0004] To achieve the above object, according to one aspect of an embodiment of the present invention, a data disaster recovery method is provided, comprising:
[0005] receiving an access request from a user, wherein the access request is used to access a target recommended location;
[0006] Determine whether the target recommendation position meets the diversion condition;
[0007] When the target recommendation position meets the diversion condition, determining that target data related to the target recommendation position exists in a preset storage unit, and acquiring the target data from the preset storage unit;
[0008] When the target recommendation position does not meet the diversion condition, a data service is called to obtain target data related to the target recommendation position.
[0009] Optionally, determining whether the target recommendation position satisfies a diversion condition includes:
[0010] Determine whether the target recommended position is a disaster recovery recommended position, and determine whether the target recommended position has a disaster recovery function enabled;
[0011] If the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is enabled for the target recommendation position, it is determined that the target recommendation position meets the diversion condition.
[0012] Optionally, the preset storage unit includes a local cache and a preset database system;
[0013] Determining that target data related to the target recommendation position exists in a preset storage unit, and acquiring the target data from the preset storage unit includes:
[0014] Determining whether there is target data related to the target recommendation position in the local cache;
[0015] If yes, obtaining target data related to the target recommendation position from the local cache;
[0016] If not, determine whether there is target data related to the target recommendation position in the preset database system; if so, obtain the target data related to the target recommendation position from the preset database system and write the target data into the local cache.
[0017] Optionally, the method further includes: when the target recommendation position meets the diversion condition and it is determined that the target data does not exist in the local cache and the preset database system, calling a data service to obtain the target data, and writing the target data into the preset storage unit.
[0018] Optionally, writing the target data into the preset storage unit includes: writing the target data into the local cache; determining whether to write the target data into the preset database system according to a preset writing condition, and if so, writing the target data into the preset database system.
[0019] Optionally, after receiving the access request from the user, the method further comprises: generating a random number in response to the access request;
[0020] According to a preset writing condition, determining whether to write the target data into the preset database system includes:
[0021] Determining whether the random number is within a range defined by the preset writing condition;
[0022] If so, the target data is written into the preset database system.
[0023] Optionally, before writing the target data into the preset storage unit, the method further includes: compressing the target data.
[0024] Optionally, the access request includes an identifier of the target recommendation position and category information of an item corresponding to the target recommendation position;
[0025] Writing the target data into the local cache includes: determining whether the target recommendation position is a specific recommendation position; if so, generating a first key according to the identifier and the category information; if not, generating a second key according to the identifier and a preset page number; and writing the target data into the local cache based on the first key or the second key;
[0026] Writing the target data into the preset database system includes: determining whether the target recommendation position is a specific recommendation position; if so, generating a third key based on the identifier, the category information and the preset redundant sharding information; if not, generating a fourth key based on the identifier, the preset page number and the preset redundant sharding information; based on the third key or the fourth key, writing the target data into the preset database system.
[0027] Optionally, the method further comprises: utilizing a least recently used elimination algorithm to delete the data with the least number of uses in the local cache.
[0028] Optionally, when the target recommendation position does not meet the diversion condition, calling a data service to obtain target data related to the target recommendation position includes:
[0029] When the target recommended position is not a disaster recovery recommended position, calling a data service to obtain target data related to the target recommended position,
[0030] When the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is not enabled for the target recommendation position, the data service is called to obtain the target data related to the target recommendation position, and it is determined whether the target data exists in the preset storage unit. If so, the hit rate of the preset storage unit is updated; if not, the hit rate of the preset storage unit is updated, and the target data is written into the preset storage unit.
[0031] To achieve the above object, according to another aspect of an embodiment of the present invention, a data disaster recovery device is provided, comprising:
[0032] A receiving module, used to receive an access request from a user, wherein the access request is used to access a target recommended location;
[0033] A diversion determination module, used to determine whether the target recommendation position meets the diversion condition;
[0034] A data acquisition module is used to determine whether target data related to the target recommendation position exists in a preset storage unit and obtain the target data from the preset storage unit when the target recommendation position meets the diversion condition; when the target recommendation position does not meet the diversion condition, call a data service to obtain the target data related to the target recommendation position.
[0035] Optionally, the diversion determination module is also used to: determine whether the target recommendation position is a disaster recovery recommendation position, and determine whether the target recommendation position has the disaster recovery function turned on; if the target recommendation position is a disaster recovery recommendation position, and the target recommendation position has the disaster recovery function turned on, then determine that the target recommendation position meets the diversion conditions.
[0036] Optionally, the preset storage unit includes a local cache and a preset database system;
[0037] The data acquisition module is also used to: determine whether there is target data related to the target recommendation position in the local cache; if so, obtain the target data related to the target recommendation position from the local cache; if not, determine whether there is target data related to the target recommendation position in the preset database system; if so, obtain the target data related to the target recommendation position from the preset database system and write the target data into the local cache.
[0038] Optionally, the data acquisition module is also used to: when the target recommendation position meets the diversion condition and it is determined that the target data does not exist in the local cache and the preset database system, call the data service to obtain the target data, and write the target data into the preset storage unit.
[0039] Optionally, the data acquisition module is further used to: write the target data into the local cache; determine whether to write the target data into the preset database system according to a preset writing condition, and if so, write the target data into the preset database system.
[0040] Optionally, the device further comprises a random number module, configured to generate a random number in response to the access request;
[0041] The data acquisition module is also used to: determine whether the random number is within the range defined by the preset writing condition; if so, write the target data into the preset database system.
[0042] Optionally, the data acquisition module is further used to: compress the target data.
[0043] Optionally, the access request includes an identifier of the target recommendation position and category information of an item corresponding to the target recommendation position;
[0044] The data acquisition module is also used to: determine whether the target recommendation position is a specific recommendation position; if so, generate a first key based on the identifier and the category information; if not, generate a second key based on the identifier and a preset page number; based on the first key or the second key, write the target data into the local cache; determine whether the target recommendation position is a specific recommendation position; if so, generate a third key based on the identifier, the category information and the preset redundant sharding information; if not, generate a fourth key based on the identifier, the preset page number and the preset redundant sharding information; based on the third key or the fourth key, write the target data into the preset database system.
[0045] Optionally, the device further comprises an elimination module, configured to utilize a least recently used elimination algorithm to delete the data with the least number of uses in the local cache.
[0046] Optionally, the data acquisition module is also used to: when the target recommendation position is not a disaster recovery recommendation position, call the data service to obtain target data related to the target recommendation position; when the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is not enabled for the target recommendation position, call the data service to obtain target data related to the target recommendation position, determine whether the target data exists in the preset storage unit, and if so, update the hit rate of the preset storage unit; if not, update the hit rate of the preset storage unit, and write the target data into the preset storage unit.
[0047] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the data disaster recovery method of an embodiment of the present invention.
[0048] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the data disaster recovery method of the embodiment of the present invention is implemented.
[0049] An embodiment of the above invention has the following advantages or beneficial effects: because it adopts receiving the user's access request, the access request is used to access the target recommendation position; determine whether the target recommendation position meets the diversion condition; when the target recommendation position meets the diversion condition, determine that there is target data related to the target recommendation position in the preset storage unit, and obtain the target data from the preset storage unit; when the target recommendation position does not meet the diversion condition, call the data service to obtain the target data related to the target recommendation position. Technical means, thereby reducing the pressure on the data service, improving the stability and security of the system, and buying time for data service repair; the disaster recovery recommendation position is configurable and can be flexibly adjusted according to application requirements to ensure that the recommendation position with high access is the disaster recovery recommendation position, further reducing the pressure on the data service; the local cache uses the least recently used elimination algorithm to retain hot spot data, thereby improving the hit rate of the local cache; based on the preset write conditions, data is written to the preset database system, thereby reducing the pressure on the database system.
[0050] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0052] Figure 1 It is a schematic diagram of the main process of the data disaster recovery method according to an embodiment of the present invention;
[0053] Figure 2 It is a schematic diagram of the main process of the data disaster recovery method according to an embodiment of the present invention;
[0054] Figure 3 It is a schematic diagram of the main process of the data disaster recovery method according to an embodiment of the present invention;
[0055] Figure 4 It is a schematic diagram of the main modules of the data disaster recovery device according to an embodiment of the present invention;
[0056] Figure 5 is an architecture diagram of a system using a data disaster recovery device according to an embodiment of the present invention;
[0057] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0058] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0060] Figure 1 FIG. 1 is a schematic diagram of the main process of the data disaster recovery method according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0061] Step S101: receiving an access request from a user, wherein the access request is used to access a target recommended location, wherein the access request may include an identifier of the target recommended location.
[0062] Step S102: Determine whether the target recommendation position meets the diversion condition.
[0063] Specifically, it may include:
[0064] Determine whether the target recommended position is a disaster recovery recommended position, and determine whether the target recommended position has a disaster recovery function enabled;
[0065] If the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is enabled for the target recommendation position, it is determined that the target recommendation position meets the diversion condition.
[0066] Among them, whether the recommendation position is a disaster recovery recommendation position can be configured in advance according to the position of the recommendation position, and the recommendation position configured as a disaster recovery recommendation position can be recorded in the configuration table. After receiving the user's access request, it is determined whether the target recommendation position is a disaster recovery recommendation position according to the configuration table. As for whether to turn on the disaster recovery function, it can be achieved by configuring whether to mock (simulate). Specifically, turning on mock turns off the disaster recovery function, and turning off mock turns on the disaster recovery function. When the disaster recovery recommendation position turns on the disaster recovery function, it means that the target recommendation position meets the diversion conditions, and it is necessary to obtain data related to the target recommendation position from the preset storage unit without calling the data service, thereby reducing the pressure on the data service.
[0067] In an optional embodiment, the pre-set configuration table can be stored in a ZooKeeper container, where ZooKeeper is a distributed, open source distributed application coordination service.
[0068] Step S103: When the target recommendation position meets the diversion condition, it is determined that there is target data related to the target recommendation position in a preset storage unit, and the target data is obtained from the preset storage unit.
[0069] The storage unit includes a local cache and a preset database system. Specifically, this step may include:
[0070] Determining whether there is target data related to the target recommendation position in the local cache;
[0071] If yes, obtaining target data related to the target recommendation position from the local cache;
[0072] If not, determine whether there is target data related to the target recommendation position in the preset database system; if so, obtain the target data related to the target recommendation position from the preset database system and write the target data into the local cache.
[0073] In this embodiment, because the local cache capacity is limited, only hot data is saved in the local cache, so if the target data being accessed is not obtained from the local cache, the target data will be written to the local cache. The preset database system serves as a secondary cache when the local cache cannot hit, thereby improving the hit rate of the storage unit. Specifically, the least recently used algorithm is used in the local cache to delete the data with the least number of uses in the local cache. The least recently used algorithm (Least Recently Used, LRU) eliminates data based on the historical access records of the data. Its core idea is that if the data has been accessed recently, then the probability of being accessed in the future is also higher. Among them, the hit rate is equal to the ratio between the number of hits and the total number of access requests, and a hit refers to the existence of relevant data of the target recommendation position in the storage unit.
[0074] In an optional embodiment, in order to ensure that there are no empty windows in the recommendation position, when the target recommendation position meets the diversion conditions and the target data does not exist in the local cache and the preset database system, it is necessary to call the data service to obtain the target data and write the target data into the preset storage unit.
[0075] Among them, Figure 2 As shown, writing the target data into a preset storage unit includes:
[0076] Step S201: writing the target data into the local cache;
[0077] Step S202: determining whether to write the target data into the preset database system according to the preset writing condition;
[0078] Step S203: If yes, writing the target data into the preset database system;
[0079] Step S204: If not, the target data is not written into the preset database system.
[0080] In order to reduce the pressure on the preset database system and reduce costs, the preset database system will not store the full amount of data. Therefore, when writing the target data to the preset database system, it is necessary to determine whether the write condition is met. When the write condition is met, the target data is written to the preset database system. When the write condition is not met, the target data is not written to the preset database system. That is, the embodiment of the present invention limits the proportion of the preset database system to be written through the write condition. As an example, the following process can be used to determine whether the target data is written to the preset database system:
[0081] determining whether a random number is within a range defined by the write condition, wherein the random number is generated after receiving a user access request;
[0082] If so, it is determined to write the target data into the preset database system.
[0083] For example, the random number generated after receiving the user access request is between 0 and 50, and the writing condition is that the random number is greater than or equal to 1 and less than or equal to 10. If the random number generated after receiving the user access request is 8, the relevant data of the target recommendation position is written into the preset database system.
[0084] In an optional embodiment, before writing the target data into the preset storage unit, the target data may be compressed to reduce the size of the target data, thereby storing more target data in a local cache with limited capacity, improving the hit rate and enhancing the diversion effect.
[0085] Step S104: When the target recommendation position does not meet the diversion condition, call the data service to obtain target data related to the target recommendation position.
[0086] The target recommendation position not meeting the diversion condition includes that the target recommendation position is not a disaster recovery recommendation position and the target recommendation position is a disaster recovery recommendation position but the disaster recovery function is not enabled.
[0087] When the target recommended position is not a disaster recovery recommended position, calling a data service to obtain target data related to the target recommended position;
[0088] When the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is not enabled for the target recommendation position, the data service is called to obtain the target data related to the target recommendation position, and it is determined whether the target data exists in the preset storage unit. If so, the hit rate of the preset storage unit is updated; if not, the hit rate of the preset storage unit is updated, and the target data is written into the preset storage unit. The process of writing the target data into the preset storage unit can refer to Figure 2 The embodiment shown.
[0089] In this embodiment, when the target recommendation position does not have the disaster recovery function enabled, the hit rate of the preset storage unit can be counted to determine whether the disaster recovery recommendation position is set reasonably and whether the expected diversion effect is achieved. When the hit rate of the preset storage unit is not high, the configuration table of the disaster recovery recommendation position can be modified. The hit rate of the preset storage unit is equal to the sum of the hit rate of the local cache and the hit rate of the preset database system.
[0090] The data disaster recovery method of the embodiment of the present invention receives an access request from a user, wherein the access request is used to access a target recommendation position; determines whether the target recommendation position meets a diversion condition; when the target recommendation position meets the diversion condition, determines whether target data related to the target recommendation position exists in a preset storage unit, and obtains the target data from the preset storage unit; when the target recommendation position does not meet the diversion condition, calls a data service to obtain the target data related to the target recommendation position, thereby reducing the pressure on the data service, improving the stability and security of the system, and buying time for data service repair; the disaster recovery recommendation position is configurable and can be flexibly adjusted according to application requirements to ensure that the recommendation position with a high access degree is the disaster recovery recommendation position, further reducing the pressure on the data service; the local cache uses a least recently used elimination algorithm to retain hot spot data, thereby improving the hit rate of the local cache; and writes data to a preset database system based on preset write conditions, thereby reducing the pressure on the database system.
[0091] In an optional embodiment, the target data is stored in the local cache and the preset database system in the form of key-value. Therefore, before writing the target data to the local cache and the preset database system, the key of the target data needs to be generated first. For the local cache, it can be determined according to the following process:
[0092] Determining whether the target recommendation position is a specific recommendation position;
[0093] If yes, generating a first key according to the identifier of the target recommendation position and the category information of the item corresponding to the target recommendation position;
[0094] If not, a second key is generated according to the identifier and a preset page number.
[0095] For the preset database system, it can be determined according to the following process:
[0096] Determining whether the target recommendation position is a specific recommendation position;
[0097] If yes, generating a third key according to the identifier of the target recommendation position, the category information of the item corresponding to the target recommendation position, and the preset redundant fragmentation information;
[0098] If not, a fourth key is generated according to the identifier, the preset page number and the preset redundant sharding information.
[0099] Among them, the identifier of the target recommendation position and the category information of the item corresponding to the target recommendation position can be obtained from the user access request.
[0100] The setting of specific recommendation positions can be flexibly set according to the application scenario. Taking the recommendation position on an e-commerce website as an example, the specific recommendation position can be the recommendation position on the item details page. Because the recommendation position on the item details page needs to have a certain category relevance with the item on the item details page, the specific recommendation position can be set as the recommendation position on the item details page. The preset page number can be configured according to the depth of the user's browsing of the target recommendation position, so that the data can be browsed within the user's browsing depth range. As an example, the preset page number is 5. The category information can be the category to which the item belongs. In order to avoid data access hotspots in the database system, the database system redundantly stores the target data. For example, if there are 16 shards in the database system for storing target data, the preset redundant shard information is 16, so as to ensure that each shard has a copy of the target data.
[0101] As an example, a string obtained by concatenating the identifier of the target recommendation position and the category information of the item corresponding to the target recommendation position can be used as the first key. The second key, the third key and the fourth key are generated in a similar manner to the first key.
[0102] Figure 3 FIG. 1 is a schematic diagram of the main process of a data disaster recovery method according to another embodiment of the present invention. Figure 3 As shown, the method includes:
[0103] Step S301: receiving an access request from a user, the access request being used to access a target recommendation position, the access request including an identifier of the target recommendation position and category information of an item corresponding to the target recommendation position;
[0104] Step S302: Based on the preset configuration table, determine whether the target recommended position is a disaster recovery recommended position; if so, execute step S303; if not, execute step S309;
[0105] Step S303: Determine whether the target recommended position has a disaster recovery function enabled; if so, execute step S304; if not, execute step S310;
[0106] Step S304: Determine whether there is relevant data corresponding to the target recommendation position in the local cache; if so, execute step S307; if not, execute step S305;
[0107] Step S305: Determine whether the preset database system has relevant data corresponding to the target recommendation position; if so, execute step S306; if not, execute step S310;
[0108] Step S306: writing the target data into the local cache;
[0109] Step S307: decompress the target data;
[0110] Step S308: Send the decompressed target data to the client;
[0111] Step S309: calling the basic data service to obtain target data related to the target recommendation position;
[0112] Step S310: calling the basic data service to obtain target data related to the target recommendation position, and counting the hit rates of the local cache and the preset database system;
[0113] Step S311: sending the acquired target data to the client;
[0114] Step S312: compressing the target data;
[0115] Step S313: writing the compressed target data into the local cache;
[0116] Step S314: determine whether to write the compressed target data into a preset database system; if so, execute step S315; if not, execute step S316;
[0117] Step S315: writing the compressed target data into a preset database system;
[0118] Step S316: Do not write the compressed target data into the preset database system.
[0119] For specific implementation details of this embodiment, please refer to Figure 1 The present invention will not be described in detail in detail with reference to the embodiments shown.
[0120] The data disaster recovery method of the embodiment of the present invention receives an access request from a user, wherein the access request is used to access a target recommendation position; determines whether the target recommendation position meets a diversion condition; when the target recommendation position meets the diversion condition, determines whether target data related to the target recommendation position exists in a preset storage unit, and obtains the target data from the preset storage unit; when the target recommendation position does not meet the diversion condition, calls a data service to obtain a technical means of target data related to the target recommendation position, thereby reducing the pressure on the data service, improving the stability and security of the system, and buying time for data service repair; the disaster recovery recommendation position is configurable and can be flexibly adjusted according to application requirements to ensure that the recommendation position with a high access degree is the disaster recovery recommendation position, thereby further reducing the pressure on the data service; the local cache uses a least recently used elimination algorithm to retain hot spot data, thereby improving the hit rate of the local cache; and writes data to a preset database system based on preset write conditions, thereby reducing the pressure on the database system.
[0121] Figure 4 4 is a schematic diagram of the main modules of the data disaster recovery device 400 according to an embodiment of the present invention. Figure 4 As shown, the device 400 includes:
[0122] A receiving module 401 is used to receive an access request from a user, where the access request is used to access a target recommended location;
[0123] A diversion determination module 402 is used to determine whether the target recommendation position meets the diversion condition;
[0124] The data acquisition module 403 is used to determine whether target data related to the target recommendation position exists in a preset storage unit and obtain the target data from the preset storage unit when the target recommendation position meets the diversion condition; when the target recommendation position does not meet the diversion condition, call the data service to obtain the target data related to the target recommendation position.
[0125] Optionally, the diversion determination module 402 is also used to: determine whether the target recommendation position is a disaster recovery recommendation position, and determine whether the target recommendation position has the disaster recovery function turned on; if the target recommendation position is a disaster recovery recommendation position, and the target recommendation position has the disaster recovery function turned on, then determine that the target recommendation position meets the diversion conditions.
[0126] Optionally, the preset storage unit includes a local cache and a preset database system;
[0127] The data acquisition module 403 is also used to: determine whether there is target data related to the target recommendation position in the local cache; if so, obtain the target data related to the target recommendation position from the local cache; if not, determine whether there is target data related to the target recommendation position in the preset database system; if so, obtain the target data related to the target recommendation position from the preset database system and write the target data into the local cache.
[0128] Optionally, the data acquisition module 403 is also used to: when the target recommendation position meets the diversion condition and it is determined that the target data does not exist in the local cache and the preset database system, call the data service to obtain the target data, and write the target data into the preset storage unit.
[0129] Optionally, the data acquisition module 403 is further used to: write the target data into the local cache; determine whether to write the target data into the preset database system according to a preset writing condition, and if so, write the target data into the preset database system.
[0130] Optionally, the device further comprises a random number module, configured to generate a random number in response to the access request;
[0131] The data acquisition module 403 is further used to: determine whether the random number is within the range defined by the preset writing condition; if so, write the target data into the preset database system.
[0132] Optionally, the data acquisition module 403 is further used to: compress the target data.
[0133] Optionally, the access request includes an identifier of the target recommendation position and category information of an item corresponding to the target recommendation position;
[0134] The data acquisition module is also used to: determine whether the target recommendation position is a specific recommendation position; if so, generate a first key based on the identifier and the category information; if not, generate a second key based on the identifier and a preset page number; based on the first key or the second key, write the target data into the local cache; determine whether the target recommendation position is a specific recommendation position; if so, generate a third key based on the identifier, the category information and the preset redundant sharding information; if not, generate a fourth key based on the identifier, the preset page number and the preset redundant sharding information; based on the third key or the fourth key, write the target data into the preset database system.
[0135] Optionally, the device further comprises an elimination module, configured to utilize a least recently used elimination algorithm to delete the data with the least number of uses in the local cache.
[0136] Optionally, the data acquisition module is also used to: when the target recommendation position is not a disaster recovery recommendation position, call the data service to obtain target data related to the target recommendation position; when the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is not enabled for the target recommendation position, call the data service to obtain target data related to the target recommendation position, determine whether the target data exists in the preset storage unit, and if so, update the hit rate of the preset storage unit; if not, update the hit rate of the preset storage unit, and write the target data into the preset storage unit.
[0137] The data disaster recovery device of the embodiment of the present invention receives an access request from a user, wherein the access request is used to access a target recommendation position; determines whether the target recommendation position meets a diversion condition; when the target recommendation position meets the diversion condition, determines whether target data related to the target recommendation position exists in a preset storage unit, and obtains the target data from the preset storage unit; when the target recommendation position does not meet the diversion condition, calls a data service to obtain a technical means of target data related to the target recommendation position, thereby reducing the pressure on the data service, improving the stability and security of the system, and buying time for data service repair; the disaster recovery recommendation position is configurable and can be flexibly adjusted according to application requirements to ensure that the recommendation position with a high access degree is the disaster recovery recommendation position, further reducing the pressure on the data service; the local cache uses a least recently used elimination algorithm to retain hot spot data, thereby improving the hit rate of the local cache; and writes data to a preset database system based on preset write conditions, thereby reducing the pressure on the database system.
[0138] The above device can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0139] Figure 5 is a schematic diagram of the architecture of a system using a data disaster recovery device according to an embodiment of the present invention. Figure 5 As shown, the system includes a configuration center, a ZooKeeper container, a data disaster recovery device cluster, a recommended client module, Snappy (for compression / decompression), a local cache, a preset database system and a data service.
[0140] The configuration center is used to manage configuration information, such as configuring disaster recovery recommendation positions, preset page numbers, whether to enable disaster recovery functions, and write conditions of the database system. The ZooKeeper container is used to store configuration information. For the configuration stored on ZooKeeper, it will be placed under each path, such as / rec / cart, / rec / ware, etc., and the configuration information of the corresponding recommendation positions is stored under these paths. The recommendation position client is used to send access requests to the data disaster recovery device cluster. Each access request includes the identifier of the target recommendation position, which is used to distinguish different recommendation positions. The data disaster recovery device cluster returns data related to the target recommendation position to the recommendation position client. Each service instance in the data disaster recovery device cluster will cache a copy of the configuration information of the configuration center and monitor each configuration path at the same time. If the content of a node on the configuration center changes, the cache configuration information of all service instances in the cluster will be modified synchronously. Snappy is an open source compression / decompression library of Google, which is used to compress / decompress target data. Local cache can be implemented using the open source guava class library provided by Google, which provides the ability to operate local cache information, which can increase the hit rate in high concurrency and reduce the impact of large traffic on the database system. The database system can be a redis-based database cluster, which can provide high-performance data query and storage capabilities, and serve as a secondary cache when the local cache fails to hit, thereby increasing the cache hit rate. The data service is used to provide relevant data for the recommended position.
[0141] Figure 6 An exemplary system architecture 600 is shown to which the data disaster recovery method or data disaster recovery device according to the embodiment of the present invention can be applied.
[0142] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 606. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0143] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0144] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0145] The server 605 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.
[0146] It should be noted that the data disaster recovery method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the data disaster recovery device is generally disposed in the server 605 .
[0147] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0148] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0149] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0150] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0151] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0152] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0153] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0154] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a sending module, an acquisition module, a determination module, and a first processing module. The names of these modules do not, in some cases, constitute a limitation on the unit itself. For example, the sending module may also be described as a "module for sending a picture acquisition request to the connected server."
[0155] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0156] receiving an access request from a user, wherein the access request is used to access a target recommended location;
[0157] Determine whether the target recommendation position meets the diversion condition;
[0158] When the target recommendation position meets the diversion condition, determining that target data related to the target recommendation position exists in a preset storage unit, and acquiring the target data from the preset storage unit;
[0159] When the target recommendation position does not meet the diversion condition, a data service is called to obtain target data related to the target recommendation position.
[0160] The technical solution of the embodiment of the present invention receives an access request from a user, wherein the access request is used to access a target recommendation position; determines whether the target recommendation position meets a diversion condition; when the target recommendation position meets the diversion condition, determines whether target data related to the target recommendation position exists in a preset storage unit, and obtains the target data from the preset storage unit; when the target recommendation position does not meet the diversion condition, a technical means of calling a data service to obtain target data related to the target recommendation position reduces the pressure on the data service, improves the stability and security of the system, and buys time for data service repair; the disaster recovery recommendation position is configurable and can be flexibly adjusted according to application requirements to ensure that the recommendation position with a high access degree is a disaster recovery recommendation position, further reducing the pressure on the data service; the local cache uses a least recently used elimination algorithm to retain hot spot data, thereby improving the hit rate of the local cache; data is written to a preset database system based on preset write conditions, thereby reducing the pressure on the database system.
[0161] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data disaster recovery method, characterized in that: include: receiving an access request from a user, wherein the access request is used to access a target recommended location; Determine whether the target recommended position meets the diversion condition; wherein, if the target recommended position is a disaster recovery recommended position and the disaster recovery function is enabled, the diversion condition is met; When the target recommendation position meets the diversion condition, determining that target data related to the target recommendation position exists in a preset storage unit, and acquiring the target data from the preset storage unit; When the target recommendation position does not meet the diversion conditions, calling the data service to obtain the target data related to the target recommendation position, including: when the target recommendation position is not a disaster recovery recommendation position, calling the data service to obtain the target data related to the target recommendation position; when the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is not enabled for the target recommendation position, calling the data service to obtain the target data related to the target recommendation position, and determining whether the target data exists in the preset storage unit, and if so, updating the hit rate of the preset storage unit; if not, updating the hit rate of the preset storage unit, and writing the target data to the preset storage unit.
2. The method according to claim 1, characterized in that Determining whether the target recommendation position meets the diversion condition includes: Determine whether the target recommended position is a disaster recovery recommended position, and determine whether the target recommended position has a disaster recovery function enabled; If the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is enabled for the target recommendation position, it is determined that the target recommendation position meets the diversion condition.
3. The method according to claim 2, characterized in that The preset storage unit includes a local cache and a preset database system; Determining that target data related to the target recommendation position exists in a preset storage unit, and acquiring the target data from the preset storage unit includes: Determining whether there is target data related to the target recommendation position in the local cache; If yes, obtaining target data related to the target recommendation position from the local cache; If not, determine whether there is target data related to the target recommendation position in the preset database system; if so, obtain the target data related to the target recommendation position from the preset database system and write the target data into the local cache.
4. The method according to claim 3, characterized in that The method also includes: when the target recommendation position meets the diversion condition and it is determined that the target data does not exist in the local cache and the preset database system, calling the data service to obtain the target data, and writing the target data into the preset storage unit.
5. The method according to claim 4, characterized in that Writing the target data into the preset storage unit comprises: Writing the target data into the local cache; According to the preset writing condition, it is determined whether to write the target data into the preset database system, and if so, the target data is written into the preset database system.
6. The method according to claim 5, characterized in that After receiving an access request from a user, the method further includes: generating a random number in response to the access request; According to a preset writing condition, determining whether to write the target data into the preset database system includes: Determining whether the random number is within a range defined by the preset writing condition; If so, the target data is written into the preset database system.
7. The method according to claim 6, characterized in that Before writing the target data into the preset storage unit, the method further includes: compressing the target data.
8. The method according to claim 7, characterized in that The access request includes an identifier of the target recommendation position and category information of an item corresponding to the target recommendation position; Writing the target data into the local cache includes: Determining whether the target recommendation position is a specific recommendation position; If yes, generating a first key according to the identifier and the category information; If not, generating a second key according to the identifier and a preset page number; Based on the first key or the second key, writing the target data into the local cache; Writing the target data into the preset database system includes: Determining whether the target recommendation position is a specific recommendation position; If yes, generating a third key according to the identifier, the category information and the preset redundant sharding information; If not, generating a fourth key according to the identifier, the preset page number and the preset redundant sharding information; Based on the third key or the fourth key, the target data is written into the preset database system.
9. The method according to claim 8, characterized in that The method further comprises: The least recently used elimination algorithm is used to delete the data with the least number of uses in the local cache.
10. A data disaster recovery device, characterized in that: include: A receiving module, used to receive an access request from a user, wherein the access request is used to access a target recommended location; A diversion determination module is used to determine whether the target recommended position meets the diversion condition; wherein, if the target recommended position is a disaster recovery recommended position and the disaster recovery function is turned on, the diversion condition is met; A data acquisition module is used to determine whether target data related to the target recommendation position exists in a preset storage unit when the target recommendation position meets the diversion condition, and obtain the target data from the preset storage unit; when the target recommendation position does not meet the diversion condition, call a data service to obtain the target data related to the target recommendation position, including: when the target recommendation position is not a disaster recovery recommendation position, call a data service to obtain the target data related to the target recommendation position; when the target recommendation position is a disaster recovery recommendation position, and the disaster recovery function is not enabled for the target recommendation position, call a data service to obtain the target data related to the target recommendation position, determine whether the target data exists in the preset storage unit, if so, update the hit rate of the preset storage unit; if not, update the hit rate of the preset storage unit, and write the target data into the preset storage unit.
11. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.
12. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Video content pushing method and device
CN109600672A