CN115407945A - Distributed cache system and method - Google Patents

Distributed cache system and method Download PDF

Info

Publication number
CN115407945A
CN115407945A CN202211199642.XA CN202211199642A CN115407945A CN 115407945 A CN115407945 A CN 115407945A CN 202211199642 A CN202211199642 A CN 202211199642A CN 115407945 A CN115407945 A CN 115407945A
Authority
CN
China
Prior art keywords
data
cache
storage node
hash
cache data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211199642.XA
Other languages
Chinese (zh)
Inventor
钱煜
胡方炜
王红宾
陈飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Weride Technology Co Ltd
Original Assignee
Guangzhou Weride Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Weride Technology Co Ltd filed Critical Guangzhou Weride Technology Co Ltd
Priority to CN202211199642.XA priority Critical patent/CN115407945A/en
Publication of CN115407945A publication Critical patent/CN115407945A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0683Plurality of storage devices
    • G06F3/0685Hybrid storage combining heterogeneous device types, e.g. hierarchical storage, hybrid arrays

Abstract

The application discloses a distributed cache system and a method, wherein the system comprises: the management node is used for distributing a hash slot to the storage nodes in the cluster by adopting a consistent hash algorithm and distributing the cache data to the storage nodes corresponding to the hash slot for storage according to the hash value of the cache data; the storage node comprises three layers of cache media used for storing cache data, and the storage node is used for adjusting the cache data in the three layers of cache media according to the access frequency of the cache data; the simulation node is used for positioning the storage node where the simulation data are located based on the Hash mapping rule and reading the corresponding data from the storage node for simulation test, so that the technical problems that the single-machine cache efficiency is gradually reduced, the data access service reading pressure is gradually increased and the simulation test efficiency is influenced due to the fact that the single-machine cache simulation data are adopted in the prior art are solved.

Description

