Data storage system and strong consistent caching method
By introducing a cache layer and a cache system into the data storage system and using object-level unique timestamps to mark data, it solves the problem that traditional systems are difficult to meet high throughput and low latency at the same time, and achieves strong data consistency and high system availability.
Patent Information
- Application Number
- CN202411623270.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-25
AI Technical Summary
Traditional data storage systems are difficult to meet the composite storage needs of high throughput and low latency at the same time, and there are problems of data inconsistency and poor system availability.
A data storage system is designed, including a controller, a distributed storage system, a cache layer and a cache system. The data is read, cached and eliminated in the cache system through an asynchronous interface, and the same version of the same object data is marked through an object-level unique timestamp to ensure strong data consistency.
It realizes the need to meet both high throughput and low latency, solves the data inconsistency problem, and improves the availability of the system through failure isolation at the cache layer.
Smart Images

Figure CN119512460A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data caching, and in particular to a data storage system and a strongly consistent caching method. Background Art
[0002] The explosive growth of data, especially the explosion of unstructured data represented by images and videos, has brought huge challenges to traditional data storage systems. Traditional data storage systems are mainly based on structured data, and the system design focuses more on low latency and high IOPS (Input / Output Operations Per Second, that is, the number of reads and writes per second), while unstructured data storage systems focus more on massive scalability, high throughput, and low cost in system design. Users' storage needs are complex, varied, and rich. There are both large file storage needs that rely on high throughput writing and low-frequency reading, and small file storage needs that focus more on low latency and high-frequency reading. Therefore, a single distributed storage system cannot meet users' diverse storage needs well.
[0003] In order to meet the complex storage requirements of high-throughput large file storage as the main and low-latency small file storage as the auxiliary, tiered storage is usually used to design two independent systems, one is a high-throughput, low-cost mass storage system for storing large files that focus on high throughput, and the other is a low-latency, more expensive small storage system for storing small files that focus on low latency. Another way is to add a low-latency, more expensive small cache system on top of the high-throughput, low-cost mass storage system. All data is stored persistently in the mass storage system, and some data is cached in the small cache system. Although compared with tiered storage, the combination of mass storage system and small cache system is more flexible, easy to expand, and more cost-controlled, its data processing is more complex, and there may be problems such as poor system availability and data inconsistency. Summary of the invention
[0004] Based on this, it is necessary to provide a data storage system and a strong consistency caching method to address the above technical problems, which can ensure the strong consistency of data.
[0005] In a first aspect, the present application provides a data storage system, including a controller, a distributed storage system, a cache layer, and a cache system; wherein:
[0006] A distributed storage system, used to persistently store object data, or to read or delete persistently stored object data, under the control of a controller;
[0007] The cache layer is used to provide various asynchronous interfaces. The controller controls the cache layer to read data from the cache system, cache data, or eliminate data by calling the asynchronous interface.
[0008] Among the data stored in the distributed storage system, the cache layer, and the cache system, the same version of the same object data is marked with the same timestamp.
[0009] In one embodiment, the distributed storage system includes a distributed database and a distributed storage engine; the distributed storage engine is used to store object data; the distributed database is used to store metadata of each object data, and the metadata includes a timestamp.
[0010] In one of the embodiments, the cache layer is provided with a cache unit, and the asynchronous interface includes a pre-write interface;
[0011] The controller is used to call the pre-written interface, read the target object data from the client, and cache the target object data in the cache unit; the cache unit marks the target object data with an entity tag;
[0012] The controller is further used to persistently store the target object data in the distributed storage engine and record the metadata of the target object data in the distributed database;
[0013] A distributed database is used to generate a unique target timestamp at the object level, mark the target object data based on the target timestamp, and synchronize the target timestamp to the cache layer and cache system.
[0014] In one of the embodiments, the asynchronous interface further includes a write-behind cache interface;
[0015] The controller is further used to call the write-after-cache interface and input the first object identifier, the entity tag and the target timestamp;
[0016] The cache layer is used to store the data marked by the entity tag into the cache unit and the cache system according to the first object identifier and the target timestamp, and delete the cache data corresponding to the entity tag from the cache unit.
[0017] In one of the embodiments, the controller is used to determine whether the data marked by the entity tag needs to be cached according to the cache policy; if so, call the write-after-cache interface and pass in the first object identifier, the entity tag and the target timestamp.
[0018] In one embodiment, the asynchronous interface includes a read interface;
[0019] The controller is used to call the read interface and input the second object identifier, the current timestamp and the waiting time;
[0020] The cache layer is used to query the corresponding object data according to the second object identifier and the current timestamp during the waiting time, and return the queried object data to the controller;
[0021] The controller is also used to transfer the object data returned by the cache layer to the client.
[0022] In one of the embodiments, the cache layer is provided with a cache unit, and the asynchronous interface further comprises a pre-read interface;
[0023] The controller is used to query the metadata of the object to be read from the distributed database to obtain the current timestamp of the object to be read;
[0024] The controller is further used to call the pre-reading interface and pass in the second object identifier and the current timestamp;
[0025] The cache layer is used to retrieve whether the specified object data exists from the cache unit according to the second object identifier and the current timestamp; if not, read the specified object data corresponding to the second object identifier and the current timestamp from the cache system, and cache the specified object data in the cache unit.
[0026] In one of the embodiments, the asynchronous interface further includes a read-behind cache interface;
[0027] The cache layer is used to invalidate information to the controller if the corresponding object data is not found according to the second object identifier and the current timestamp within the waiting time;
[0028] The controller is further configured to, when receiving invalid information, read object data corresponding to the second object identifier and the current timestamp from the distributed storage engine, and call the read-after-cache interface to pass in the second object identifier, the current timestamp, and the read object data;
[0029] The cache layer is further used to store the object data transmitted by the read-after-cache interface into the cache unit and the cache system according to the second object identifier and the current timestamp.
[0030] In one of the embodiments, the cache layer is provided with a cache unit, and the asynchronous interface includes a deletion interface;
[0031] The controller is used to query the metadata of the object to be deleted from the distributed database, obtain the timestamp of the object to be read, and call the deletion interface to pass in the third object identifier and the timestamp of the object to be read;
[0032] The cache layer is used to delete cache data in the cache unit and the cache system according to the third object identifier and the timestamp of the object to be read.
[0033] In a second aspect, the present application further provides a strongly consistent cache method, which is applied to the data storage system as described in the first aspect above, the data storage system includes a controller, a distributed storage system, a cache layer and a cache system; the method includes the following steps:
[0034] The distributed storage system, under the control of the controller, persistently stores object data, or performs read operations or delete operations on persistently stored object data;
[0035] The cache layer provides various asynchronous interfaces;
[0036] The controller controls the cache layer to read data from the cache system, cache data, or eliminate data by calling the asynchronous interface;
[0037] Among the data stored in the distributed storage system, the cache layer, and the cache system, the same version of the same object data is marked with the same timestamp.
[0038] The above data storage system and strong consistent cache method, the data storage system includes a controller, a distributed storage system, a cache layer and a cache system; the distributed storage system, under the control of the controller, persistently stores object data, or performs read operations or delete operations on persistently stored object data; the cache layer provides various asynchronous interfaces; the controller controls the cache layer to read data, cache data or eliminate data from the cache system by calling the asynchronous interface; wherein, the same version of the same object data in the distributed storage system, the cache layer and the cache system is marked by the same timestamp. Through the above method, combined with the distributed storage system, the cache layer and the cache system, the requirements of high throughput and low latency can be met at the same time. Based on the unique and unchanging timestamp at the object level, the same version of the same object data in the distributed storage system, the cache layer and the cache system are marked, which ensures the strong consistency of the data and can solve the problem of data inconsistency in the data storage system. The cache layer provides various asynchronous interfaces for completing the reading, caching or elimination of object data in the cache system, and the cache system is used as a bypass system. When the cache system fails and is unavailable, the cache layer achieves good fault isolation, so that the failure of the cache system will not affect the overall storage service, thereby improving the availability of the data storage system. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0040] FIG1 is a schematic diagram of the structure of a data storage system in one embodiment;
[0041] FIG2 is a schematic diagram of the structure of a data storage system in another embodiment;
[0042] FIG3 is a schematic diagram of a cache process for writing object data in one embodiment;
[0043] FIG4 is a schematic diagram of a cache flow of reading object data in one embodiment;
[0044] FIG5 is a schematic diagram of a cache flow chart of deleting object data in one embodiment;
[0045] FIG6 is a schematic diagram of a flow chart of a strongly consistent cache method in one embodiment. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0047] It is to be understood that the terms "first", "second", etc. used in this application may be used to describe various elements in this article, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first object identifier may be referred to as a second object identifier, and similarly, a second object identifier may be referred to as a first object identifier. Both the first object identifier and the second object identifier are object identifiers, but they are not the same object identifier.
[0048] In an exemplary embodiment, as shown in FIG1 , a data storage system is provided, including a controller 10, a distributed storage system 20, a cache layer 30, and a cache system 40; wherein:
[0049] The distributed storage system 20 is used to persistently store object data, or to read or delete persistently stored object data under the control of the controller 10; the cache layer 30 is used to provide various asynchronous interfaces; the controller 10 controls the cache layer 30 to read data, cache data or eliminate data from the cache system 40 by calling the asynchronous interface; wherein, in the data stored in the distributed storage system 20, the cache layer 30 and the cache system 40, the same version of the same object data is marked with the same timestamp.
[0050] Among them, all data of this embodiment are persistently stored in the distributed storage system 20, and hot data or small files sensitive to delay that meet specific cache conditions are cached in the cache system 40. In a specific implementation, the controller 10 is used to control the read, write and delete process of object data, and decide whether to cache object data according to the cache strategy, and control the specific cache process.
[0051] Optionally, in the distributed storage system 20, data is represented as objects, and the corresponding metadata includes a unique and invariant timestamp at the object level. In the cache layer 30 and the cache system 40, data is cached in the form of key-value pairs, and the key of the data includes a unique and invariant timestamp at the object level.
[0052] In an optional implementation, when writing data, the controller 10 controls the distributed storage system 20 to persistently store the data in the form of an object, and decides whether to cache the data according to the cache policy, and if so, caches the data synchronously to the cache system 40. When reading data, the controller 10 preferentially reads data from the cache system 40 by calling the asynchronous interface of the cache layer 30, and reads data from the distributed storage system 20 in the case of a data miss.
[0053] Exemplarily, the cache layer 30 provides a set of asynchronous interfaces for the data storage system in the form of a lib library, which is used to realize low-latency reading of data, caching of data or elimination of data from the cache system 40. Various types of asynchronous interfaces include: pre-read interface, read interface, read-after-cache interface; pre-write interface, write-after-cache interface; delete interface. The cache layer 30 includes a cache unit, which can be a process-level memory LRU cache (a high-speed cache using a least recently used algorithm) as a first-level cache, and the cache system 40 as a second-level cache. The cache layer 30 plays a role in isolating the failure of the cache system 40.
[0054] In an optional implementation, the cache system 40, as a secondary cache, will persist cached objects and eliminate cached objects according to specific rules. The cache system 40 provides a set of read, write, and delete key-value operation interfaces for the cache layer 30, where the key can be <object identifier, timestamp>, and the timestamp is consistent with the timestamp of the cached object in the distributed storage system 20. Based on the key-value operation interface, the cache layer 30 can read data from the cache system 40, cache data, or eliminate data.
[0055] In the above data storage system, the distributed storage system 20, the cache layer 30 and the cache system 40 are combined to meet the requirements of high throughput and low latency at the same time. Based on the unique and unchanging timestamp at the object level, the same version of the same object data in the distributed storage system 20, the cache layer 30 and the cache system 40 are marked to ensure strong consistency of the data and solve the problem of data inconsistency in the data storage system. The cache layer 30 is used to provide various asynchronous interfaces for completing the reading, caching or elimination of object data in the cache system 40, and the cache system 40 is used as a bypass system. When the cache system 40 fails and is unavailable, the cache layer 30 achieves good fault isolation, so that the failure of the cache system 40 will not affect the overall storage service, thereby improving the availability of the data storage system.
[0056] In an exemplary embodiment, as shown in FIG. 2 , a distributed storage system 20 includes a distributed database 201 and a distributed storage engine 202 ; the distributed storage engine 202 is used to store object data; and the distributed database 201 is used to store metadata of each object data, wherein the metadata includes a timestamp.
[0057] The distributed storage system 20 includes two parts: a distributed database 201 and a distributed storage engine 202. Data is represented in the form of objects, object data is stored in the distributed storage engine 202, and metadata of the object is stored in the distributed database 201. The metadata of the object includes a unique and unchanging timestamp, and different versions of each object correspond to different timestamps.
[0058] Optionally, the timestamp corresponding to each object data is generated by the distributed database 201 when the object data is written. The storage, reading, writing and deletion operations of the object are implemented in the distributed database 201, the cache layer 30 and the cache system 40 using <object identifier, timestamp> as the object key.
[0059] In an exemplary embodiment, as shown in Figure 3, the cache layer 30 is provided with a cache unit, and the asynchronous interface includes a pre-write interface; the controller 10 is used to call the pre-write interface, read the target object data from the client, and cache the target object data in the cache unit; the cache unit marks the target object data with an entity tag; the controller 10 is also used to persistently store the target object data in the distributed storage engine 202, and record the metadata of the target object data in the distributed database 201; the distributed database 201 is used to generate a unique target timestamp at the object level, mark the target object data based on the target timestamp, and synchronize the target timestamp to the cache layer 30 and the cache system 40.
[0060] Among them, the cache unit can be a process-level memory LRU cache. The controller 10 first calls the pre-write interface of the cache layer 30 to read the target object data from the client. On the one hand, the target object data is cached in the cache unit of the cache layer 30. At this time, no timestamp is generated. The entity tag (Entity Tag, ETag, which can be understood as a resource identifier) of the target object data is used as the key in the cache unit. On the other hand, the target object data is returned as a return value. The controller 10 persistently stores the target object data in the distributed storage engine 202, generates an ETag, and records the metadata of the target object data in the distributed database 201. At the same time, the distributed database 201 generates a unique target timestamp at the object level. The generated target timestamp is synchronized to the cache layer 30 and the cache system 40, and the key of the target object data in the cache layer 30 and the cache system 40 is adjusted.
[0061] In this embodiment, a method for persistently storing object data in the distributed storage system 20 is provided, and a unique target timestamp at the object level is generated by the distributed database 201 and synchronized to the cache layer 30 and the cache system 40, thereby ensuring strong consistency of the data and being able to solve the problem of data inconsistency in the data storage system.
[0062] In an exemplary embodiment, as shown in Figure 3, the asynchronous interface also includes a write-after-cache interface; the controller 10 is also used to call the write-after-cache interface to pass in the first object identifier, entity tag and target timestamp; the cache layer 30 is used to store the data marked by the entity tag into the cache unit and the cache system 40 according to the first object identifier and the target timestamp, and delete the cache data corresponding to the entity tag from the cache unit.
[0063] Among them, the controller 10 calls the post-write cache interface of the cache layer 30, passes in the parameters <object identifier, ETag, timestamp>, and the cache layer 30 executes asynchronously: using <object identifier, timestamp> as the key, the data corresponding to the ETag is stored in the cache layer 30 and the cache system 40 respectively, completing the object cache, and deleting the cache data with ETag as the key from the cache layer 30.
[0064] In this embodiment, a timestamp synchronization method and an object data caching method are provided, so that the same version of the same object data in the data stored in the distributed storage system 20, the cache layer 30 and the cache system 40 is marked with the same timestamp.
[0065] In an exemplary embodiment, the controller 10 is used to determine whether the data marked by the entity tag needs to be cached according to the cache policy; if so, call the write-after-cache interface and pass in the first object identifier, the entity tag and the target timestamp.
[0066] The cache strategy may correspond to the hot and cold judgment conditions, delay requirements or data volume requirements, which are not limited in this embodiment. For example, if the number of read and write times of the data marked by the entity tag exceeds the set number, the data is cached; if the delay required by the data marked by the entity tag is less than the set threshold, the data is cached; if the data marked by the entity tag is less than a certain amount of data, the data is cached.
[0067] In this embodiment, the controller 10 determines whether to cache an object based on a cache strategy, so that hot data or small files sensitive to latency that meet specific cache conditions are cached in the cache system 40 to meet low latency requirements.
[0068] Exemplarily, the distributed storage system 20 is referred to as LDSS, the distributed database 201 is referred to as DDB, the distributed storage engine 202 is referred to as DSS, the cache layer 30 is referred to as CL, the cache system 40 is referred to as CS, and the cache unit adopts a memory LRU cache. Referring to FIG3, the cache process of writing an object is described with an object obj:
[0069] 1) The controller 10 calls the CL pre-write interface writePrepare(obj, InputStream), which reads the InputStream to obtain the data corresponding to obj and stores it in the memory buffer. It also obtains the etag corresponding to the data and<etag,buffer> Store in memory LRU cache and return buffer as the return value of the interface.
[0070] 2) The controller 10 writes the data in the buffer into the DSS, generates the corresponding etag, and writes the metadata corresponding to obj into the DDB. The DDB generates a unique timestamp ts for obj. When multiple objects with the same name are written to obj at the same time, the ts generated for each write is different.
[0071] 3) The controller 10 calls the write-post cache interface writePost(obj, etag, ts) of CL, which executes asynchronously: it queries the buffer corresponding to the etag from the LRU cache and writes<obj, ts> The key and buffer are written into LRUcache and CS respectively, and the cache corresponding to the key etag is deleted from LRU cache.
[0072] In an exemplary embodiment, as shown in FIG. 4 , the asynchronous interface includes a read interface; a controller 10 is used to call the read interface and pass in a second object identifier, a current timestamp, and a waiting time; a cache layer 30 is used to query corresponding object data according to the second object identifier and the current timestamp during the waiting time, and return the queried object data to the controller 10; the controller 10 is also used to transmit the object data returned by the cache layer 30 to the client.
[0073] When the controller 10 needs to return data to the client, it calls the read interface of the cache layer 30 and passes in the parameters <object ID, timestamp, waiting time>. The read interface returns the result within the waiting time. If the cache hits, the cache layer 30 returns the object data, otherwise it returns invalid information (for example, NULL).
[0074] In this embodiment, a data reading method is provided to preferentially read object data from the cache layer 30, thereby improving data reading efficiency and availability of the data storage system.
[0075] In an exemplary embodiment, as shown in FIG. 4 , the cache layer 30 is provided with a cache unit, and the asynchronous interface also includes a pre-read interface; the controller 10 is used to query the metadata of the object to be read from the distributed database 201 to obtain the current timestamp of the object to be read; the controller 10 is also used to call the pre-read interface to pass in the second object identifier and the current timestamp; the cache layer 30 is used to retrieve whether there is specified object data from the cache unit according to the second object identifier and the current timestamp; if not, the specified object data corresponding to the second object identifier and the current timestamp is read from the cache system 40, and the specified object data is cached in the cache unit.
[0076] The controller 10 first queries the metadata of the object to be read from the distributed database 201 to obtain the current timestamp of the object to be read. Then, the pre-reading interface of the cache layer 30 is called, and the parameter <object identifier, timestamp> is passed in. The pre-reading interface performs the following operations: using <object identifier, timestamp> as a key, it searches whether the corresponding object data exists in the cache unit. If not, it reads the object data corresponding to <object identifier, timestamp> from the cache system 40, and caches the specified object data read from the cache unit in the cache unit.
[0077] In this embodiment, a pre-reading method of the cache layer 30 is provided, which can pre-store the data of the cache layer 30 and the cache system 40 in the cache unit, so as to facilitate subsequent fast reading and improve data reading efficiency.
[0078] In an exemplary embodiment, as shown in FIG. 4 , the asynchronous interface further includes a post-read cache interface; the cache layer 30 is used to send invalid information to the controller 10 if the corresponding object data is not found according to the second object identifier and the current timestamp during the waiting time; the controller 10 is also used to, upon receiving the invalid information, read the object data corresponding to the second object identifier and the current timestamp from the distributed storage engine 202, and call the post-read cache interface to pass in the second object identifier, the current timestamp and the read object data; the cache layer 30 is also used to store the object data passed in by the post-read cache interface into the cache unit and the cache system 40 according to the second object identifier and the current timestamp.
[0079] Among them, when the cache layer 30 misses the data, the controller 10 reads the data from the distributed storage engine 202, and calls the post-read cache interface of the cache layer 30, passing in the parameters <object ID, timestamp, object data>, and the cache layer 30 executes asynchronously: using <object ID, timestamp> as the key, the object data is stored in the cache unit and the cache system 40 respectively to complete the data cache.
[0080] In this embodiment, a post-read cache method is provided to cache the data read from the distributed storage engine 202 into the cache layer 30 and the cache system 40 to facilitate subsequent rapid reading of the object data.
[0081] Exemplarily, the distributed storage system 20 is referred to as LDSS, the distributed database 201 is referred to as DDB, the distributed storage engine 202 is referred to as DSS, the cache layer 30 is referred to as CL, the cache system 40 is referred to as CS, and the cache unit adopts a memory LRU cache. Referring to FIG4 , the cache process of reading an object is described with an object obj:
[0082] 1) The controller 10 queries the DDB using the object obj as a key to obtain the complete metadata corresponding to obj, including the timestamp ts of obj.
[0083] 2) The controller 10 calls the pre-reading interface readPrepare(obj, ts) of CL, which is executed asynchronously:<obj,ts> Search the LRU cache for the key. If it misses, replace it with<obj, ts> Retrieve the corresponding data buffer for the key CS. If a hit is found, the key is<obj, ts> The value is stored in the LRU cache as buffer.
[0084] 3) The controller 10 calls the read interface read(obj, ts, timeout) of CL, which needs to return the result within the timeout range. If the result exists in the LRU cache, the corresponding buffer is returned. If not, the controller 10 waits for the longest timeout until the result exists in the LRU cache.<obj, ts> The corresponding buffer or timeout. The return value is buffer or NULL.
[0085] 4) If the read interface return value of CL is NULL, read from DSS<obj, ts> The corresponding data buffer, and then the controller 10 calls the CL read-post cache interface readPost (obj, ts, buffer), which is executed asynchronously:<obj, ts> As the key, buffer is used as the value and written into LRU cache and CS respectively.
[0086] In an exemplary embodiment, as shown in Figure 5, the cache layer 30 is provided with a cache unit, and the asynchronous interface includes a deletion interface; the controller 10 is used to query the metadata of the object to be deleted from the distributed database 201, obtain the timestamp of the object to be read, and call the deletion interface to pass in the third object identifier and the timestamp of the object to be read; the cache layer 30 is used to delete the cache data in the cache unit and the cache system 40 according to the third object identifier and the timestamp of the object to be read.
[0087] Among them, the controller 10 first queries the metadata corresponding to the object to be deleted from the distributed database 201, obtains the timestamp corresponding to the object to be deleted, and then calls the deletion interface of the cache layer 30, passing in the parameters <object ID, timestamp>. The deletion interface asynchronously completes the deletion operation of the cache object, and deletes the cache data corresponding to <object ID, timestamp> in the cache unit and the cache system 40 respectively.
[0088] In this embodiment, a cache deletion method is provided to release storage space, improve the availability of the cache layer 30 and the cache system 40, and improve the overall performance of the data storage system.
[0089] Exemplarily, the distributed storage system 20 is referred to as LDSS, the distributed database 201 is referred to as DDB, the distributed storage engine 202 is referred to as DSS, the cache layer 30 is referred to as CL, the cache system 40 is referred to as CS, and the cache unit adopts a memory LRU cache. Referring to FIG4, the cache process of deleting an object is described with an object obj:
[0090] 1) The controller 10 queries the DDB using the object obj as a key to obtain the complete metadata corresponding to obj, including the timestamp ts of obj.
[0091] 2) Controller 10 calls CL's delete interface delete(obj, ts), asynchronously executing: deleting from LRU cache and CS respectively<obj, ts> The cache corresponding to the key.
[0092] Based on the same inventive concept, the embodiment of the present application also provides a strongly consistent cache method applied to the above data storage system. The implementation solution provided by the method to solve the problem is similar to the implementation solution recorded in the above system, so the specific limitations in one or more strongly consistent cache method embodiments provided below can refer to the limitations on the data storage system above, and will not be repeated here.
[0093] In an exemplary embodiment, referring to FIG. 6 , the strong consistent cache method provided by the present application includes the following steps:
[0094] Step 602: Under the control of the controller, the distributed storage system persistently stores the object data, or performs a read operation or a delete operation on the persistently stored object data.
[0095] Step 604: The cache layer provides various asynchronous interfaces.
[0096] Step 606, the controller controls the cache layer to read data, cache data or eliminate data from the cache system by calling an asynchronous interface; wherein the same version of the same object data in the data stored in the distributed storage system, the cache layer and the cache system is marked with the same timestamp.
[0097] The description of steps 602 to 606 can be found in the explanation of the aforementioned distributed storage system, which will not be repeated here.
[0098] In the above-mentioned strong consistency cache method, the distributed storage system, cache layer and cache system are combined to meet the requirements of high throughput and low latency at the same time. Based on the unique and unchanging timestamp at the object level, the same version of the same object data in the distributed storage system, cache layer and cache system is marked to ensure the strong consistency of the data and solve the problem of data inconsistency in the data storage system. The cache layer is used to provide various asynchronous interfaces for completing the reading, caching or elimination of object data in the cache system. The cache system is used as a bypass system. When the cache system fails and is unavailable, the cache layer achieves good fault isolation, so that the failure of the cache system will not affect the overall storage service, thereby improving the availability of the data storage system.
[0099] In an exemplary embodiment, the cache layer is provided with a cache unit, and the asynchronous interface includes a pre-write interface; the specific implementation process of the write operation includes the following steps: the controller calls the pre-write interface, reads the target object data from the client, and caches the target object data in the cache unit; the cache unit marks the target object data with an entity tag; the controller stores the target object data persistently in a distributed storage engine, and records the metadata of the target object data in a distributed database; the distributed database generates a unique target timestamp at the object level, marks the target object data based on the target timestamp, and synchronizes the target timestamp to the cache layer and the cache system.
[0100] In an exemplary embodiment, the asynchronous interface also includes a write-post cache interface; synchronizing the target timestamp to the cache layer and the cache system specifically includes: the controller calls the write-post cache interface, passing in the first object identifier, entity tag and target timestamp; the cache layer stores the data marked by the entity tag into the cache unit and the cache system according to the first object identifier and the target timestamp, and deletes the cache data corresponding to the entity tag from the cache unit.
[0101] In an exemplary embodiment, before the controller calls the write-post cache interface and passes in the first object identifier, entity tag and target timestamp, the method also includes: the controller determines whether it is necessary to cache the data marked by the entity tag based on the cache policy; if so, calling the write-post cache interface and passing in the first object identifier, entity tag and target timestamp.
[0102] In an exemplary embodiment, the asynchronous interface includes a read interface; the specific implementation process of reading data from the cache system includes the following steps: the controller calls the read interface, passes in the second object identifier, the current timestamp and the waiting time; during the waiting time, the cache layer queries the corresponding object data according to the second object identifier and the current timestamp, and returns the queried object data to the controller; the controller transmits the object data returned by the cache layer to the client.
[0103] In an exemplary embodiment, the cache layer is provided with a cache unit, and the asynchronous interface also includes a pre-read interface; the method also includes: the controller queries the metadata of the object to be read from the distributed database to obtain the current timestamp of the object to be read; the controller calls the pre-read interface and passes in the second object identifier and the current timestamp; the cache layer retrieves whether the specified object data exists from the cache unit based on the second object identifier and the current timestamp; if not, the specified object data corresponding to the second object identifier and the current timestamp is read from the cache system, and the specified object data is cached in the cache unit.
[0104] In an exemplary embodiment, the asynchronous interface also includes a post-read cache interface; the specific implementation process of the read operation includes the following steps: if the cache layer fails to find the corresponding object data according to the second object identifier and the current timestamp within the waiting time, the cache layer sends invalid information to the controller; when the controller receives the invalid information, it reads the object data corresponding to the second object identifier and the current timestamp from the distributed storage engine, and calls the post-read cache interface to pass in the second object identifier, the current timestamp and the read object data; the cache layer stores the object data passed in by the post-read cache interface into the cache unit and the cache system according to the second object identifier and the current timestamp.
[0105] In an exemplary embodiment, the specific implementation process of eliminating data from a cache system includes the following steps: the controller queries the metadata of the object to be deleted from the distributed database, obtains the timestamp of the object to be read, and calls the deletion interface, passing in the third object identifier and the timestamp of the object to be read; the cache layer deletes the cached data in the cache unit and the cache system according to the third object identifier and the timestamp of the object to be read.
[0106] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0107] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0108] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0109] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data storage system, characterized in that: The data storage system includes a controller, a distributed storage system, a cache layer and a cache system; wherein: The distributed storage system is used to persistently store object data, or perform a read operation or a delete operation on the persistently stored object data under the control of the controller; The cache layer is used to provide various asynchronous interfaces; the controller controls the cache layer to read data, cache data or eliminate data from the cache system by calling the asynchronous interface; Among the data stored in the distributed storage system, the cache layer and the cache system, the same version of the same object data is marked with the same timestamp.
2. The system according to claim 1, characterized in that The distributed storage system includes a distributed database and a distributed storage engine; the distributed storage engine is used to store object data; the distributed database is used to store metadata of each object data, and the metadata includes a timestamp.
3. The system according to claim 2, characterized in that The cache layer is provided with a cache unit, and the asynchronous interface includes a pre-write interface; The controller is used to call the pre-written interface, read the target object data from the client, and cache the target object data in the cache unit; The cache unit marks the target object data by an entity tag; The controller is further configured to persistently store the target object data in the distributed storage engine, and record metadata of the target object data in the distributed database; The distributed database is used to generate a unique target timestamp at the object level, mark the target object data based on the target timestamp, and synchronize the target timestamp to the cache layer and the cache system.
4. The system according to claim 3, characterized in that The asynchronous interface also includes a write-behind cache interface; The controller is further used to call the write-after-cache interface and input the first object identifier, the entity tag and the target timestamp; The cache layer is used to store the data marked by the entity tag into the cache unit and the cache system according to the first object identifier and the target timestamp, and delete the cache data corresponding to the entity tag from the cache unit.
5. The system according to claim 4, characterized in that The controller is used to determine whether the data marked by the entity tag needs to be cached according to the cache strategy; if so, call the write-after-cache interface to pass in the first object identifier, the entity tag and the target timestamp.
6. The system according to claim 2, characterized in that The asynchronous interface includes a read interface; The controller is used to call the read interface and input the second object identifier, the current timestamp and the waiting time; The cache layer is used to query the corresponding object data according to the second object identifier and the current timestamp within the waiting time, and return the queried object data to the controller; The controller is further used to transmit the object data returned by the cache layer to the client.
7. The system according to claim 6, characterized in that The cache layer is provided with a cache unit, and the asynchronous interface further includes a pre-read interface; The controller is used to query metadata of the object to be read from the distributed database to obtain a current timestamp of the object to be read; The controller is further used to call the pre-reading interface and input the second object identifier and the current timestamp; The cache layer is used to retrieve whether the specified object data exists from the cache unit based on the second object identifier and the current timestamp; if not, read the specified object data corresponding to the second object identifier and the current timestamp from the cache system, and cache the specified object data in the cache unit.
8. The system according to claim 7, characterized in that The asynchronous interface also includes a read-after-cache interface; The cache layer is configured to invalidate information to the controller if no corresponding object data is found according to the second object identifier and the current timestamp within the waiting time; The controller is further configured to, upon receiving the invalid information, read object data corresponding to the second object identifier and the current timestamp from the distributed storage engine, and call the read-after-cache interface to pass in the second object identifier, the current timestamp, and the read object data; The cache layer is further used to store the object data transmitted by the read-after-cache interface into the cache unit and the cache system according to the second object identifier and the current timestamp.
9. The system according to claim 2, characterized in that The cache layer is provided with a cache unit, and the asynchronous interface includes a deletion interface; The controller is used to query the metadata of the object to be deleted from the distributed database, obtain the timestamp of the object to be read, and call the deletion interface to input the third object identifier and the timestamp of the object to be read; The cache layer is used to delete cache data in the cache unit and the cache system according to the third object identifier and the timestamp of the object to be read.
10. A strong consistent cache method, characterized in that: The strongly consistent cache method is applied to the data storage system according to any one of claims 1 to 9, wherein the data storage system comprises a controller, a distributed storage system, a cache layer, and a cache system; the method comprises the following steps: The distributed storage system, under the control of the controller, persistently stores the object data, or performs a read operation or a delete operation on the persistently stored object data; The cache layer provides various asynchronous interfaces; The controller controls the cache layer to read data, cache data or eliminate data from the cache system by calling the asynchronous interface; Among the data stored in the distributed storage system, the cache layer and the cache system, the same version of the same object data is marked with the same timestamp.