WO2012034475A1 - 存储数据的方法和装置 - Google Patents
存储数据的方法和装置 Download PDFInfo
- Publication number
- WO2012034475A1 WO2012034475A1 PCT/CN2011/078965 CN2011078965W WO2012034475A1 WO 2012034475 A1 WO2012034475 A1 WO 2012034475A1 CN 2011078965 W CN2011078965 W CN 2011078965W WO 2012034475 A1 WO2012034475 A1 WO 2012034475A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data request
- data
- storage
- stored data
- storing
- 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.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0238—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
- G06F12/0246—Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input 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/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0614—Improving the reliability of storage systems
- G06F3/0619—Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input 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/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
- G06F3/0656—Data buffering arrangements
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input 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/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
Definitions
- the present invention relates to the field of storage technologies, and in particular, to a method and apparatus for storing data. Background technique
- UGC User Generate Content
- UGC business is emerging, such as community network, video sharing and blogs, etc., are the main application forms of UGC, but also generate massive amounts of data, and massive random read and write of these data. . How to store these data and provide high-concurrency random read and write services is an inevitable problem in the technical field.
- the existing technical solution uses a layered structure to store data generated by the UGC service, including: a Cache (cache) layer and a data layer.
- the Cache layer uses memory storage to cache data with a high frequency of recent access, and uses a elimination strategy to eliminate low-frequency data from the memory;
- the data layer uses disk storage to store all data.
- a method of storing data comprising:
- the data is stored to the solid state drive SSD disk according to the stored data request.
- the method further includes:
- determining whether the stored data request satisfies a preset storage condition, and rejecting the stored data request when the stored data request does not satisfy the preset storage condition, when the stored data request satisfies When the preset storage condition is described, the operation of storing the data to the SSD disk of the solid state drive according to the stored data request is continued; if not, proceeding to store the data to the SSD disk of the solid state drive according to the storage data request operating.
- the determining whether the stored data request satisfies the preset storage condition specifically includes:
- the maximum number of times the stored data requests processed by the SSD disk in the one cycle is at least 1.
- the storing the data to the solid state hard disk SSD disk specifically includes:
- Determining whether the format of the data is in the TLV format if not, converting the data into data in the TLV format; storing the data in the TLV format to the SSD disk.
- an embodiment of the present invention provides an apparatus for storing data, where the apparatus includes: a storage data request receiving module, configured to receive a storage data request sent by a user;
- the SSD disk storage module is configured to store data to the SSD disk according to the stored data request.
- the device also includes:
- a storage condition determining module configured to determine whether the storage type of the stored data request is random storage; if yes, determining whether the stored data request satisfies a preset storage condition, when the stored data request does not satisfy the pre- Resetting the storage data request, when the storage data request satisfies the preset storage condition, continuing to perform an operation of storing data to the SSD disk according to the storage data request; If not, the operation of storing the data to the SSD disk of the solid state drive according to the stored data request is continued.
- the storage condition determining module specifically includes:
- a storage data request judging unit configured to determine, during the period in which the stored data request is received, the Whether the number of storage requests for storing the data request exceeds the maximum number of times the stored data request is processed in one cycle of the SSD disk, and if not, the stored data request satisfies the storage condition.
- the maximum number of times the stored data requests processed by the SSD disk in the one cycle is at least 1.
- the SSD disk storage module specifically includes:
- a data format conversion unit configured to determine whether the format of the data is a TLV format, and if not, convert the data into data in a TLV format
- a data storage unit configured to store the data in the TLV format to an SSD disk.
- the data storage consistency is ensured, the data redundancy caused by using the Cache layer cache data in the prior art is saved, and the single layer storage by using the SSD disk is saved.
- the data avoids the increase in the amount of access to the external request and the data layer caused by the Cache layer that needs to be reloaded in the prior art, and further reduces the complexity of the system design and the operation and maintenance cost.
- Embodiment 1 is a flowchart of a method for storing data provided in Embodiment 1 of the present invention
- Embodiment 2 is a flowchart of another method for storing data provided in Embodiment 2 of the present invention.
- FIG. 3 is a flow chart of a specific step of S204 in Embodiment 2 of the present invention.
- FIG. 4 is a schematic structural diagram of an apparatus for storing data according to Embodiment 3 of the present invention. detailed description
- this embodiment discloses a method for storing data, including the following steps:
- S101 Receive a storage data request sent by a user
- S102 Store the data to an SSD (Solid State Disk) disk according to the storage data request.
- the method provided in this embodiment ensures data by storing data to an SSD disk according to the storage data request.
- the consistency of the storage saves the data redundancy caused by the Cache layer cache data in the prior art, and the storage data of the single layer of the SSD disk is used to avoid the Cache layer needs to be reloaded once the machine is powered down in the prior art.
- the impact of data on external requests and the increase in access to the data layer further reduces system design complexity and operational maintenance costs.
- this embodiment discloses a method for storing data, which includes the following steps:
- S201 The user sends a storage data request.
- the stored data request sent by the user is used to request storage of the data generated by the user.
- the data requested by the user may be newly generated data of the user, or may be modified data that the user modifies the data that has been uploaded to the network.
- a user For example, a user generates data through a UGC service, such as a community network, a video sharing, and a blog. If the user needs to store the data, the user sends a request to store the data. Alternatively, the user needs to modify the data that has been generated. When the modified data is stored, the user sends a storage data request and requests to store the modified data.
- a UGC service such as a community network, a video sharing, and a blog.
- the stored data request may further include data information such as attributes, formats, and sizes of the data, and the stored data request may be defined according to the storage requirement.
- S202 Receive a storage data request sent by a user.
- storage types include random storage and sequential storage.
- the SSD disk sequentially stores the data, and the type of the stored data request is sequential storage; when the user requests the stored data to be the modified data of the user, the SSD disk needs to be searched. Unmodified data corresponding to the modified data, and replacing the unmodified data with the modified data. Since the unmodified data may be distributed anywhere on the SSD disk, the modified data storage location is also It may be anywhere on the SSD disk, so the type of storage request is random compared to the SSD disk.
- S204 Determine whether the stored data request satisfies the preset storage condition. If yes, execute S205. If not, the stored data request does not satisfy the storage condition, and reject the stored data request.
- the preset storage conditions are used to avoid random storage performance bottlenecks that may exist on the SSD disk.
- the requested frequency of the stored data request that requires the SSD disk to be randomly stored exceeds the range that can be tolerated, there may be a performance bottleneck of the random storage.
- the stability of the service can be ensured.
- the random storage operation of the SSD disk is restricted, and the preset storage conditions are set to protect the stability of the system.
- the storage condition is met. If the condition is met, the normal storage service is executed; if the storage condition is not met, the operation is directly rejected, which can The role of peak elimination.
- the storage conditions of different SSD disks can be set to prevent the performance bottleneck of the SSD disk, thereby ensuring the stability of the service.
- the specific storage conditions are not limited in this embodiment.
- the preset storage condition may be a maximum number of times that the SSD disk can process the stored data request in one cycle; that is, in one cycle, when the stored data request exceeds the maximum number of times, the stored data request does not satisfy the storage.
- Condition rejecting the stored data request; when the stored data request does not exceed the maximum number of times, the stored data request satisfies the storage condition and accepts the stored data request.
- the maximum number of times that an SSD disk can process a stored data request in this one cycle is at least one.
- the maximum number of times the data request is stored is used to balance the storage efficiency and storage stability of the SSD disk.
- the stability of the SSD disk is higher, but the random storage efficiency is lower.
- the random storage efficiency of the SSD disk is higher, but The stability is lower.
- the specific calculation method for the maximum number of stored data requests that can be processed by an SSD disk in a cycle can be obtained by multiple value test, or calculated by the relevant formula of the prior art, thereby achieving the premise of ensuring the stability of the SSD disk.
- the method further improves the random storage efficiency of the SSD.
- the specific method is not limited in this embodiment.
- determining whether the storage data request satisfies the storage condition is specifically:
- the maximum number of times is one, it is determined whether the number of storage requests including the stored data request received during the period in which the data request is stored exceeds the maximum number of times that the SSD disk can process the stored data request within one cycle. Whether the stored data request is the first stored data request received during the period in which it is located, and if so, the stored data request satisfies the storage condition, and S205 is performed; if not, the stored data request does not satisfy the storage condition;
- the maximum number of times is 20 times, it is determined whether the number of storage requests including the storage data request received in the period in which the data request is stored exceeds the maximum number of times that the storage data request can be processed in one cycle of the SSD disk is: Whether the data request is any stored data request between the first time and the twentieth time received in the period in which it is located, and if so, the stored data request satisfies the storage condition, and S204 is performed; if not, the data is requested Seek not to satisfy the storage conditions.
- S204 may be specifically implemented by the following steps, but this embodiment does not Limited:
- the stored sequence number of the received stored data request is recorded by a counter program.
- the initial value of the counter in the counter program is set to zero. Whenever a stored data request is received, the counter is incremented by one until S2046 re-assigns the counter, so that the counter records the true number of stored data requests received in the current cycle. value.
- the storage sequence number of the stored data request recorded by the counter program is obtained.
- S2044 Obtain a receiving time of the stored data request.
- the last recorded storage data request is the first storage data request in the period in which the storage data request is located.
- S2046 determining whether the time interval between the receiving time of the stored data request and the receiving time of the last recorded stored data request is greater than one cycle, and if yes, the stored data request satisfies the storage condition, executing S205, and setting the value of the counter Set to 1, initialize the counter program; modify the receiving time of the last recorded stored data request to the receiving time of the stored data request;
- S2043 to S2046 are expressed in code form as:
- gdwRanWriteNum++ ⁇ record the storage sequence number of the stored data request; if (gdwRanWriteNum dwMaxAl lowRanWrites) ⁇ determine whether the storage sequence number of the stored data request is less than or equal to the maximum value;
- ⁇ causes the counter to record the true value of the number of stored data requests received in the current cycle
- gdwRanWriteNum is a storage sequence number for storing data requests
- dwMaxAl lowRanWrites is the maximum number of times the SSD disk can process the number of stored data requests in a cycle; dwCurTime is the receiving time of the stored data request;
- gdwLastTime is the receiving time of the last recorded storage data request
- Return 0 indicates that the stored data request satisfies the preset storage condition
- Return 1 indicates that the stored data request does not satisfy the preset storage condition.
- S205 determining whether the format of the data is a TLV format, if yes, executing S207, if not, executing S206; specifically, determining whether the format of the data included in the stored data request is a TLV format, and if not, the data is Convert to data in TLV format;
- the optional information can be encoded into a type-length-value format, or TLV.
- the type and length fields are fixed lengths, typically 1_4 bytes, and the value field is variable length.
- the three parts are used as follows:
- Type uses a numeric code to indicate the type of the entire data block
- Value data area a variable-length set of bytes.
- S207 Store data in TLV format to an SSD disk.
- the data in the TLV format is stored according to the stored data request.
- those skilled in the art can easily store data according to the stored data request, and the specific method is not described again.
- the method provided in this embodiment ensures data consistency of the data storage by storing the data to the SSD disk according to the storage data request, saves data redundancy caused by using the Cache layer cache data in the prior art, and adopts the SSD.
- the storage of data in a single layer of the disk avoids the increase in the amount of access to the external request and the data layer caused by the Cache layer needing to reload the data in the prior art, and further reduces the complexity of the system design and Operation and maintenance costs.
- this embodiment discloses an apparatus for storing data, including the following steps:
- a storage data request receiving module S301 configured to receive a storage data request sent by a user
- the SSD disk storage module S302 is configured to store data to the SSD disk according to the storage data request.
- the storage condition determining module S303 is configured to determine whether the storage type of the storage data request is random storage; if yes, determine whether the storage data request satisfies a preset storage condition, and reject the storage data request when the storage data request does not satisfy the preset storage condition Storing a data request, when the storage data request satisfies the preset storage condition, continuing to perform the operation of storing the data to the SSD disk according to the storage data request; if not, continuing to perform the storage of the data to the solid state according to the storage data request Operation of the hard disk SSD disk;
- the storage condition determining module S303 specifically includes:
- the storage data request judging unit S3031 is configured to determine, when the preset storage condition is the maximum value of the number of stored data requests that can be processed by the SSD disk in one cycle, to determine the storage request including the storage data request received during the period in which the data request is stored. Whether the number of times exceeds the maximum value, and if not, the stored data request satisfies the storage condition;
- the maximum number of stored data requests that an SSD disk can handle in a cycle is at least 1;
- the SSD disk storage module S302 specifically includes:
- the data format conversion unit S3021 is configured to determine whether the format of the data is a TLV format, and if not, convert the data into data in a TLV format;
- the data storage unit S3022 is configured to store data in a TLV format to an SSD disk.
- the device provided by the embodiment saves the data storage consistency by storing the data to the SSD disk according to the storage data request, saves data redundancy caused by using the Cache layer cache data in the prior art, and adopts the SSD.
- the storage of data in a single layer of the disk avoids the increase in the amount of access to the external request and the data layer caused by the Cache layer needing to reload the data in the prior art, and further reduces the complexity of the system design and Operation and maintenance costs.
- the data storage device provided by the foregoing embodiment stores data, only the division of each functional module is described. In actual applications, the function distribution may be completed by different functional modules as needed.
- the internal structure of the device is divided into different functional modules to perform all or part of the functions described above.
- the device for storing data provided by the foregoing embodiment is the same as the method for storing data, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
- All or part of the technical solutions provided by the above embodiments may be implemented by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a readable storage medium, such as a computer. Hard disk, compact disc or floppy disk.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Computer Security & Cryptography (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Description
存储数据的方法和装置 技术领域
本发明涉及存储技术领域, 特别涉及一种存储数据的方法和装置。 背景技术
UGC (Users Generate Content , 用户生成内容) 是一种用户使用互联网的新方式, 用 户将自己原创生成的内容上传至互联网, 通过互联网平台进行展示或者提供给其他用户, 同时用户也可对其生成的内容进行编辑修改。 由此可见, 用户对互联网的使用, 由原来的 以下载为主变成下载和上传并重的模式。 随着全球互联网业务的不断发展, UGC业务正在日 渐崛起, 如社区网络、 视频分享和博客等, 都是 UGC 的主要应用形式, 同时也催生出海量 的数据, 以及对这些数据的海量随机读写。 如何存储这些数据, 提供高并发的随机读写服 务, 是技术领域必然面临的问题。
现有的技术方案, 采用分层的结构存储 UGC业务产生的数据, 包括: Cache (高速缓冲 存储器)层和数据层。 其中, Cache层使用内存存储, 缓存最近访问频率较高的数据, 并采 用淘汰策略将频率较低的数据从内存淘汰出去; 数据层使用磁盘存储, 保存全部数据。
在实现本发明的过程中, 发明人发现现有技术至少存在以下问题:
( 1 ) 数据一致性问题。 现有的技术方案, 采用分层的结构存储数据, 用户在修改数据 时, 需要将 Cache层和数据层的数据进行同步修改, 因此可能引发不一致问题。
( 2 ) 成本问题。 由于 Cache层存储的访问频率较高的数据也需要存储于数据层, 即该 部分的数据内容是冗余的, 从而造成了额外的成本;
( 3 ) 可靠性问题。 由于内存数据的存在易失性, 一旦机器掉电, Cache层需要重新加 载数据, 在 Cache 层加载数据过程中, 外部的请求可能受到影响, 同时, 数据层的访问量 也将增加, 从而增加了数据层的负载。
( 4) 设计复杂度问题。 为了解决或尽量缓解上述三个问题, 整个系统的设计会变得较 复杂。
( 5 ) 运维相关。 上面的几个因素, 都会增加运维成本。 发明内容
为了在确保数据存储的一致性、 减少现有技术中采用 Cache 层缓存数据而造成的数据 冗余和因机器掉电而引起的外部请求受损的同时, 减少系统设计的复杂度和运营维护成本, 本发明实施例提供了一种存储数据的方法和装置, 所述技术方案如下:
一方面, 提供了一种存储数据的方法, 所述方法包括:
接收用户发送的存储数据请求;
根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘。
所述接收用户发送的存储数据请求之后还包括:
判断所述存储数据请求的存储类型是否为随机存储;
如果是, 则判断所述存储数据请求是否满足预置的存储条件, 当所述存储数据请求不 满足所述预置的存储条件时, 拒绝所述存储数据请求, 当所述存储数据请求满足所述预置 的存储条件时, 继续执行根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘的操作; 如果不是,则继续执行根据所述存储数据请求,将数据存储至固态硬盘 SSD磁盘的操作。 所述判断所述存储数据请求是否满足预置的存储条件具体包括:
判断所述存储数据请求所在周期内接收到的包括所述存储数据请求的存储请求次数是 否超出了所述 SSD磁盘一个周期内处理的所述存储数据请求的最大次数, 如果不是, 则所 述存储数据请求满足所述存储条件。
所述一个周期内所述 SSD磁盘处理的所述存储数据请求次数的最大值至少为 1。
所述将数据存储至固态硬盘 SSD磁盘具体包括:
判断数据的格式是否为 TLV格式, 如果不是, 则将所述数据转换为 TLV格式的数据; 将所述 TLV格式的数据存储至 SSD磁盘。
另一方面, 本发明实施例提供了一种存储数据的装置, 所述装置包括- 存储数据请求接收模块, 用于接收用户发送的存储数据请求;
SSD磁盘存储模块, 用于根据所述存储数据请求, 将数据存储至 SSD磁盘。
所述装置还包括:
存储条件判断模块, 用于判断所述存储数据请求的存储类型是否为随机存储; 如果是, 则判断所述存储数据请求是否满足预置的存储条件, 当所述存储数据请求不满足所述预置 的存储条件时, 拒绝所述存储数据请求, 当所述存储数据请求满足所述预置的存储条件时, 继续执行根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘的操作; 如果不是, 则继 续执行根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘的操作。
所述存储条件判断模块具体包括:
存储数据请求判断单元, 用于判断所述存储数据请求所在周期内接收到的包括所述存
储数据请求的存储请求次数是否超出了所述 SSD磁盘一个周期内处理的所述存储数据请求 的最大次数, 如果不是, 则所述存储数据请求满足所述存储条件。
所述一个周期内所述 SSD磁盘处理的所述存储数据请求次数的最大值至少为 1。
SSD磁盘存储模块具体包括:
数据格式转换单元, 用于判断数据的格式是否为 TLV格式, 如果不是, 则将所述数据 转换为 TLV格式的数据;
数据存储单元, 用于将所述 TLV格式的数据存储至 SSD磁盘。
本发明实施例提供的技术方案带来的有益效果是:
通过根据所述存储数据请求, 将数据存储至 SSD磁盘, 确保了数据存储的一致性, 节 省了现有技术中采用 Cache层缓存数据而造成的数据冗余, 并且通过采用 SSD磁盘单层的 存储数据, 避免了现有技术中一旦机器掉电, Cache层需要重新加载数据而造成的影响外部 请求以及数据层的访问量的增加, 也进一步的减少了系统设计的复杂度和运营维护成本。 附图说明
为了更清楚地说明本发明实施例中的技术方案, 下面将对实施例描述中所需要使用的 附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是本发明的一些实施例, 对于本 领域普通技术人员来讲, 在不付出创造性劳动的前提下, 还可以根据这些附图获得其他的 附图。
图 1是本发明实施例 1中提供的一种存储数据的方法流程图;
图 2是本发明实施例 2中提供的另一种存储数据的方法流程图;
图 3是本发明实施例 2中 S204的一种具体步骤流程图;
图 4是本发明实施例 3中提供的一种存储数据的装置结构示意图。 具体实施方式
为使本发明的目的、 技术方案和优点更加清楚, 下面将结合附图对本发明实施方式作 进一步地详细描述。
实施例 1
如图 1所示, 本实施例公开了一种存储数据的方法, 包括以下步骤:
S101 : 接收用户发送的存储数据请求;
S102: 根据存储数据请求, 将数据存储至 SSD ( Sol id State Disk, 固态硬盘) 磁盘。 本实施例提供的方法, 通过根据存储数据请求, 将数据存储至 SSD磁盘, 确保了数据
存储的一致性, 节省了现有技术中采用 Cache 层缓存数据而造成的数据冗余, 并且通过采 用 SSD磁盘单层的存储数据, 避免了现有技术中一旦机器掉电, Cache层需要重新加载数据 而造成的影响外部请求以及数据层的访问量的增加, 也进一步的减少了系统设计的复杂度 和运营维护成本。 实施例 2
如图 2所示, 本实施例公开了一种存储数据的方法, 包括以下步骤:
S201 : 用户发送存储数据请求;
具体的, 用户发送的存储数据请求, 用于请求对其生成的数据进行存储。
其中, 用户请求存储的数据可以是用户新生成的数据, 也可以是用户对其已上传至网 络中的数据进行修改的修改后的数据。
例如, 用户通过 UGC业务, 如社区网络、 视频分享和博客等, 生成了数据, 用户需要 对该数据进行存储, 则用户发送存储数据请求; 或者, 用户对其已经生成的数据进行了修 改, 需要对修改后的数据进行存储, 则用户发送存储数据请求, 请求存储修改后的数据。
优选的, 该存储数据请求中, 还可包括数据的属性、 格式、 大小等数据信息, 可根据 存储需求定义存储数据请求。
S202 : 接收用户发送的存储数据请求;
S203 : 判断存储数据请求的存储类型是否为随机存储;
具体的, 判断存储数据请求的存储类型是否为随机存储, 如果是, 则执行 S204, 如果 不是, 则执行 S206。
其中, 存储类型包括随机存储和顺序存储。 当用户请求存储的数据是用户新生成的数 据时, SSD磁盘顺序存储该数据, 则该存储数据请求的类型为顺序存储; 当用户请求存储的 数据是用户修改后的数据时, SSD磁盘需查找与该修改后的数据相对应的未修改的数据, 并 用该修改后的数据替换该未修改的数据, 由于未修改的数据可能分布于 SSD磁盘的任意位 置, 则修改后的数据的存储位置也可能处于 SSD磁盘的任意位置, 因此, 相对于 SSD磁盘 来说, 该存储请求的类型为随机存储。
S204: 判断存储数据请求是否满足预置的存储条件, 如果是, 则执行 S205, 如果不是, 则该存储数据请求不满足该存储条件, 拒绝该存储数据请求。
具体的, 预置的存储条件, 用于避免 SSD磁盘可能存在的随机存储性能瓶颈。 当接收 到的需要 SSD磁盘进行随机存储的存储数据请求的请求频率超过其能承受的范围时, 可能 存在随机存储的性能瓶颈, 要避免遇到 SSD磁盘的性能瓶颈, 才能保证服务的稳定性。 因
此, 对 SSD磁盘的随机存储操作进行限制, 设置预置的存储条件, 以保护系统的稳定性。 当每收到一个需要进行随机存储的存储数据请求时, 都会判断是否符合存储条件, 如果符 合条件时, 则执行正常存储服务; 如果不符合存储条件, 则直接拒绝本次操作, 这样能起 到消峰的作用。 进一步的, 可通过设置不同的 SSD磁盘的存储条件, 使 SSD磁盘避免其性 能瓶颈, 从而保证服务的稳定性, 具体存储条件本实施例并不限定。
优选的, 预置的存储条件可以为一个周期内 SSD磁盘能够处理的存储数据请求的最大 次数; 即, 在一个周期内, 当存储数据请求超出了该最大次数, 则该存储数据请求不满足 存储条件, 拒绝该存储数据请求; 当存储数据请求未超出了该最大次数, 则该存储数据请 求满足存储条件, 接受该存储数据请求。 该一个周期内 SSD磁盘能够处理的存储数据请求 次数的最大次数至少为 1次。
其中, 存储数据请求的最大次数用于平衡 SSD磁盘的存储效率和存储稳定性。 当该最 大次数为一较低值时, SSD磁盘的稳定性较高, 但其随机存储效率则较低, 当该最大次数为 一较高值时, SSD磁盘随机存储效率则较高, 但其稳定性则较低。 一个周期内 SSD磁盘能够 处理的存储数据请求最大次数的具体计算方法可通过多次取值试验得出, 或由现有技术的 相关公式计算得出, 从而达到在确保 SSD磁盘的稳定性的前提下, 进一步提高 SSD随机存 储效率, 具体方法本实施例并不限定。
具体的, 当 SSD磁盘的存储条件为一个周期内 SSD磁盘能够处理的存储数据请求的最 大次数时, 判断存储数据请求是否满足存储条件具体为:
判断存储数据请求所在周期内接收到的包括存储数据请求的存储请求次数是否超出了 SSD磁盘一个周期内能够处理的存储数据请求的最大次数, 如果不是, 则存储数据请求满足 存储条件。
例如, 当该最大次数为 1 次时, 判断存储数据请求所在周期内接收到的包括存储数据 请求的存储请求次数是否超出了 SSD磁盘一个周期内能够处理的存储数据请求的最大次数 具体为- 判断该存储数据请求是否为其所在周期内接收到的第一次的存储数据请求, 如果是, 则该存储数据请求满足存储条件, 执行 S205 ; 如果不是, 即该存储数据请求不满足存储条 件;
当该最大次数为 20次时, 判断存储数据请求所在周期内接收到的包括存储数据请求的 存储请求次数是否超出了 SSD磁盘一个周期内能够处理的存储数据请求的最大次数具体为: 判断该存储数据请求是否为其所在周期内接收到的第一次至第二十次之间的任一存储 数据请求, 如果是, 则该存储数据请求满足存储条件, 执行 S204; 如果不是, 则该数据请
求不满足存储条件。
进一步优选的, 可以根据接收到的存储数据请求的类型, 设置不同的最大次数, 由于 SSD磁盘可能存在的存储性能瓶颈, 则参见图 3, S204具体可通过以下步骤实现, 但本实施 例并不限定:
S2041 : 记录存储数据请求的存储序号;
优选的, 通过计数器程序记录接收到的存储数据请求的存储序号。
其中, 该计数器程序中计数器的初始值设为零, 每当接收到的一个存储数据请求, 则 计数器加一, 直至 S2046 为计数器重新赋值, 使计数器记录当前周期接收到的存储数据请 求次数的真实值。
S2042: 获取该存储数据请求的存储序号;
具体的, 获取计数器程序记录的该存储数据请求的存储序号。
S2043: 判断该存储数据请求的存储序号是否小于或等于该最大值, 如果是, 则该存储 数据请求满足该预设条件, 执行 S205;
如果不是, 则执行 S2044;
S2044: 获取该存储数据请求的接收时间;
S2045: 获取最近一次记录的存储数据请求的接收时间;
具体的, 该最近一次记录的存储数据请求为该次存储数据请求所在周期内的第一次存 储数据请求。
S2046: 判断该存储数据请求的接收时间与最近一次记录的存储数据请求的接收时间的 时间间隔是否大于一个周期, 如果是, 则该存储数据请求满足该存储条件, 执行 S205, 并 将计数器的值设为 1, 使计数器程序初始化; 将最近一次记录的存储数据请求的接收时间修 改为该存储数据请求的接收时间;
如果不是, 则该存储数据请求不满足该存储条件, 拒绝该存储数据请求, 流程结束。 S2043至 S2046以代码形式表示为:
gdwRanWriteNum++ ; 〃记录存储数据请求的存储序号; if (gdwRanWriteNum dwMaxAl lowRanWrites)〃判断该存储数据请求的存储序号是否 小于或等于该最大值;
return 0 ; 〃满足存储条件;
dwCurTime = time (NULL); 〃获取该存储数据请求的接收时间; if (dwCurTime -gdwLastTime >T) 〃判断该存储数据请求的接收时间与最近一次记 录的存储数据请求的接收时间的时间间隔是否大于
一个周期; gdwLastTime = dwCurTime ; 〃将最近一次记录的存储数据请求的接收时间修改为 该存储数据请求的接收时间;
gdwRanWriteNum -) gdwRanWriteNum = 1 ; 〃使计数器记录当前周期接收到的存储数据 请求次数的真实值;
return 0 ; 〃满足存储条件; return 1 ; 〃则该存储数据请求不满足该存储条件。 其中,
gdwRanWriteNum为存储数据请求的存储序号;
dwMaxAl lowRanWrites为一个周期内 SSD磁盘能够处理的存储数据请求次数的最大值; dwCurTime为存储数据请求的接收时间;
gdwLastTime为最近一次记录的存储数据请求的接收时间;
return 0表示存储数据请求满足预设的存储条件;
return 1表示存储数据请求不满足预设的存储条件。
S205:判断数据的格式是否为 TLV格式,如果是,则执行 S207,如果不是,则执行 S206; 具体的, 判断存储数据请求中包含的数据的格式是否为 TLV格式, 如果不是, 则将该 数据转换为 TLV格式的数据;
其中, 在数据通讯协议里, 可选信息可以编码为 type-length-value 格式, 或者叫做 TLV。 type和 length域是固定长度, 一般为 1_4字节, value域是可变长度。 三个部分用 法如下:
Type 用一个数字代码表示整个数据块的类型;
Length Value区的大小 (一般以字节为单位);
Value 数据区, 长度可变的字节集。
S206: 将数据转换为 TLV格式的数据;
现有技术中, 本领域技术人员可很容易判断该数据的格式是否为 TLV格式, 如果不是, 则将该数据转换为 TLV格式的数据, 具体方法不再赘述。
S207: 将 TLV格式的数据存储至 SSD磁盘。
具体的, 根据该存储数据请求对该 TLV格式的数据进行存储。
现有技术中, 本领域技术人员可很容易根据存储数据请求对数据进行存储, 具体方法 不再赘述。
本实施例提供的方法, 通过根据存储数据请求, 将数据存储至 SSD磁盘, 确保了数据 存储的一致性, 节省了现有技术中采用 Cache 层缓存数据而造成的数据冗余, 并且通过采 用 SSD磁盘单层的存储数据, 避免了现有技术中一旦机器掉电, Cache层需要重新加载数据 而造成的影响外部请求以及数据层的访问量的增加, 也进一步的减少了系统设计的复杂度 和运营维护成本。 实施例 3
如图 4所示, 本实施例公开了一种存储数据的装置, 包括以下步骤:
存储数据请求接收模块 S301, 用于接收用户发送的存储数据请求;
SSD磁盘存储模块 S302, 用于根据存储数据请求, 将数据存储至 SSD磁盘;
存储条件判断模块 S303, 用于判断存储数据请求的存储类型是否为随机存储; 如果是, 则判断存储数据请求是否满足预置的存储条件, 当存储数据请求不满足预置的存储条件时, 拒绝存储数据请求, 当存储数据请求满足预置的存储条件时, 继续执行根据存储数据请求, 将数据存储至固态硬盘 SSD磁盘的操作; 如果不是, 则继续执行根据存储数据请求, 将数据 存储至固态硬盘 SSD磁盘的操作;
存储条件判断模块 S303具体包括:
存储数据请求判断单元 S3031 ,用于当预置的存储条件为一个周期内 SSD磁盘能够处理 的存储数据请求次数的最大值时, 判断存储数据请求所在周期内接收到的包括存储数据请 求的存储请求次数是否超出了最大值, 如果不是, 则存储数据请求满足存储条件;
一个周期内 SSD磁盘能够处理的存储数据请求次数的最大值至少为 1 ;
SSD磁盘存储模块 S302具体包括:
数据格式转换单元 S3021, 用于判断数据的格式是否为 TLV格式, 如果不是, 则将数据 转换为 TLV格式的数据;
数据存储单元 S3022 , 用于将 TLV格式的数据存储至 SSD磁盘。
本实施例提供的装置, 通过根据存储数据请求, 将数据存储至 SSD磁盘, 确保了数据 存储的一致性, 节省了现有技术中采用 Cache 层缓存数据而造成的数据冗余, 并且通过采 用 SSD磁盘单层的存储数据, 避免了现有技术中一旦机器掉电, Cache层需要重新加载数据 而造成的影响外部请求以及数据层的访问量的增加, 也进一步的减少了系统设计的复杂度 和运营维护成本。
需要说明的是: 上述实施例提供的存储数据的装置在存储数据时, 仅以上述各功能模 块的划分进行举例说明, 实际应用中, 可以根据需要而将上述功能分配由不同的功能模块 完成, 即将装置的内部结构划分成不同的功能模块, 以完成以上描述的全部或者部分功能。 另外, 上述实施例提供的存储数据的装置与存储数据的方法实施例属于同一构思, 其具体 实现过程详见方法实施例, 这里不再赘述。
以上实施例提供的技术方案中的全部或部分内容可以通过硬件实现, 也可以通过程序 来指令相关的硬件完成, 所述的程序可以存储在可读取的存储介质中, 存储介质例如: 计 算机中的硬盘、 光盘或软盘。
以上仅为本发明的较佳实施例, 并不用以限制本发明, 凡在本发明的精神和原则之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。
Claims
1、 一种存储数据的方法, 其特征在于, 所述方法包括:
接收用户发送的存储数据请求;
根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘。
2、根据权利要求 1所述方法, 其特征在于, 所述接收用户发送的存储数据请求之后还包 括- 判断所述存储数据请求的存储类型是否为随机存储;
如果是, 则判断所述存储数据请求是否满足预置的存储条件, 当所述存储数据请求不满 足所述预置的存储条件时, 拒绝所述存储数据请求, 当所述存储数据请求满足所述预置的存 储条件时, 继续执行根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘的操作;
如果不是, 则继续执行根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘的操作。
3、根据权利要求 2所述方法, 其特征在于, 所述判断所述存储数据请求是否满足预置的 存储条件具体包括:
判断所述存储数据请求所在周期内接收到的包括所述存储数据请求的存储请求次数是否 超出了所述 SSD磁盘一个周期内处理的所述存储数据请求的最大次数, 如果不是, 则所述存 储数据请求满足所述存储条件。
4、 根据权利要求 3所述方法, 其特征在于, 所述一个周期内所述 SSD磁盘处理的所述 存储数据请求次数的最大值至少为 1。
5、根据权利要求 1至 4中任一项所述方法,其特征在于,所述将数据存储至固态硬盘 SSD 磁盘具体包括:
判断数据的格式是否为 TLV格式, 如果不是, 则将所述数据转换为 TLV格式的数据; 将所述 TLV格式的数据存储至 SSD磁盘。
6、 一种存储数据的装置, 其特征在于, 所述装置包括:
存储数据请求接收模块, 用于接收用户发送的存储数据请求;
SSD磁盘存储模块, 用于根据所述存储数据请求, 将数据存储至 SSD磁盘。
7、 根据权利要求 6所述装置, 其特征在于, 所述装置还包括:
存储条件判断模块, 用于判断所述存储数据请求的存储类型是否为随机存储; 如果是, 则判断所述存储数据请求是否满足预置的存储条件, 当所述存储数据请求不满足所述预置的 存储条件时, 拒绝所述存储数据请求, 当所述存储数据请求满足所述预置的存储条件时, 继 续执行根据所述存储数据请求, 将数据存储至固态硬盘 SSD 磁盘的操作; 如果不是, 则继续 执行根据所述存储数据请求, 将数据存储至固态硬盘 SSD磁盘的操作。
8、 根据权利要求 7所述装置, 其特征在于, 所述存储条件判断模块具体包括: 存储数据请求判断单元, 用于判断所述存储数据请求所在周期内接收到的包括所述存储 数据请求的存储请求次数是否超出了所述 SSD磁盘一个周期内处理的所述存储数据请求的最 大次数, 如果不是, 则所述存储数据请求满足所述存储条件。
9、 根据权利要求 8所述装置, 其特征在于, 所述一个周期内所述 SSD磁盘处理的所述 存储数据请求次数的最大值至少为 1。
10、根据权利要求 6至 9中任一项所述装置,其特征在于, SSD磁盘存储模块具体包括: 数据格式转换单元, 用于判断数据的格式是否为 TLV格式, 如果不是, 则将所述数据转 换为 TLV格式的数据;
数据存储单元, 用于将所述 TLV格式的数据存储至 SSD磁盘。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US13/677,141 US8738839B2 (en) | 2010-09-17 | 2012-11-14 | Method and device for storing data in solid state disk (SSD) and storage medium storing programs to perform the method |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201010287013.3 | 2010-09-17 | ||
| CN201010287013.3A CN102402397B (zh) | 2010-09-17 | 2010-09-17 | 存储数据的方法和装置 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US13/677,141 Continuation US8738839B2 (en) | 2010-09-17 | 2012-11-14 | Method and device for storing data in solid state disk (SSD) and storage medium storing programs to perform the method |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2012034475A1 true WO2012034475A1 (zh) | 2012-03-22 |
Family
ID=45831001
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2011/078965 Ceased WO2012034475A1 (zh) | 2010-09-17 | 2011-08-26 | 存储数据的方法和装置 |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US8738839B2 (zh) |
| CN (1) | CN102402397B (zh) |
| WO (1) | WO2012034475A1 (zh) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103761180A (zh) * | 2014-01-11 | 2014-04-30 | 浪潮电子信息产业股份有限公司 | 一种集群存储中磁盘故障的预防及检测方法 |
| CN105302478B (zh) | 2015-09-23 | 2019-09-24 | 联想(北京)有限公司 | 一种数据存储方法及电子设备 |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101398749A (zh) * | 2008-11-13 | 2009-04-01 | 成都市华为赛门铁克科技有限公司 | 一种静态损耗均衡的方法、装置和系统 |
| CN101504625A (zh) * | 2009-03-04 | 2009-08-12 | 成都市华为赛门铁克科技有限公司 | 实现独立磁盘冗余阵列的方法、固态硬盘和电子设备 |
| CN101699413A (zh) * | 2009-10-30 | 2010-04-28 | 成都市华为赛门铁克科技有限公司 | 硬盘数据读写控制方法、装置及数据存储系统 |
Family Cites Families (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2010049502A (ja) * | 2008-08-21 | 2010-03-04 | Hitachi Ltd | ストレージサブシステム、及びこれを有するストレージシステム |
| KR101515621B1 (ko) * | 2008-09-26 | 2015-04-29 | 삼성전자주식회사 | 반도체 디스크 장치 및 그것의 랜덤 데이터 처리 방법 |
| CN101446924B (zh) * | 2008-12-16 | 2013-04-17 | 成都市华为赛门铁克科技有限公司 | 一种数据存储及获取方法、系统 |
| US8230123B2 (en) * | 2010-08-23 | 2012-07-24 | International Business Machines Corporation | Using information on input/output (I/O) sizes of accesses to an extent to determine a type of storage device for the extent |
| US8566308B2 (en) * | 2011-01-26 | 2013-10-22 | International Business Machines Corporation | Intelligent adaptive index density in a database management system |
-
2010
- 2010-09-17 CN CN201010287013.3A patent/CN102402397B/zh active Active
-
2011
- 2011-08-26 WO PCT/CN2011/078965 patent/WO2012034475A1/zh not_active Ceased
-
2012
- 2012-11-14 US US13/677,141 patent/US8738839B2/en active Active
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101398749A (zh) * | 2008-11-13 | 2009-04-01 | 成都市华为赛门铁克科技有限公司 | 一种静态损耗均衡的方法、装置和系统 |
| CN101504625A (zh) * | 2009-03-04 | 2009-08-12 | 成都市华为赛门铁克科技有限公司 | 实现独立磁盘冗余阵列的方法、固态硬盘和电子设备 |
| CN101699413A (zh) * | 2009-10-30 | 2010-04-28 | 成都市华为赛门铁克科技有限公司 | 硬盘数据读写控制方法、装置及数据存储系统 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN102402397A (zh) | 2012-04-04 |
| US8738839B2 (en) | 2014-05-27 |
| US20130073782A1 (en) | 2013-03-21 |
| CN102402397B (zh) | 2014-12-03 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP6316974B2 (ja) | フラッシュメモリ圧縮 | |
| CN114201421B (zh) | 一种数据流处理方法、存储控制节点及可读存储介质 | |
| CN112632069B (zh) | 哈希表数据存储管理方法、装置、介质和电子设备 | |
| CN101916289B (zh) | 支持海量小文件和动态备份数的数字图书馆存储系统的构建方法 | |
| WO2015154352A1 (zh) | 分布式文件系统的数据迁移方法、装置及元数据服务器 | |
| CN102841931A (zh) | 分布式文件系统的存储方法及装置 | |
| CN105205014A (zh) | 一种数据存储方法和装置 | |
| JP2014528127A (ja) | 使用状態ビットマップを備えた記憶装置への効率的なアクセス | |
| CN103853671A (zh) | 一种数据写入控制方法及装置 | |
| CN113835616A (zh) | 应用的数据管理方法、系统和计算机设备 | |
| CN107562385A (zh) | 分布式存储客户端读取数据的方法、装置和设备 | |
| CN111930305A (zh) | 数据的存储方法和装置、存储介质、电子装置 | |
| CN105187564A (zh) | 一种手机端文件断点续传的方法 | |
| WO2024046188A1 (zh) | 一种云环境下的i/o卸载方法、设备、系统及存储介质 | |
| CN116233111A (zh) | 一种基于Minio的大文件上传方法 | |
| CN107422989B (zh) | 一种Server SAN系统多副本读取方法及存储系统 | |
| WO2017054540A1 (zh) | 一种数据处理方法、装置、服务器及控制器 | |
| CN107423425B (zh) | 一种对k/v格式的数据快速存储和查询方法 | |
| CN117931690A (zh) | 缓存盘动态扩缩容的方法及装置 | |
| WO2012034475A1 (zh) | 存储数据的方法和装置 | |
| CN103491124A (zh) | 一种对彩信数据进行处理的方法及分布式缓存系统 | |
| CN118193540B (zh) | 索引处理方法、装置、电子设备及可读存储介质 | |
| CN118708135A (zh) | 存储空间的调整方法、装置、存储介质和电子设备 | |
| CN117762332A (zh) | 一种存储管理系统、方法、设备及机器可读存储介质 | |
| CN117573756A (zh) | 业务计数方法、装置、存储介质及电子设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 11824545 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 20/09/2013) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 11824545 Country of ref document: EP Kind code of ref document: A1 |