Distributed cache system and method
Technical Field
The present application relates to the field of data storage technologies, and in particular, to a distributed cache system and method.
Background
With the progress of the development process of automatic driving, the number of simulation tasks is continuously increased, and the scale of data required by the simulation tasks and hot spot data is gradually increased. In order to save limited network resources and reduce data access service reading pressure, hot spot data used by simulation tasks are generally cached. Since the data requirements of the simulation task are featureless, the caching of the simulation task is on a single-machine level. Because the storage space of a single machine is limited, and the data required by the simulation task is continuously increased, the single machine caching efficiency is gradually reduced, the data access service reading pressure is gradually increased along with the increase of the concurrent number of the simulation task, and the database paralysis is caused in severe cases, so that the simulation test efficiency is influenced.
Disclosure of Invention
The application provides a distributed cache system and a distributed cache method, which are used for solving the technical problems that the simulation test efficiency is influenced because the single-machine cache efficiency is gradually reduced and the data access service reading pressure is gradually increased when single-machine cache simulation data is adopted in the prior art.
In view of the above, a first aspect of the present application provides a distributed cache system, including:
the management node is used for distributing a hash slot to the storage nodes in the cluster by adopting a consistent hash algorithm and distributing the cache data to the storage nodes corresponding to the hash slot for storage according to the hash value of the cache data;
the storage node comprises a three-layer cache medium for storing cache data, and the storage node is used for adjusting the cache data in the three-layer cache medium according to the access frequency of the cache data;
and the simulation node is used for positioning the storage node where the simulation data is located based on the Hash mapping rule, and reading the corresponding data from the storage node for simulation test.
Optionally, the storage node is further configured to record the number of times of access to the hash slot, and send the number of times of access to the hash slot to the management node;
and the management node is further used for adjusting the size of the hash slot of the storage node according to the access times of the hash slot and the size of the cache resource of the storage node.
Optionally, the three layers of cache media include a memory, a solid state disk and a mechanical hard disk;
the access frequency of the cache data stored in the memory is higher than that of the cache data stored in the solid state disk, and the access frequency of the cache data stored in the solid state disk is higher than that of the cache data stored in the mechanical hard disk;
the cache data stored in the memory comprises fixed data and non-fixed data, the non-fixed data comprises first non-fixed data and second non-fixed data, and the non-fixed data is eliminated according to the access condition.
Optionally, the storage node is specifically configured to:
setting a data queue, adding the cache data with the highest use frequency in the mechanical hard disk into the head of the data queue, and adding the cache data with the lowest use frequency in the mechanical hard disk into the tail of the data queue;
when the redundant storage space is stored in the memory, the cache data accessed recently in the solid state disk is raised to the memory to be stored as fixed data, or the cache data at the head of the data queue is raised from the mechanical hard disk to the memory to be stored as the first non-fixed data;
and/or when the access frequency of the cache data in the mechanical hard disk is increased and is greater than or equal to the access frequency of the original cache data at the head of the data queue, adding the cache data to the head of the data queue, and exchanging the cache data stored in the mechanical hard disk with the original cache data at the head of the data queue stored in the memory;
and/or exchanging the latest accessed cache data in the solid state disk with the fixed data which is not accessed in the memory for the longest time;
and/or when the cache data in the solid state disk or the mechanical hard disk is read, the cache data in the solid state disk or the mechanical hard disk is moved to the memory to be stored as the second non-fixed data.
Optionally, the storage node is further configured to eliminate data that is not accessed for the longest time in the second non-fixed data when the size of the second non-fixed data stored in the memory exceeds a preset threshold.
Optionally, the simulation node is further configured to subscribe to a change of a hash mapping rule of the management node by using an observer pattern.
A second aspect of the present application provides a distributed caching method, which is applied to any one of the distributed caching systems in the first aspect, and the method includes:
distributing a hash slot to a storage node in a cluster by a management node by adopting a consistent hash algorithm, and distributing cache data to the storage node corresponding to the hash slot for storage according to the hash value of the cache data, wherein the storage node comprises a three-layer cache medium for storing the cache data;
adjusting the cache data in the three layers of cache media according to the access frequency of the cache data through the storage node;
and positioning a storage node where the simulation data is located through the simulation node based on the Hash mapping rule, and reading corresponding data from the storage node to perform simulation test.
Optionally, the method further includes:
and recording the access times of the hash slot through the storage node, and sending the access times of the hash slot to the management node, so that the management node adjusts the size of the hash slot of the storage node according to the access times of the hash slot and the size of the cache resource of the storage node.
Optionally, the three layers of cache media include a memory, a solid state disk and a mechanical hard disk;
the access frequency of the cache data stored in the memory is higher than that of the cache data stored in the solid state disk, and the access frequency of the cache data stored in the solid state disk is higher than that of the cache data stored in the mechanical hard disk;
the cache data stored in the memory comprise fixed data and non-fixed data, the non-fixed data comprise first non-fixed data and second non-fixed data, and the non-fixed data are eliminated according to the access condition.
Optionally, the method further includes:
and subscribing the change of the Hash mapping rule of the management node by the simulation node in an observer mode.
According to the technical scheme, the method has the following advantages:
the application provides a distributed cache system, including: the management node is used for distributing a hash slot to the storage nodes in the cluster by adopting a consistent hash algorithm and distributing the cache data to the storage nodes corresponding to the hash slot for storage according to the hash value of the cache data; the storage node comprises a three-layer cache medium for storing cache data, and is used for adjusting the cache data in the three-layer cache medium according to the access frequency of the cache data; and the simulation node is used for positioning the storage node where the simulation data is located based on the Hash mapping rule, and reading the corresponding data from the storage node for simulation test.
In the application, the management node caches the cache data in a fragmentation mode to the storage nodes in the cluster by adopting a consistent Hash algorithm, the storage nodes cache the data by adopting three layers of cache media, the cache data in the three layers of cache media are adjusted according to the access frequency of the cache data, the data are timely eliminated and replaced by dynamically managing the position of the data, the problem that the single-machine cache space is limited can be effectively solved, the access pressure of data access service is reduced, the problem that a database is paralyzed due to a large amount of accesses is avoided, the technical problem that the single-machine cache efficiency is gradually reduced, the data access service reading pressure is gradually increased, and the simulation test efficiency is influenced is solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic structural diagram of a distributed cache system according to an embodiment of the present application;
fig. 2 is a schematic diagram of an adjustment strategy of cache data between three layers of cache media according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a distributed caching method according to an embodiment of the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
To facilitate understanding, referring to fig. 1, an embodiment of the present application provides a distributed cache system, including:
the management node is used for distributing a hash slot to the storage nodes in the cluster by adopting a consistent hash algorithm and distributing the cache data to the storage nodes corresponding to the hash slot for storage according to the hash value of the cache data;
the storage node comprises a three-layer cache medium for storing cache data, and is used for adjusting the cache data in the three-layer cache medium according to the access frequency of the cache data;
and the simulation node is used for positioning the storage node where the simulation data is located based on the Hash mapping rule, and reading the corresponding data from the storage node for simulation test.
According to the embodiment of the application, the problem that the single machine cache space is limited is considered, and the cache data is subjected to data fragmentation through a consistent hash algorithm. Specifically, the management node organizes the whole hash space into a virtual ring, and then allocates hash slots according to the storage node resources, and if the hash value of the cache data falls into any hash slot, the cache data is stored in the storage node corresponding to the hash slot. For example, assume that the entire hash space is 0-2 32 1, performing hash calculation by using the IP or host name of the storage node as a key to obtain the hash value of the storage node, assuming that there are 3 storage nodes in the cluster, wherein the hash value of the storage node 1 is 2 10 The hash value of storage node 2 is 2 18 The hash value of storage node 3 is 2 32 -1, then the hash slot corresponding to storage node 1 is [0,2 ] 10 ]The hash slot corresponding to the storage node 2 is (2) 10 ,2 18 ]The hash slot corresponding to the storage node 3 is (2) 18 ,2 32 -1]If the hash value of a certain cached data is 8, it falls into the hash slot [0,2 ] 10 ]Then, the cache data is stored in the storage node 1.
According to the embodiment of the application, the cache is designed on the cluster level, so that the problems that the consumed time of a simulation task is prolonged and the consumed resource bandwidth is increased due to insufficient single machine cache can be effectively solved, and the data downloading time and the downloading bandwidth pressure can be saved; with the increasing concurrency of simulation tasks, the access pressure of data access service can be greatly reduced by designing the cache at the cluster level, and the database paralysis problem caused by a large amount of accesses can be avoided.
The storage node is further used for recording the access times of the hash slot and sending the access times of the hash slot to the management node;
and the management node is also used for adjusting the size of the hash slot of the storage node according to the access times of the hash slot and the size of the cache resource of the storage node.
Considering that the access pressure of a single storage node is too high when data is accessed, the management node needs to monitor each storage node in real time according to the conditionThe cache resources of the storage nodes dynamically adjust the size of the hash slot, so that the load is balanced. In the embodiment of the application, the storage node directly records the access times of the hash slot of the storage node and sends the access times to the management node at preset intervals in consideration of the fact that the access times of hash spaces with the same size are different and cannot be predicted; the management node determines whether the storage node has the condition of excessive access pressure according to the access times of the hash grooves; for a storage node with excessive access pressure, the management node may reduce the size of the hash slot of the storage node according to the size of the cache resource of the storage node, allocate the reduced hash space to a free storage node, and then transfer the access of the hash space to the free storage node. Using the above example, assuming that the access pressure of storage node 1 is too large and storage node 2 is relatively idle, to relieve the access pressure of storage node 1, the management node will store [0,2 ] of the hash slot of storage node 1 10 ]Partial hash space 0-2 5 Is allocated to the storage node 2, and the subsequent hash space is 0-2 5 Is transferred to storage node 2, when the hash slot corresponding to storage node 2 includes [0,2 ] 5 ]And (2) 10 ,2 18 ]At this time, the mapping relationship between the storage nodes 1 and 2 and the hash slot is changed. When the storage node has a plurality of hash grooves, the storage node records the access times of each hash groove and sends the access times to the management node to dynamically adjust the hash grooves. After the management node adjusts the size of the hash slot of the storage node, the mapping relationship between part of the storage node and the hash slot changes, and the management node records the mapping relationship between the storage node and the hash slot after the size of the hash slot is adjusted.
Further, the three layers of cache media comprise a memory, a solid state disk and a mechanical hard disk;
the access frequency of the cache data stored in the memory is higher than that of the cache data stored in the solid state disk, and the access frequency of the cache data stored in the solid state disk is higher than that of the cache data stored in the mechanical hard disk;
the cache data stored in the memory comprises fixed data and non-fixed data, the non-fixed data comprises first non-fixed data and second non-fixed data, and the non-fixed data is eliminated according to the access condition.
The cache media of the storage node in the embodiment of the application are designed into three layers, including a faster memory, a second-fastest solid state disk and a slower mechanical hard disk. The cache data is stored in cache media of different layers according to the access frequency, the data of the hottest point is stored in the memory, and the cache data in the cache media of different layers can be adjusted in a cross-layer mode along with the access frequency.
The cache data of the single machine is divided into two parts, one part is fixed data and can be stored in the memory and the solid state disk, whether the fixed data is stored in the memory or the solid state disk can be determined according to the least recently used sequence, the fixed data which is accessed recently can be stored in the memory, and the fixed data which is not accessed recently can be stored in the solid state disk; the other part is non-fixed data which is replaced along with the access conditions (such as access times and access frequency). 50% of the cache data in the memory is hot data (i.e. data accessed most) of the default bags, and the part of the data resides in the memory, i.e. fixed data; 40% of cache data in the memory are hot spot data of the data queue, namely first non-fixed data, and the partial data are eliminated and replaced by adopting the sequence of least recent use and least frequent use; the remaining 10% of the buffered data is data moved to the memory during reading, i.e. second non-fixed data, and the data is eliminated in the order of least recent use.
The solid state disk is used for storing other data of default bags and artificially defined common data, and the artificially defined common data can be increased, so that the data is stored in the solid state disk which can be expanded. The mechanical hard disk is used for storing buffer data which are relatively unhealthy in the data queue.
Further, the storage node is specifically configured to:
setting a data queue, adding the cache data with the highest use frequency in the mechanical hard disk into the head of the data queue, and adding the cache data with the lowest use frequency in the mechanical hard disk into the tail of the data queue;
when the memory has redundant storage space, the cache data accessed recently in the solid state disk is raised to the memory to be stored as fixed data, or the cache data at the head of the data queue is raised from the mechanical hard disk to the memory to be stored as first non-fixed data;
and/or when the access frequency of the cache data in the mechanical hard disk is increased and is more than or equal to the access frequency of the original cache data at the head of the data queue, adding the cache data to the head of the data queue, and exchanging the cache data stored in the mechanical hard disk with the original cache data at the head of the data queue stored in the memory;
and/or exchanging the latest accessed cache data in the solid state disk with the fixed data which is not accessed in the memory for the longest time;
and/or when the cache data in the solid state disk or the mechanical hard disk is read, the cache data in the solid state disk or the mechanical hard disk is moved to the memory to be stored as second non-fixed data.
In the embodiment of the present application, the cache data has three adjustment policies in a three-layer cache medium, including exchange, ascending, and moving during reading, which may specifically refer to fig. 2.
Exchanging: when the cache data is frequently accessed to enter the head of the data queue, the data is inevitably accessed from a hot area to a non-hot area, the two data blocks need to be exchanged, so that the cache data in the hot area enters the memory, the cache data in the non-hot area enters the mechanical hard disk, for example, assuming that the cache data in the data queue is a → b → c, the head of the data queue is the cache data a, and the tail is the cache data c, the cache data a is stored in the memory, the remaining cache data b and c of the data queue are both stored in the mechanical hard disk, as the access frequency of the cache data b in the data queue increases, the cache data b enters the head of the data queue, the original cache data a moves one bit downwards towards the tail of the data queue, namely b → a → c, at this moment, the storage node can exchange the cache data b in the mechanical hard disk with the original cache data a in the memory, and after the exchange, the current cache data b in the head of the data queue is stored in the memory, and the head of the data in the mechanical hard disk is stored in the cache data queue. The exchange in memory and solid state for fixed data is similar.
Rising: when the memory has a redundant storage space (for example, the memory is loaded for the first time or the cache is expired), the cache data in the solid state disk or the mechanical hard disk can be raised into the memory.
Moving during reading: when the cached data in the disk needs to be read into the memory when it is used, the read time rises to 10% of the data in the memory.
Further, the storage node is further configured to eliminate data that has not been accessed for the longest time in the second non-fixed data when the size of the second non-fixed data stored in the memory exceeds a preset threshold.
In the embodiment of the application, caching is carried out on the cluster level, even if the caching size is multiple times of that of single machine caching, the caching size shared by each storage node is much smaller than the original number, the effect is better along with the expansion of the cluster, the precious storage space of the single machine can be effectively saved, the solid state expansion can be well supported, and the storage resources can be better utilized; the storage node can replace the data in time by dynamically managing the storage position of the cached data, so that the single-machine caching pressure can be further reduced.
When the simulation node performs the simulation test, the simulation data needs to be read, and the simulation node can locate the storage node where the simulation data is located based on the hash mapping rule and read the corresponding data from the storage node to perform the simulation test. Specifically, the simulation node obtains the hash value of the simulation data based on the hash algorithm in the hash mapping rule, and positions which hash slot the hash value of the simulation data falls in according to the mapping relation between the hash slot and the storage node in the hash mapping rule, so as to determine the storage node where the simulation data is located, and further read the simulation data from the storage node to perform the simulation test. In order to avoid the situation that the simulation node needs to request for inquiring the position of the simulation data of the management node when reading the simulation data each time, the simulation node can subscribe the change of the hash mapping rule of the management node (including the change of the mapping relation between the hash slot and the storage node) by adopting an observer mode, so that the simulation node can directly position and access the storage node where the simulation data is located according to the hash preset rule when reading the data each time. According to the embodiment of the application, the cache data is stored by utilizing the pure reading scene of the simulation task, so that the data acquisition speed can be increased, the simulation task can be ensured to be completed quickly, and the simulation test efficiency is improved.
In the embodiment of the application, the management node caches the cache data in a fragmentation mode to the storage nodes in the cluster by adopting a consistent Hash algorithm, the storage nodes cache the data by adopting three layers of cache media, the cache data in the three layers of cache media are adjusted according to the access frequency of the cache data, the data are timely eliminated and replaced by dynamically managing the position of the data, and the problem of limited single-machine cache space can be effectively solved, so that the access pressure of data access service is reduced, the problem of database paralysis caused by a large number of accesses is avoided, the technical problems that the single-machine cache simulation data is adopted in the prior art, the single-machine cache efficiency is gradually reduced, the data access service reading pressure is gradually increased, and the simulation test efficiency is influenced are solved.
The above is an embodiment of a distributed cache system provided by the present application, and the following is an embodiment of a distributed cache method provided by the present application.
Referring to fig. 3, a distributed caching method provided in an embodiment of the present application is applied to a distributed caching system in the foregoing embodiment, and the method includes:
step 301, distributing a hash slot to a storage node in the cluster by using a consistent hash algorithm through the management node, and distributing the cache data to the storage node corresponding to the hash slot for storage according to the hash value of the cache data, where the storage node includes three layers of cache media for storing the cache data.
According to the embodiment of the application, the problem that the single machine cache space is limited is considered, and the cache data is subjected to data fragmentation through a consistent hash algorithm. Specifically, the management node organizes the entire hash space into a virtual ring, which is then rootedAnd allocating a hash slot according to the storage node resource, and storing the cache data into the storage node corresponding to the hash slot according to which hash slot the hash value of the cache data falls into. For example, assume the entire hash space is 0-2 32 1, performing hash calculation by using the IP or host name of the storage node as a key to obtain the hash value of the storage node, assuming that there are 3 storage nodes in the cluster, wherein the hash value of the storage node 1 is 2 10 The hash value of the storage node 2 is 2 18 The hash value of the storage node 3 is 2 32 -1, the hash slot corresponding to the storage node 1 is [0,2 ] 10 ]The hash slot corresponding to the storage node 2 is (2) 10 ,2 18 ]The hash slot corresponding to the storage node 3 is (2) 18 ,2 32 -1]If the hash value of a certain cache data is 8, the hash value falls into the hash slot [0,2 ] 10 ]Then, the cache data is stored in the storage node 1.
According to the embodiment of the application, the cache is designed on the cluster level, so that the problems that the simulation task consumes longer time and the resource bandwidth consumes larger time due to insufficient single machine cache can be effectively solved, and the data downloading time and the downloading bandwidth pressure can be saved; with the increasing concurrent number of simulation tasks, the access pressure of data access service can be greatly reduced by designing cache at the cluster level, and the problem of database paralysis caused by a large number of accesses can be avoided.
In the embodiment of the application, the three layers of cache media comprise a memory, a solid state disk and a mechanical hard disk;
the access frequency of the cache data stored in the memory is higher than that of the cache data stored in the solid state disk, and the access frequency of the cache data stored in the solid state disk is higher than that of the cache data stored in the mechanical hard disk;
the cache data stored in the memory comprises fixed data and non-fixed data, the non-fixed data comprises first non-fixed data and second non-fixed data, and the non-fixed data is eliminated according to the access condition.
The cache medium of the storage node in the embodiment of the application is designed into three layers, including a faster memory, a second-faster solid state disk and a slower mechanical hard disk. The cache data is stored in cache media of different layers according to the access frequency, the data of the hottest point is stored in the memory, and the cache data in the cache media of different layers can be adjusted in a cross-layer mode along with the access frequency.
The cache data of the single machine is divided into two parts, wherein one part is fixed data and can be stored in the memory and the solid state disk, specifically, whether the fixed data is stored in the memory or the solid state disk can be determined according to the least recently used sequence, the fixed data which is accessed recently can be stored in the memory, and the fixed data which is not accessed recently is stored in the solid state disk; the other part is non-fixed data which is eliminated along with the access conditions (such as access times and access frequency). 50% of the cache data in the memory is the hot spot data (i.e. the data which is accessed most) of the default bags, and the part of the data resides in the memory, i.e. fixed data; 40% of cache data in the memory are hot spot data of the data queue, namely first non-fixed data, and the partial data are eliminated and replaced by adopting the sequence of least recent use and least frequency; the remaining 10% of the buffered data is data moved to the memory during reading, i.e. second non-fixed data, and the data is eliminated in the order of least recent use.
The solid state disk is used for storing other data of default bags and artificially defined common data, and the artificially defined common data can be increased, so that the data is stored in the solid state disk which can be expanded. The mechanical hard disk is used for storing buffer data which are relatively unhealthy in the data queue.
And step 302, adjusting the cache data in the three layers of cache media by the storage node according to the access frequency of the cache data.
The method for adjusting the cache data in the three-layer cache medium through the storage node according to the access frequency of the cache data comprises the following steps:
setting a data queue through a storage node, adding the cache data with the highest use frequency in the mechanical hard disk into the head of the data queue, and adding the cache data with the lowest use frequency in the mechanical hard disk into the tail of the data queue;
when the memory has redundant storage space, the cache data which is accessed recently in the solid state disk is lifted to the memory through the storage node to be stored as fixed data, or the cache data at the head of the data queue is lifted from the mechanical hard disk to the memory to be stored as first non-fixed data;
and/or when the access frequency of the cache data in the mechanical hard disk is increased and is more than or equal to the access frequency of the original cache data at the head of the data queue, adding the cache data to the head of the data queue through the storage node, and exchanging the cache data stored in the mechanical hard disk with the original cache data at the head of the data queue stored in the memory;
and/or exchanging the latest accessed cache data in the solid state disk with the fixed data which is not accessed for the longest time in the memory through the storage node;
and/or when the cache data in the solid state disk or the mechanical hard disk is read, the cache data in the solid state disk or the mechanical hard disk is moved to the memory through the storage node and stored as second non-fixed data.
In the embodiment of the application, the cache data has three adjustment strategies in a three-layer cache medium, including exchange, ascending and moving during reading.
Exchanging: when the cache data is frequently accessed to enter the head of the data queue, the data inevitably goes from the hot area to the non-hot area, the two data blocks need to be exchanged, so that the cache data in the hot area enters the memory, the cache data in the non-hot area enters the mechanical hard disk, for example, assuming that the cache data in the data queue is a → b → c, the head of the data queue is cache data a, and the tail of the data queue is cache data c, the cache data a is stored in the memory, the remaining cache data b and c of the data queue are stored in the mechanical hard disk, and as the access frequency of the cache data b in the data queue increases, the cache data b enters the head of the data queue, the original cache data a moves one bit downwards towards the tail of the data queue, namely b → a → c, at this time, the storage node can exchange the cache data b in the mechanical hard disk with the cache data a in the memory, and after the exchange, the current cache data b at the head of the data queue is stored in the memory, and the head of the data queue is stored in the mechanical hard disk. The exchange in memory and solid state for fixed data is similar.
Rising: when the memory has a redundant storage space (for example, the first load or the cache is expired), the cache data in the solid state disk or the mechanical hard disk can be raised into the memory.
Moving during reading: when the cached data in the disk needs to be read into the memory when it is used, the read time rises to 10% of the data in the memory.
Further, when the size of the second non-fixed data stored in the memory exceeds a preset threshold, the data which is not accessed for the longest time in the second non-fixed data is eliminated through the storage nodes.
In the embodiment of the application, caching is carried out on the cluster level, even if the caching size is multiple times of that of single machine caching, the caching size shared by each storage node is much smaller than the original number, the effect is better along with the expansion of the cluster, the precious storage space of the single machine can be effectively saved, the solid state expansion can be well supported, and the storage resources can be better utilized; the storage node dynamically manages the storage position of the cache data, and replaces the data in time, so that the single-machine cache pressure can be further reduced.
Further, the method in the embodiment of the present application further includes:
and recording the access times of the hash slot through the storage node, and sending the access times of the hash slot to the management node, so that the management node adjusts the size of the hash slot of the storage node according to the access times of the hash slot and the size of the cache resource of the storage node.
Considering that the access pressure of a single storage node is too high when data is accessed, the management node needs to monitor each storage node in real time, and dynamically adjusts the size of the hash slot according to the cache resources of the storage nodes, so that the load is balanced. In the embodiment of the application, considering that the access times of hash spaces with the same size are not the same and cannot be predicted, the access times of hash slots of the storage nodes are directly recorded by the storage nodes, and the access times are sent to the management nodes at intervals of preset time, so that the management nodes determine whether the storage nodes have the condition of overlarge access pressure according to the access times of the hash slots; for the storage node with excessive access pressure, the management node may reduce the size of the hash slot of the storage node according to the size of the cache resource of the storage node, allocate the reduced hash space to a free storage node, and then transfer the access of the hash space to the free storage node. When the storage node has a plurality of hash grooves, the storage node records the access times of each hash groove and sends the access times to the management node to dynamically adjust the hash grooves. After the management node adjusts the size of the hash slot of the storage node, the mapping relationship between part of the storage node and the hash slot changes, and the management node records the mapping relationship between the storage node and the hash slot after the size of the hash slot is adjusted.
And 303, positioning a storage node where the simulation data is located through the simulation node based on a Hash mapping rule, and reading corresponding data from the storage node to perform simulation test.
When the simulation node carries out simulation test, simulation data needs to be read, the storage node where the simulation data is located through the simulation node based on the Hash mapping rule, and corresponding data are read from the storage node for carrying out the simulation test. Specifically, the simulation node obtains the hash value of the simulation data based on the hash algorithm in the hash mapping rule, and positions which hash slot the hash value of the simulation data falls in according to the mapping relation between the hash slot and the storage node in the hash mapping rule, so as to determine the storage node where the simulation data is located, and further read the simulation data from the storage node to perform the simulation test. In order to avoid the situation that the simulation node needs to request to inquire the position of the simulation data of the management node every time the simulation node reads the simulation data, the simulation node can subscribe the change of the hash mapping rule of the management node (including the change of the mapping relation between the hash slot and the storage node) by adopting an observer mode, so that the simulation node can directly position and access the storage node where the simulation data is located according to the hash preset rule every time the simulation node reads the data. According to the embodiment of the application, the cache data is stored by utilizing the pure reading scene of the simulation task, so that the data acquisition speed can be increased, the simulation task can be ensured to be completed quickly, and the simulation test efficiency is improved.
In the embodiment of the application, the management node caches the cache data in a fragmentation mode to the storage nodes in the cluster by adopting a consistent Hash algorithm, the storage nodes cache the data by adopting three layers of cache media, the cache data in the three layers of cache media are adjusted according to the access frequency of the cache data, the data are timely eliminated and replaced by dynamically managing the position of the data, and the problem of limited single-machine cache space can be effectively solved, so that the access pressure of data access service is reduced, the problem of database paralysis caused by a large number of accesses is avoided, the technical problems that the single-machine cache simulation data is adopted in the prior art, the single-machine cache efficiency is gradually reduced, the data access service reading pressure is gradually increased, and the simulation test efficiency is influenced are solved.
The terms "first," "second," "third," "fourth," and the like (if any) in the description of the present application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged under appropriate circumstances such that the embodiments of the application described herein may be implemented, for example, in sequences other than those illustrated or described herein. Moreover, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of the singular or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b and c may be single or plural.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (10)

1. A distributed cache system, comprising:
the management node is used for distributing a hash slot to the storage nodes in the cluster by adopting a consistent hash algorithm and distributing the cache data to the storage nodes corresponding to the hash slot for storage according to the hash value of the cache data;
the storage node comprises a three-layer cache medium for storing cache data, and the storage node is used for adjusting the cache data in the three-layer cache medium according to the access frequency of the cache data;
and the simulation node is used for positioning the storage node where the simulation data is located based on the Hash mapping rule, and reading the corresponding data from the storage node for simulation test.
2. The distributed cache system of claim 1, wherein the storage node is further configured to record the number of access times of the hash slot, and send the number of access times of the hash slot to the management node;
and the management node is further used for adjusting the size of the hash slot of the storage node according to the access times of the hash slot and the size of the cache resource of the storage node.
3. The distributed caching system of claim 1, wherein the three-tier caching media comprise a memory, a solid state disk, and a mechanical hard disk;
the access frequency of the cache data stored in the memory is higher than that of the cache data stored in the solid state disk, and the access frequency of the cache data stored in the solid state disk is higher than that of the cache data stored in the mechanical hard disk;
the cache data stored in the memory comprise fixed data and non-fixed data, the non-fixed data comprise first non-fixed data and second non-fixed data, and the non-fixed data are eliminated according to the access condition.
4. The distributed caching system of claim 3, wherein the storage node is specifically configured to:
setting a data queue, adding the cache data with the highest use frequency in the mechanical hard disk into the head of the data queue, and adding the cache data with the lowest use frequency in the mechanical hard disk into the tail of the data queue;
when the redundant storage space is stored in the memory, the cache data accessed recently in the solid state disk is raised to the memory to be stored as fixed data, or the cache data at the head of the data queue is raised from the mechanical hard disk to the memory to be stored as the first non-fixed data;
and/or when the access frequency of the cache data in the mechanical hard disk is increased and is greater than or equal to the access frequency of the original cache data at the head of the data queue, adding the cache data to the head of the data queue, and exchanging the cache data stored in the mechanical hard disk with the original cache data at the head of the data queue stored in the memory;
and/or exchanging the latest accessed cache data in the solid state disk with the fixed data which is not accessed for the longest time in the memory;
and/or when the cache data in the solid state disk or the mechanical hard disk is read, the cache data in the solid state disk or the mechanical hard disk is moved to the memory to be stored as the second non-fixed data.
5. The distributed cache system according to claim 3 or 4, wherein the storage node is further configured to discard data that has not been accessed for the longest time in the second non-fixed data when the size of the second non-fixed data stored in the memory exceeds a preset threshold.
6. The distributed caching system of claim 1, wherein the emulation node is further configured to subscribe to changes in a hash mapping rule of the management node using an observer pattern.
7. A distributed caching method applied to the distributed caching system of any one of claims 1 to 6, the method comprising:
distributing a hash slot to a storage node in a cluster by a management node through a consistent hash algorithm, and distributing cache data to the storage node of the corresponding hash slot for storage according to a hash value of the cache data, wherein the storage node comprises three layers of cache media for storing the cache data;
adjusting the cache data in the three layers of cache media through the storage node according to the access frequency of the cache data;
and positioning a storage node where the simulation data is located through the simulation node based on the Hash mapping rule, and reading corresponding data from the storage node to perform simulation test.
8. The distributed caching method of claim 7, further comprising:
and recording the access times of the hash slot through the storage node, and sending the access times of the hash slot to the management node, so that the management node adjusts the size of the hash slot of the storage node according to the access times of the hash slot and the size of the cache resource of the storage node.
9. The distributed caching method according to claim 7, wherein the three layers of caching media comprise a memory, a solid state disk and a mechanical hard disk;
the access frequency of the cache data stored in the memory is higher than that of the cache data stored in the solid state disk, and the access frequency of the cache data stored in the solid state disk is higher than that of the cache data stored in the mechanical hard disk;
the cache data stored in the memory comprises fixed data and non-fixed data, the non-fixed data comprises first non-fixed data and second non-fixed data, and the non-fixed data is eliminated according to the access condition.
10. The distributed caching method of claim 7, further comprising:
and subscribing the change of the Hash mapping rule of the management node by the simulation node in an observer mode.
CN202211199642.XA 2022-09-29 2022-09-29 Distributed cache system and method Pending CN115407945A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211199642.XA CN115407945A (en) 2022-09-29 2022-09-29 Distributed cache system and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211199642.XA CN115407945A (en) 2022-09-29 2022-09-29 Distributed cache system and method

Publications (1)

Publication Number Publication Date
CN115407945A true CN115407945A (en) 2022-11-29

Family

ID=84167250

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211199642.XA Pending CN115407945A (en) 2022-09-29 2022-09-29 Distributed cache system and method

Country Status (1)

Country Link
CN (1) CN115407945A (en)

Similar Documents

Publication Publication Date Title
CN107943867B (en) High-performance hierarchical storage system supporting heterogeneous storage
CN110134514B (en) Extensible memory object storage system based on heterogeneous memory
CN110825324B (en) Hybrid storage control method and hybrid storage system
US8914501B2 (en) Method, apparatus, and system for scheduling distributed buffer resources
CN103246616B (en) A kind of globally shared buffer replacing method of access frequency within long and short cycle
EP3089039B1 (en) Cache management method and device
CN107018172B (en) System and method for adaptive partitioning in distributed cache memory
CN105549905A (en) Method for multiple virtual machines to access distributed object storage system
CN107066397A (en) Caching is dissected to replace
EP3425513B1 (en) Cache management method and apparatus for non-volatile storage device
Jiang et al. ULC: A file block placement and replacement protocol to effectively exploit hierarchical locality in multi-level buffer caches
CN105095495B (en) A kind of distributed file system buffer memory management method and system
US11360891B2 (en) Adaptive cache reconfiguration via clustering
CN107341114A (en) A kind of method of directory management, Node Controller and system
CN104202349B (en) The method of scheduling distributed buffer resources, Apparatus and system
CN112947860A (en) Hierarchical storage and scheduling method of distributed data copies
CN116894041B (en) Data storage method, device, computer equipment and medium
CN112995257B (en) Cache expansion method and device based on cloud storage architecture and storage medium
CN105808150A (en) Solid state disk caching system for hybrid storage device
CN115407945A (en) Distributed cache system and method
CN112486857B (en) Multi-layer nonvolatile caching method for wear sensing and load balancing
CN114785662B (en) Storage management method, device, equipment and machine-readable storage medium
WO2023035694A1 (en) Service system, and memory management method and apparatus
CN109582233A (en) A kind of caching method and device of data
CN115509962A (en) Multi-level cache management method, device and equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination