CN112099736A - Data storage method and device, electronic equipment and storage medium - Google Patents

Data storage method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112099736A
CN112099736A CN202011016833.9A CN202011016833A CN112099736A CN 112099736 A CN112099736 A CN 112099736A CN 202011016833 A CN202011016833 A CN 202011016833A CN 112099736 A CN112099736 A CN 112099736A
Authority
CN
China
Prior art keywords
data
storage data
storage
hard disk
memory buffer
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
CN202011016833.9A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202011016833.9A priority Critical patent/CN112099736A/en
Publication of CN112099736A publication Critical patent/CN112099736A/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/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/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/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/0659Command handling arrangements, e.g. command buffers, queues, command scheduling
    • 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/0673Single storage device

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

The embodiment of the application discloses a data storage method and device, electronic equipment and a storage medium. Relates to the field of data storage. The method comprises the following steps: responding to a data storage request, and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party; when the write-in execution condition is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into a hard disk, wherein the hard disk is a mechanical hard disk; and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into the memory queue. Therefore, the number of times and the movement distance of mechanical movement of the hard disk triggering magnetic head are reduced, the performance of writing data into the hard disk is improved, and the file storage in the hard disk is more quickly facilitated.

Description

Data storage method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of data storage, and more particularly, to a data storage method and apparatus, an electronic device, and a storage medium.
Background
In electronic devices, there are usually many data to be stored, and there are also many data storage methods. For example, in the data storage process of the persistent queue, data is stored in the hard disk first, and then the data stored in the hard disk is stored in the memory. However, during the data storage process of the persistent queue, the performance of writing data into the hard disk still needs to be improved.
Disclosure of Invention
In view of the above problems, the present application provides a data storage method, an apparatus, an electronic device and a storage medium to improve the above problems.
In a first aspect, the present application provides a data storage method, including: responding to a data storage request, and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party; when the write-in execution condition is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk, wherein the hard disk is a mechanical hard disk; and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into a memory queue.
In a second aspect, the present application provides a data storage device comprising: the data buffer unit is used for responding to a data storage request and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party; the persistent write-in unit is used for writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk when a write-in execution condition is met, wherein the hard disk is a mechanical hard disk; and the memory writing unit is used for storing the first storage data written into the memory buffer area into a memory queue after the second storage data is successfully written into the hard disk.
In a third aspect, the present application provides an electronic device comprising a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the methods described above.
In a fourth aspect, the present application provides a computer readable storage medium having program code stored therein, wherein the method described above is performed when the program code is executed by a processor.
According to the data storage method, the data storage device, the electronic equipment and the storage medium, in response to a data storage request, first storage data requested to be stored in a hard disk is stored in a memory buffer area, then when a write-in execution condition is met, second storage data obtained by combining a plurality of first storage data written in the memory buffer area are written in the hard disk, and then after the second storage data are successfully written in the hard disk, the first storage data written in the memory buffer area are stored in a memory queue. Therefore, the plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that the operation of writing data into the hard disk once is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the times of writing the second storage data into the hard disk are reduced. In addition, the mechanical hard disk locates the data writing position based on the mechanical movement of the magnetic head in the process of writing data, so that the times and the movement distance of the mechanical movement of the magnetic head triggered by the hard disk are reduced under the condition of reducing the times of writing the data into the hard disk, and the performance of writing the data into the hard disk is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are 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 to obtain other drawings based on these drawings without creative efforts.
FIG. 1 shows a schematic diagram of a persistence queue;
FIG. 2 is a schematic diagram illustrating an application environment of a data storage method in an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating an application environment of another data storage method in the embodiment of the present application;
FIG. 4 is a flow chart illustrating a data storage method according to an embodiment of the present application;
FIG. 5 is a flow chart illustrating a data storage method according to another embodiment of the present application;
FIG. 6 is a diagram illustrating determination of a write execution condition based on a deadline in an embodiment of the present application;
FIG. 7 is a diagram illustrating a condition content included in determining a write execution condition in multiple stages in an embodiment of the present application;
FIG. 8 is a diagram showing a combined second storage data in the embodiment of the present application;
FIG. 9 is a diagram illustrating changes to store instructions after combining first store data in an embodiment of the present application;
FIG. 10 is a schematic diagram illustrating splicing of first storage data to obtain second storage data in an embodiment of the present application;
FIG. 11 is a diagram illustrating an example of fetching first store data from a memory queue according to an embodiment of the present application
Fig. 12 is a flow chart illustrating a data storage method according to another embodiment of the present application;
FIG. 13 is a flow chart illustrating a data storage method according to yet another embodiment of the present application;
FIG. 14 is a flow chart illustrating a data storage method according to yet another embodiment of the present application;
fig. 15 is a block diagram showing a structure of a data storage device according to an embodiment of the present application;
fig. 16 is a block diagram showing a data storage device according to another embodiment of the present application;
fig. 17 is a block diagram showing another electronic device for executing a data storage method according to an embodiment of the present application;
fig. 18 shows a storage unit for storing or carrying program codes for implementing the data storage method according to the embodiment of the present application.
Detailed Description
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 of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
As computer systems become increasingly functional, more data is generated for storage. For example, for data processing tasks dispatched by some computer systems, received data processing tasks are stored if they are not processed immediately. As a storage mode, the electronic device may store data to be stored in a persistent queue mode.
As shown in fig. 1, the persistent queue includes a memory queue, the memory queue is a queue running in a memory, and data in the memory queue is stored in a hard disk in a file form, so that the persistent queue can be understood as being composed of the memory queue and a file stored in the hard disk, so that even when data in the memory is cleared due to some reasons, data can be recovered from the hard disk to the memory queue, so as to implement reliable data storage in the persistent queue. When data is stored through a persistent queue, data to be stored is stored in a hard disk, and then the same data is stored in the queue.
However, the inventors found in their research that the data storage performance of the relevant persistent queue is to be improved. Specifically, the inventor of the present invention has found, in a research on a data storage manner of a related persistent queue, that in the related manner, a data storage operation is performed immediately every time data needs to be stored, and an operation of writing data into a hard disk is performed every time the data storage operation is performed. However, for a mechanical hard disk, data reading and writing positions are positioned by mechanical movement of a magnetic head, and each time data writing operation is performed based on a random writing mode, so that each time data writing operation is performed on the hard disk, the hard disk needs to be positioned by the mechanical movement of the magnetic head, and excessive mechanical movement of the magnetic head affects data writing performance.
Therefore, in order to solve the above problem, embodiments of the present application provide a data storage method, an apparatus, an electronic device, and a storage medium, where first storage data requested to be stored in a hard disk is first stored in a memory buffer area in response to a data storage request, and then when a write execution condition is satisfied, second storage data obtained by combining a plurality of first storage data written in the memory buffer area is written in the hard disk, and then when the second storage data is successfully written in the hard disk, the first storage data written in the memory buffer area is stored in a memory queue.
Therefore, the plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that the operation of writing data into the hard disk once is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the times of writing the second storage data into the hard disk are reduced. In addition, the mechanical hard disk locates the data writing position based on the mechanical movement of the magnetic head in the process of writing data, so that the times and the movement distance of the mechanical movement of the magnetic head triggered by the hard disk are reduced under the condition of reducing the times of writing the data into the hard disk, and the performance of writing the data into the hard disk is improved.
Before further detailed description of the embodiments of the present application, the embodiments of the present application are described with reference to an application environment.
As shown in fig. 2, fig. 2 is a schematic diagram of an application environment according to an embodiment of the present application. The system includes a client 10 and a server 20. The client 10 may generate a data storage request and then send the generated processing request to the server 20, and the data storage method provided in the embodiment of the present application may be executed in the server 20, and further, after the server 20 receives the data storage request, subsequent processing may be performed based on the data storage method provided in the embodiment of the present application. Where the client 10 may be understood as a storage caller, the environment shown in fig. 1 may also include other clients besides the client 10, and each client may be considered as a storage caller.
It should be noted that the server 20 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a CDN (Content Delivery Network), a big data and an artificial intelligence platform. The electronic device where the client 10 is located may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like.
As shown in fig. 3, fig. 3 is a schematic diagram of another application environment according to an embodiment of the present application. In fig. 3, both the client 40 and the system component 50 operate in the same electronic device 30, in this way, the client 40 may generate a data storage request and then send the generated processing request to the system component 50, and the data storage method provided in the embodiment of the present application may operate in the system component 50, and further, after the system component 50 receives the data storage request, subsequent processing may be further performed based on the data storage method provided in the embodiment of the present application.
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Referring to fig. 4, fig. 4 is a flowchart illustrating a data storage method according to an embodiment of the present application, where the method includes:
s110: responding to a data storage request, and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party.
As one way, a data storage flow can be triggered by sending a data storage request to a storage caller needing to store data. The first storage data requested to be stored is the first storage data requested by the data storage request. The server or the system component executing the data storage method provided by this embodiment may take the requested data as the first storage data after receiving the data storage request, and store the first storage data in the memory buffer. The memory buffer may be a data buffer area in the memory different from the memory queue.
It should be noted that, in this embodiment, the first storage data is not written into the memory buffer as a trigger to write the received first storage data into the hard disk, but the operation of writing the first storage data in the memory buffer into the hard disk is executed when a subsequent writing condition is required to be met, and the received first storage data may be stored into the memory buffer for temporary storage.
The server or system component executing the data storage method may have various ways of acquiring the first storage data.
As one approach, the first storage data may be carried in a data storage request. In this manner, the first storage data may be retrieved from the data storage request by parsing the data storage request. Alternatively, the server or system component may send a response message to the application sending the data storage request after receiving the data storage request, and the application may return the first storage data in response to the response message after receiving the response message.
Optionally, the data content of the first storage data may be determined according to different application scenarios of the data storage method provided in this embodiment. For example, if the application scenario is a log system, the content of the first storage data may be a log. If the application scenario is a commodity transaction system, the first storage data may be commodity transaction data.
S120: and when the write-in execution condition is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk, wherein the hard disk is a mechanical hard disk.
The writing execution condition represents a condition for writing the first storage data in the memory buffer area into the hard disk. In addition, in order to reduce the number of times of executing the write operation to the hard disk, the first storage data written into the memory buffer area is combined to obtain second storage data, and then the operation of writing the second storage data into the hard disk is executed once, so that the first storage data which are not written into the hard disk in the memory buffer area can be all written into the hard disk. Illustratively, when the write execution condition is satisfied, the first storage data written into the memory buffer includes first storage data a1, first storage data a2, first storage data a3, and first storage data a4, and further, the first storage data a1, the first storage data a2, the first storage data a3, and the first storage data a4 are combined to obtain second storage data b 1. Then, the second storage data b1 is written into the hard disk once, so that the first storage data a1, the first storage data a2, the first storage data a3 and the first storage data a4 can be written into the hard disk once, without performing the operation of writing into the hard disk once for the first storage data a1, the first storage data a2, the first storage data a3 and the first storage data a4, respectively, thereby reducing the number of times of writing into the hard disk.
As one mode, when a write execution condition is satisfied, writing second storage data obtained by combining a plurality of first storage data written into a memory buffer area into a hard disk includes: and when the write-in execution condition is met, combining the plurality of first storage data written into the memory buffer area into second storage data based on a group commit mode, and writing the second storage data into the hard disk. The server or the system component executing the data storage method may trigger writing of the second storage data into the hard disk based on the group commit mode through the fsync instruction.
S130: and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into the memory queue.
It should be noted that the purpose of writing the first storage data into the hard disk is to perform persistent storage, for example, to recover data from the hard disk after power failure, and when the first storage data is subsequently called, the first storage data is called from the memory queue, and further, for the purpose of subsequent calling, when the second storage data is successfully written into the hard disk, the first storage data written into the memory buffer is stored into the memory queue.
In the data storage method provided in this embodiment, in response to a data storage request, first storage data requested to be stored in a hard disk is first stored in a memory buffer, and then when a write-in execution condition is satisfied, second storage data obtained by combining a plurality of first storage data written in the memory buffer is written in the hard disk, and then when the second storage data is successfully written in the hard disk, the first storage data written in the memory buffer is stored in a memory queue. Therefore, the plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that the operation of writing data into the hard disk once is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the times of writing the second storage data into the hard disk are reduced. In addition, the mechanical hard disk locates the data writing position based on the mechanical movement of the magnetic head in the process of writing data, so that the times and the movement distance of the mechanical movement of the magnetic head triggered by the hard disk are reduced under the condition of reducing the times of writing the data into the hard disk, and the performance of writing the data into the hard disk is improved.
Referring to fig. 5, fig. 5 is a flowchart illustrating a data storage method according to an embodiment of the present application, where the method includes:
s210: responding to a data storage request, and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party.
S220: and when the write-in execution condition is met, acquiring a splicing sequence corresponding to the first storage data written into the memory buffer area.
In this embodiment, the specific content of the write execution condition may be written in various ways.
By one approach, the write execution condition includes at least one of the following conditions: the quantity of the first storage data stored in the memory buffer area meets a quantity threshold value; the data volume of the first storage data stored in the memory buffer area meets a data volume threshold value; and the expiration time to the current data write cycle.
Optionally, the write execution condition may include that the number of the first storage data stored in the memory buffer satisfies a number threshold. In this way, when the first storage data is written into the memory buffer, the amount of the first storage data that has been written into the memory buffer and has not been written into the hard disk may be updated correspondingly, and if the amount satisfies the amount threshold, it is determined that the write execution condition is satisfied. For example, if the number threshold is 3, if the number of the first storage data that has been written into the memory buffer and has not been written into the hard disk is 2, it is detected again that the first storage data is written into the memory buffer, the number is updated from 2 to 3, in which case the number of the first storage data that has been written into the memory buffer and has not been written into the hard disk satisfies the number threshold 3, and it is determined that the current write execution condition is satisfied, the 3 first storage data are combined into one second storage data.
Optionally, the write execution condition may include that a data amount of the first storage data stored in the memory buffer satisfies a data amount threshold. It should be noted that the data amount may be understood as the size of the storage space occupied by the first storage data. Illustratively, if the memory buffer is written with the first storage data a1 and the first storage data a2, wherein the size of the storage space occupied by the first storage data a1 is 500KB, and the size of the storage space occupied by the second storage data a2 is 600KB, the amount of the first storage data stored in the memory buffer, which has been written into the memory buffer and has not been written into the hard disk, is 2, and the data amount is 1100 KB. Correspondingly, the system combination or the server correspondingly updates the data volume of the first storage data which is written into the memory buffer area and is not written into the hard disk after the first storage data is written into the memory buffer area each time, and determines that the write-in execution condition is met if the updated data volume reaches the data volume threshold value. Illustratively, the data size threshold is 10MB, and if the updated data size is greater than 10MB, it is determined that the data size threshold is met, and then it is determined that the current write execution condition is met.
Alternatively, the write execution condition may include an expiration time of reaching the current data write cycle. It should be noted that the system component or the server may periodically perform the operation of writing data into the hard disk. For example, the operation of writing data into the hard disk may be performed once every t seconds, as shown in fig. 6, in a period from 2t to 3t, when the expiration time of the period is reached, the first storage data written into the memory buffer and not yet written into the hard disk includes the first storage data a5 and the first storage data a6, and when the expiration time of the period from 2t to 3t is reached, the second storage data is obtained by combining the first storage data a5 and the first storage data a 6. Similarly, when the expiration time of the period of 3t to 4t is reached, the second stored data is obtained by combining the first stored data a7, the first stored data a8, and the first stored data a 9.
Further, as described above, the write execution condition may include a plurality of conditions in addition to the case where one of the conditions may be included.
Optionally, the write execution condition may include that the amount of the first storage data stored in the memory buffer satisfies a number threshold and that the data amount of the first storage data stored in the memory buffer satisfies a data amount threshold. In this way, the number and the data amount of the first storage data written into the memory buffer need to be determined at the same time, and it is determined that the write execution condition is satisfied under the condition that the number of the first storage data satisfies the number threshold and the data amount of the first storage data satisfies the data amount threshold.
Optionally, the write execution condition may include that the amount of the first storage data stored in the memory buffer satisfies a number threshold and reaches the deadline of the current data write cycle. In this way, it is necessary to simultaneously determine the amount of the first storage data written into the memory buffer and whether the deadline of the current data writing period is reached, and further, when the amount of the first storage data written into the memory buffer satisfies the amount threshold and the deadline of the current data writing period is reached, it is determined that the writing execution condition is satisfied.
The content of the condition specifically included in the aforementioned write execution condition is only exemplary, for example, the write execution condition may include a combination of any two of the aforementioned three conditions, or may include all the aforementioned three conditions.
It should be noted that, in this embodiment, the trigger effect brought by each specific condition is different, for example, in such a manner based on the quantity threshold, it is necessary to wait until the quantity of the first storage data written into the memory buffer satisfies the quantity threshold to determine that the write execution condition is satisfied, and through further research, the inventors have found that, if the quantity of the first storage data is generally large, and it is still determined whether the quantity threshold is satisfied according to the quantity threshold, the quantity of the second storage data obtained by combining the first storage data and the second storage data when the execution condition is satisfied is large, and further, when the first storage data is written, a relatively long time needs to be consumed, and a write delay of writing sequentially subsequent data in the writing process is caused.
For another example, in this manner based on the data amount threshold, the operation of writing to the hard disk is triggered to be executed only when the data amount of the first storage data that needs to be written into the memory buffer meets the data amount threshold, and if the data amount of the first storage data is generally small, and it is still determined whether the write execution condition is met according to the data amount threshold, a larger amount of first storage data needs to be accumulated to reach the data amount threshold, so that the first storage data that is previously stored into the memory buffer may have a larger delay. For example, the first storage data a1, the first storage data a2, the first storage data a3 … … and the first storage data a10 are sequentially stored in the memory buffer, and if the write execution condition is satisfied when the first storage data a10 is written into the memory buffer, the first storage data a1 written first has a large storage delay.
Then, in order to make the data storage method provided by the present embodiment have better environmental suitability, the content of the condition specifically included in the write execution condition may be determined according to the size of the data amount of the first storage data requested to be stored.
As a manner, the content of the condition specifically included in the write execution condition may be determined according to the type of service to which the data storage method provided by the present embodiment is applied.
It should be noted that, for data of the same service type, the size of the data volume has a greater similarity. For example, for a user login service, the stored data may be the login account number and the corresponding password of the user, and the data amount corresponding to the login account number and the password is relatively small, in this way, whether the write execution condition is satisfied may be determined according to the number threshold. For another example, in some service scenarios, data processing tasks may be mutually dispatched between systems, and some data processing tasks that are not yet ready to be executed may be stored, and the task identifier of the data processing task may be stored therein, and the data volume of the task identifier itself is relatively small, so that in this manner, it may be determined whether the write execution condition is satisfied according to the volume threshold. Furthermore, in the file storage service, files are stored, and the data volume of the files is relatively large compared to the aforementioned login account or task identifier, in this way, in order to avoid the aforementioned problem of storage delay, it may be determined whether the write execution condition is satisfied based on the data volume threshold.
Optionally, a corresponding relationship between the service type and the corresponding write execution condition may be pre-established, so that in the operation process of the data storage method provided in this embodiment, after the currently deployed service scenario is acquired to acquire the service type, the condition content specifically included in the write execution condition may be determined based on the corresponding relationship. Illustratively, the established correspondence relationship includes that the service type p1 corresponds to the write execution condition c1, the service type p2 corresponds to the write execution condition c1, the service type p3 corresponds to the write execution condition c2, and the service type p4 corresponds to the write execution condition c 3. Then, in the case where the traffic type is identified as p1, the determined write execution condition is the write execution condition c 1. In the case where it is recognized that the traffic type is p4, the determined write execution condition is a write execution condition c 3.
Optionally, in the embodiment, the system component and the server may identify the service type according to the service identifier carried in the data storage request, when the data storage request carries the service identifier. And under the condition that the data storage request does not carry the service identification, the service type can be identified according to the structure of the required storage data (first storage data).
Alternatively, the content of the condition specifically included in the write execution condition may be determined directly from the size of the data amount of the storage data requested by the first storage data. Optionally, the data amount of the first storage data written into the memory buffer within a period of time may be counted, and an average data amount of each first storage data is calculated, and if the average data amount is smaller than the average threshold, whether the write-in execution condition is satisfied may be determined according to the number threshold. Conversely, if the average data amount is greater than the average threshold, it may be determined whether the write execution condition is satisfied according to the data amount threshold. For example, the first storage data written into the memory buffer in a period of time includes 10 first storage data, i.e. the first storage data a1, the first storage data a2, the first storage data a3 … …, and the first storage data a10, then the sum of the data amount of the 10 first storage data may be divided by 10 to obtain the average data amount.
It should be noted that, in this manner, it may not be determined how to determine the content of the condition specifically included in the write execution condition at an early stage (for example, when the average data amount has not been calculated for the first time), in this manner, a default manner of determining whether the write execution condition is satisfied may be adopted first, and after the average data amount is calculated to determine whether the corresponding manner of determining whether the write execution condition is satisfied, the subsequent steps may be executed using the write execution condition obtained based on the average data amount.
Further, the content of the condition included in the write execution condition may be determined by combining the foregoing two manners, i.e., according to the type of service and the size of the data amount of the requested storage data. It should be noted that, in the manner of determining the condition content included in the write execution condition based on the service type, the service type may be identified when the first storage data is acquired for the first time, and the condition content included in the write execution condition may be determined more immediately. Then as a way, as shown in fig. 7. In this way, there are two phases in the operation process of the data storage method provided in this embodiment, namely, the first phase and the second phase shown in fig. 7. The first stage is a stage in which the data processing method starts to run, and in this stage, because a sufficient amount of first storage data has not been acquired yet, and further an average data volume has not been calculated according to the data volume of the first storage data to determine condition content specifically included in the write execution condition, further in order to ensure that the first storage data in the memory buffer can still be successfully written into the hard disk, the condition content specifically included in the write execution condition is determined according to the service type in the first stage. As shown in FIG. 7, where t iskThe average data amount is calculated for the first time, and the time when the condition content specifically included in the write execution condition is obtained is determined based on the average data amount calculated for the first time. Then at tkThe write execution condition is determined according to the average data amount after the time.
When it is determined that the write-in execution condition is satisfied, the first storage data which is written into the memory buffer and is not written into the hard disk yet may be spliced to obtain second storage data. Optionally, when the first storage data is spliced, because there may be a plurality of first storage data, the splicing order of each first storage data may be determined first, so that the splicing is performed based on the corresponding splicing order. In this embodiment, there may be a plurality of ways to determine the splicing order.
As a mode, acquiring a splicing order corresponding to a plurality of first storage data written in a memory buffer includes: acquiring a service type corresponding to first storage data written into a memory buffer area; and determining a splicing order corresponding to the first storage data written into the memory buffer area based on the service type. It should be noted that the service type corresponding to the first storage data may be understood as a service type of a service for generating the first storage data. The data storage method provided by the embodiment of the present application may be operated in one service scenario, and when the data storage method is operated in the same service scenario, the received first storage data belongs to the same service generation, and then the service types corresponding to the first storage data are the same.
Optionally, the first storage data written into the memory buffer may be data to be stored in the hard disk corresponding to the same service, or data to be stored in the hard disk corresponding to different services. For example, when the write execution condition is satisfied, the first storage data that is written into the memory buffer and has not been written into the hard disk includes first storage data a1, first storage data a2, first storage data a3, and first storage data a4, where the first storage data a1 and the first storage data a2 may belong to storage data generated in the same service, and the first storage data a3 and the first storage data a4 may belong to storage data generated in the same service.
Wherein, the storage priority corresponding to different services may be different. Optionally, the splicing order of each first storage data may be determined based on a priority of a service type corresponding to the first storage data, where the higher the priority of the corresponding service type is, the earlier the splicing order corresponding to the first storage data is. As shown in fig. 8, the first storage data a1 is spliced first, then the first storage data a2, then the first storage data a3, and finally the first storage data a4, and then the spliced second storage data is shown in the figure, wherein the direction indicated by the dashed arrow is the forward direction. It should be noted that, in the embodiment of the present application, it can be understood that, in a direction close to the start of writing, when writing the second storage data into the hard disk, the first storage data with the most advanced splicing order is written into the hard disk first.
As another way, obtaining a splicing order corresponding to a plurality of first storage data written in the memory buffer includes: acquiring the writing time of the first storage data written into the memory buffer area; and determining a splicing order corresponding to the first storage data written into the memory buffer area based on the writing time. In this way, the write time of each first storage data written into the memory buffer may be recorded, and further, in the process of determining the splicing order corresponding to the plurality of first storage data written into the memory buffer based on the write time, the first storage data with the longer write time from the current time is configured with the splicing order that is further ahead. The current time is a time when the splicing order of the first storage data starts to be determined, and the longer the corresponding write time is from the current time, the longer the buffer time in the memory buffer is. Illustratively, the buffer duration of the first stored data a1 from the writing into the memory buffer to the current time is 1 second, and the buffer duration of the first stored data a2 from the writing into the memory buffer to the current time is 0.5 second, then the buffer duration corresponding to the first stored data a1 is longer than the buffer duration corresponding to the first stored data a2, which further means that the duration of the writing time of the first stored data a1 from the current time is longer than the duration of the writing time of the first stored data a2 from the current time.
It should be noted that, in the foregoing manner of determining the splicing order based on the service types, it is possible that the service types corresponding to a plurality of first storage data are all the same, and for the first storage data whose corresponding service types are all the same, the corresponding splicing order may be determined by combining the write time. Optionally, for the first stored data with the same service type, the longer the corresponding write-in time distance is from the current time, the earlier the corresponding splicing order is. For example, taking the first storage data including the first storage data a1, the first storage data a2, the first storage data a3 and the first storage data a4 as an example, if the traffic types corresponding to the first storage data a1 and the first storage data a2 are traffic type e1, the traffic types corresponding to the first storage data a3 and the first storage data a4 are e2, and the priority corresponding to the traffic type e1 is higher than the priority corresponding to the traffic type e 1. Furthermore, the writing time corresponding to the first stored data a2 is longer than the current time from the current time than the writing time corresponding to the first stored data a1, and the writing time corresponding to the first stored data a3 is longer than the writing time corresponding to the first stored data a4, furthermore, firstly, according to the service type, the splicing order of the first storage data a1 and the first storage data a2 is determined to be earlier than that of the first storage data a3 and the first storage data a4, and then, in combination with the determination of the writing time, the splicing order of the first storage data a2 is determined to be earlier than that of the first storage data a1, the splicing order of the first storage data a3 is determined to be earlier than that of the first storage data a4, the determined splicing order is a storage data a2, a first storage data a1, a first storage data a3 and a first storage data a4 from front to back.
S230: and sequentially splicing the plurality of first storage data written into the memory buffer area based on the splicing sequence to obtain second storage data, wherein when the second storage data are written into the hard disk, the first storage data with the earlier splicing sequence have higher priority to execute writing operation.
In the process of writing the data in the memory buffer area to the hard disk, the write operation may be performed based on the storage instruction, and if the operation of writing the data to the hard disk is directly performed without splicing the first storage data, the storage instruction is performed once for each first storage data. Where each store instruction may have an instruction header and an instruction trailer, the actual stored data would be between the instruction header and the instruction trailer. Taking the first storage data a1 and the first storage data a2 as an example, if the first storage data a1 and the first storage data a2 are not spliced, as shown in the upper part of fig. 9, a storage instruction is executed for the first storage data a1 and the first storage data a2, respectively, and if the first storage data a1 and the first storage data a2 are spliced, as shown in the lower part of fig. 8, the first storage data a1 and the first storage data a2 can be written into the hard disk only by executing the storage instruction once.
S240: and writing the second storage data into the hard disk.
S250: and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into the memory queue.
As one mode, when the first storage data is detected, after storing the first storage data in the memory buffer, the method further includes: enabling a storage caller who generates the first write data to be in a blocking state; when the write-in execution condition is satisfied, after writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk, the method further comprises: and after the second storage data is successfully written into the hard disk, enabling the storage calling party in the blocking state to remove the data blocking state so as to return a message of successful writing.
The storage caller in the blocking state can be understood as a state waiting for the storage result, and then after the second storage data is written into the hard disk, the system component or the server executing the write operation can remove the blocking state of the data caller, and further return a message of successful write to the storage caller. It should be noted that, a system component or a server may allocate a thread to each storage caller who has sent a data storage request to perform an operation of writing corresponding first storage data into a memory buffer, so that the foregoing storage caller who has generated the first write data is in a blocking state, which may be understood as causing a thread corresponding to the storage caller who has generated the first write data to be in the blocking state, and correspondingly causing the storage caller who is in the blocking state to release the data blocking state may be understood as causing a thread corresponding to the storage caller who is in the blocking state to release the blocking state.
For example, as shown in fig. 10, after the first storage data corresponding to the storage caller u1, the storage caller u2, and the storage caller u3 are written into the memory buffer 60, the storage caller u1, the storage caller u2, and the storage caller u3 are all in a blocking state, and then the second storage data b1 is successfully written into the file system 70 in the hard disk, which triggers the storage caller u1, the storage caller u2, and the storage caller u3 to release the blocking state.
As a mode, after the second storage data is successfully written into the hard disk, the step of storing the first storage data written into the memory buffer area into the memory queue further includes: and deleting the first storage data written into the memory buffer area from the memory buffer area.
As a mode, after the second storage data is successfully written into the hard disk, the step of storing the first storage data written into the memory buffer area into the memory queue further includes: and deleting the first storage data taken out from the memory queue from the hard disk after the first storage data are taken out from the memory queue. The first storage data written into the memory buffer area is actively deleted from the memory buffer area, which is beneficial to more timely cleaning useless data in the memory buffer area so as to reduce the power consumption consumed for maintaining data storage. The useless data can be understood as data that has been written to the hard disk. For example, as shown in fig. 11, the first storage data a1, the first storage data a2 and the first storage data a3 shown in fig. 10 are written into the memory queue 80 after being written from the memory buffer to the hard disk. Then when there is data in the memory queue 80 fetched, for example, the first storage data a1 fetched therein, the first storage data a1 is also deleted from the file system 70, so as to recycle the occupied hard disk space.
According to the data storage method provided by the embodiment, a plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that one-time data writing operation into the hard disk is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the number of times of writing into the hard disk is reduced. In addition, the mechanical hard disk locates the data writing position based on the mechanical movement of the magnetic head in the process of writing data, so that the times and the movement distance of the mechanical movement of the magnetic head triggered by the hard disk are reduced under the condition of reducing the times of writing the data into the hard disk, and the performance of writing the data into the hard disk is improved. In addition, in this embodiment, when the first storage data is spliced, the splicing order of each first storage data is also obtained first, so that the splicing is performed according to the splicing order of each first storage data, so as to improve flexibility in the combining process.
Referring to fig. 12, fig. 12 is a flowchart illustrating a data storage method according to an embodiment of the present application, where the method includes:
s310: responding to a data storage request, and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party.
S320: when the first storage data is stored in the memory buffer area, the splicing sequence corresponding to the first storage data written in the memory buffer area is obtained.
In this embodiment, different from the foregoing embodiment, in the foregoing embodiment, when it is detected that the write execution condition is satisfied, the obtaining of the splicing order of each first storage data is started to perform the splicing operation, and in this embodiment, when the first storage data is written into the memory buffer, the splicing order may be configured for the written first storage data, and the splicing operation may be performed.
S330: and sequentially splicing the first storage data stored in the memory buffer area based on the splicing sequence, wherein when the second storage data is written into the hard disk, the first storage data which is more advanced in the splicing sequence is preferentially written into the hard disk.
In this embodiment, the splicing operation may be performed immediately after the splicing order of the first storage data is obtained, and the splicing operation does not need to be performed when the write execution condition is satisfied, so that the efficiency of writing to the hard disk may be improved. Then in this manner, the splicing order for the first stored data written later into the memory buffer does not have to be later.
Then, as one way, when there is the first storage data written into the memory buffer, the splicing order of all the first storage data written before is also updated, and splicing is performed after the updating. For example, if the first storage data a1 and the first storage data a2 are received earlier when the first storage data a3 is received, and the first storage data a2 is spliced later according to the splicing order in which the first storage data a1 is earlier, the splicing order of the first storage data a1 and the first storage data a2 is re-determined after the first storage data a3 is received, and the first storage data a3 is spliced according to the order of the first storage data a1, the first storage data a3 and the first storage data a2 when the splicing order of the first storage data a3 is determined to be earlier than the first storage data a 2.
Alternatively, if the number of the first storage data is large, the splicing order of all the previous first storage data is updated again after each time the first storage data is written into the memory buffer, which results in a large amount of data calculation. In order to avoid increasing too much data calculation amount, when the first storage data is written, the written first storage data can be compared with the splicing order of the first storage data at the tail end of the current splicing order, and the first storage data is updated according to the comparison result. Illustratively, the first storage data a1 and the first storage data a2 have been received previously, and the first storage data a2 has been spliced in the splicing order in which the first storage data a1 is received previously and the first storage data a2 is later, then after the first storage data a3 is received, the splicing order of the first storage data a3 and the first storage data a2 is compared again if the first storage data a2 at the end of the current splicing order is determined.
S340: and when the write-in execution condition is met, writing the spliced second storage data into a hard disk, wherein the hard disk is a mechanical hard disk.
S350: and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into the memory queue.
According to the data storage method provided by the embodiment, a plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that one-time data writing operation into the hard disk is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the number of times of writing into the hard disk is reduced. In addition, in this embodiment, the corresponding splicing order may be obtained for splicing when the first storage data is written into the memory buffer, and then the operation of writing into the hard disk may be directly executed without performing the splicing operation when the write-in execution condition is satisfied, so as to improve the write-in efficiency.
Referring to fig. 13, fig. 13 is a flowchart illustrating a data storage method according to an embodiment of the present application, where the method includes:
s410: and responding to the data storage request in the current data storage period, and storing the first storage data requested to be stored into the memory buffer area.
S420: and when the write-in execution condition of the current data storage period is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area in the current data storage period into the hard disk.
Optionally, in this embodiment, the first storage data combination is performed periodically. The period may be divided based on time, or may be divided according to the number or the data amount. And when the splicing operation is executed after the write execution condition of the current data storage cycle is met, entering the next data storage cycle. For example, the period may be one period every 10 seconds, and the period may be one period every 3 first storage data are written into the memory buffer.
S430: and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into the memory queue.
According to the data storage method provided by the embodiment, a plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that one-time data writing operation into the hard disk is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the number of times of writing into the hard disk is reduced. In addition, the mechanical hard disk locates the data writing position based on the mechanical movement of the magnetic head in the process of writing data, so that the times and the movement distance of the mechanical movement of the magnetic head triggered by the hard disk are reduced under the condition of reducing the times of writing the data into the hard disk, and the performance of writing the data into the hard disk is improved.
Referring to fig. 14, fig. 14 is a flowchart illustrating a data storage method according to an embodiment of the present application, where the method includes:
s510: the dispatched task is received.
Alternatively, the task may be a data processing task.
S520: and generating a data storage request corresponding to the task.
It should be noted that processing of a task needs to consume processing resources, and when the processing resources are in a relatively short or insufficient amount, the received task may not be processed in time, and the task that cannot be processed in time may be persistently stored. Optionally, the data storage request is a data storage request for performing persistent storage on a task that cannot be processed in time.
S530: and responding to the data storage request, and storing the task requesting to be stored into the memory buffer area as first storage data.
S540: and when the write-in execution condition is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk, wherein the hard disk is a mechanical hard disk.
S550: and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into the memory queue.
When the task stored in the memory queue can be processed, the task to be executed may be taken out from the memory queue first. And simultaneously, the tasks to be executed in the memory queue are taken out from the memory queue, and the tasks to be executed in the memory queue are deleted from the hard disk.
According to the data storage method provided by the embodiment, when the received task is processed, the task is stored in the memory buffer area as the first storage data, then the multiple tasks are combined to obtain the second storage data when the write-in execution condition is met, and then the multiple tasks are written into the hard disk at one time, so that the performance of writing into the hard disk in the process of performing persistent storage on the task is improved.
It should be noted that, in one environment configuration, each time 4KB of data is written into the hard disk, 8 users (storage callers) call and execute Operations of writing into the hard disk multiple times at the same time, the IOPS (Input/Output Operations Per Second) of the relevant persistent queue write interface is 20, and the maximum delay of the write request is degraded to 40 seconds.
Under the same environment configuration, in the data storage method provided in the basic application embodiment, 8 users (storage callers) simultaneously invoke operations written into the hard disk for multiple times, the IOPS of the persistent queue write interface is 190, and the maximum delay of the write request is 393 milliseconds. 64 users (storage callers) simultaneously invoke the operation of writing to the hard disk for multiple times, the IOPS of the write interface of the persistence queue is 1104, and the maximum delay of the write request is 500 milliseconds. 1024 users (storage callers) simultaneously invoke the operation of writing to the hard disk for many times, the IOPS of the persistent queue write interface is 9402, and the maximum delay of the write request is 532 milliseconds.
Referring to fig. 15, fig. 15 is a block diagram illustrating a data storage device 800 according to an embodiment of the present application, the device 800 including:
the data buffer unit 810 is configured to respond to a data storage request, store first storage data requested to be stored in a memory buffer area, where the first storage data is data to be stored in a hard disk corresponding to a storage calling party;
a persistent write unit 820, configured to write, when a write execution condition is met, second storage data obtained by combining a plurality of first storage data written in the memory buffer into a hard disk, where the hard disk is a mechanical hard disk;
the memory writing unit 830 is configured to store the first storage data written in the memory buffer into the memory queue after the second storage data is successfully written in the hard disk.
As one mode, the persistent write unit 820 is specifically configured to combine, when the write execution condition is met, the plurality of first storage data written into the memory buffer into second storage data based on the group commit mode, and write the second storage data into the hard disk.
As a manner, the persistent write unit 820 is specifically configured to, when the write execution condition is met, obtain a splicing order corresponding to the plurality of first storage data written into the memory buffer; sequentially splicing a plurality of first storage data written into the memory buffer area to obtain second storage data based on the splicing sequence, wherein when the second storage data are written into the hard disk, the first storage data with the earlier splicing sequence have the higher priority to execute writing operation; and writing the second storage data into the hard disk.
As a manner, the persistent write unit 820 is specifically configured to, when there is a first storage data stored in the memory buffer, obtain a splicing order corresponding to a plurality of first storage data written in the memory buffer; sequentially splicing the first storage data stored in the memory buffer area based on the splicing sequence, wherein when the second storage data is written into the hard disk, the first storage data with the more front splicing sequence has the higher priority to execute the writing operation; and when the write-in execution condition is met, writing the spliced second storage data into the hard disk.
Optionally, the persistent writing unit 820 is specifically configured to obtain a service type corresponding to the first storage data written in the memory buffer; and determining a splicing order corresponding to the first storage data written into the memory buffer area based on the service type.
Optionally, the persistent writing unit 820 is specifically configured to obtain a writing time for writing the first storage data into the memory buffer; and determining a splicing order corresponding to the plurality of first storage data written into the memory buffer area based on the writing time, wherein the earlier the corresponding writing time is, the earlier the corresponding splicing order is.
By one approach, the data buffer unit 810 is specifically configured to respond to a data storage request in the current data storage period, and store the first storage data requested to be stored to the memory buffer. In this manner, the persistent writing unit 820 is specifically configured to write, to the hard disk, the second storage data obtained by combining the plurality of first storage data written to the memory buffer in the current data storage cycle when the write execution condition in the current data storage cycle is satisfied.
Optionally, the write execution condition includes at least one of the following conditions: the quantity of the first storage data stored in the memory buffer area meets a quantity threshold value; the data volume of the first storage data stored in the memory buffer area meets a data volume threshold value; and the expiration time to the current data write cycle.
As shown in fig. 16, the apparatus 800 further comprises: the block control unit 840 is configured to, when the first storage data is detected, store the first storage data in the memory buffer, and then enable the storage caller that generates the first write data to be in a block state. The blocking control unit 840 is further configured to, after writing second storage data obtained by combining the plurality of first storage data written into the memory buffer into the hard disk, enable the storage caller in the blocking state to release the data blocking state after the second storage data is successfully written into the hard disk, so as to return a message that the writing is successful.
The storage data management unit 850 is configured to delete the first storage data written in the memory buffer from the memory buffer after the second storage data is successfully written in the hard disk and the first storage data written in the memory buffer is stored in the memory queue. And the memory controller is further used for deleting the first storage data taken out from the memory queue from the hard disk after the first storage data written into the memory buffer area is stored into the memory queue after the second storage data is successfully written into the hard disk and the first storage data taken out from the memory queue is taken out from the memory queue.
The data storage device responds to a data storage request, first storage data requested to be stored in a hard disk is stored in a memory buffer area, then when a write-in execution condition is met, second storage data obtained by combining a plurality of first storage data written in the memory buffer area are written in the hard disk, and then after the second storage data are successfully written in the hard disk, the first storage data written in the memory buffer area are stored in a memory queue. Therefore, the plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that the operation of writing data into the hard disk once is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the times of writing the second storage data into the hard disk are reduced. In addition, the mechanical hard disk locates the data writing position based on the mechanical movement of the magnetic head in the process of writing data, so that the times and the movement distance of the mechanical movement of the magnetic head triggered by the hard disk are reduced under the condition of reducing the times of writing the data into the hard disk, and the performance of writing the data into the hard disk is improved.
It should be noted that the device embodiment and the method embodiment in the present application correspond to each other, and specific principles in the device embodiment may refer to the contents in the method embodiment, which is not described herein again.
An electronic device provided by the present application will be described below with reference to fig. 17.
Referring to fig. 17, based on the data storage method, another electronic device 200 including a processor 104 capable of executing the data storage method is further provided in the embodiment of the present application. The electronic device 200 also includes a memory 104 and a network module 106. The memory 104 stores programs that can execute the content of the foregoing embodiments, and the processor 102 can execute the programs stored in the memory 104.
The processor 102, which is coupled to various components throughout the electronic device 200 using various interfaces and lines, performs various functions of the electronic device 200 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 104 and invoking data stored in the memory 104. Alternatively, the processor 102 may be implemented in hardware using at least one of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 102 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing display content; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 102, but may be implemented by a communication chip.
The Memory 104 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). The memory 104 may be used to store instructions, programs, code sets, or instruction sets. The memory 104 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing various method embodiments described below, and the like. The storage data area may also store data created by the terminal 100 in use, such as a phonebook, audio-video data, chat log data, and the like.
The network module 106 is configured to receive and transmit electromagnetic waves, and implement interconversion between the electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices, for example, an audio playing device. The network module 106 may include various existing circuit elements for performing these functions, such as an antenna, a radio frequency transceiver, a digital signal processor, an encryption/decryption chip, a Subscriber Identity Module (SIM) card, memory, and so forth. The network module 106 may communicate with various networks, such as the internet, an intranet, a wireless network, or with other devices via a wireless network. The wireless network may comprise a cellular telephone network, a wireless local area network, or a metropolitan area network. For example, the network module 106 may interact with a base station.
Referring to fig. 18, a block diagram of a computer-readable storage medium according to an embodiment of the present application is shown. The computer-readable medium 1100 has stored therein program code that can be called by a processor to perform the method described in the above-described method embodiments.
The computer-readable storage medium 1100 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer-readable storage medium 1100 includes a non-volatile computer-readable storage medium. The computer readable storage medium 1100 has storage space for program code 1110 for performing any of the method steps of the method described above. The program code can be read from or written to one or more computer program products. The program code 1110 may be compressed, for example, in a suitable form.
Embodiments of the present application also provide a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data storage method.
In summary, according to the data storage method, the data storage device, the electronic device, and the storage medium provided by the present application, in response to a data storage request, first storage data requested to be stored in a hard disk is first stored in a memory buffer, and then when a write-in execution condition is satisfied, second storage data obtained by combining a plurality of first storage data written in the memory buffer is written in the hard disk, and then when the second storage data is successfully written in the hard disk, the first storage data written in the memory buffer is stored in a memory queue. Therefore, the plurality of first storage data written into the memory buffer area are combined to obtain one second storage data, so that the operation of writing data into the hard disk once is realized, the plurality of first storage data combined to obtain the second storage data can be written into the hard disk, and the times of writing the second storage data into the hard disk are reduced. In addition, the mechanical hard disk locates the data writing position based on the mechanical movement of the magnetic head in the process of writing data, so that the times and the movement distance of the mechanical movement of the magnetic head triggered by the hard disk are reduced under the condition of reducing the times of writing the data into the hard disk, and the performance of writing the data into the hard disk is improved.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it will 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; such modifications and substitutions do not necessarily depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (14)

1. A method of data storage, the method comprising:
responding to a data storage request, and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party;
when the write-in execution condition is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk, wherein the hard disk is a mechanical hard disk;
and when the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer area into a memory queue.
2. The method according to claim 1, wherein writing, when the write execution condition is satisfied, second storage data, which is a combination of a plurality of first storage data written into the memory buffer, into the hard disk, comprises:
and when the write-in execution condition is met, combining the plurality of first storage data written into the memory buffer area into second storage data based on a group submission mode, and writing the second storage data into the hard disk.
3. The method according to claim 1, wherein writing, when the write execution condition is satisfied, second storage data, which is a combination of a plurality of first storage data written into the memory buffer, into the hard disk, comprises:
when the write-in execution condition is met, acquiring a splicing sequence corresponding to a plurality of first storage data written into the memory buffer area;
sequentially splicing a plurality of first storage data written into the memory buffer area based on the splicing sequence to obtain second storage data, wherein when the second storage data are written into the hard disk, the first storage data with the more front splicing sequence have higher priority to execute writing operation;
and writing the second storage data into the hard disk.
4. The method according to claim 1, wherein writing, when the write execution condition is satisfied, second storage data, which is a combination of a plurality of first storage data written into the memory buffer, into the hard disk, comprises:
when first storage data are stored in a memory buffer area, acquiring a splicing sequence corresponding to a plurality of first storage data written in the memory buffer area;
sequentially splicing the first storage data stored in the memory buffer area based on the splicing sequence, wherein when the second storage data is written into the hard disk, the first storage data with the earlier splicing sequence has the higher priority to execute writing operation;
and when the write-in execution condition is met, writing the spliced second storage data into the hard disk.
5. The method according to claim 3 or 4, wherein the obtaining the splicing order corresponding to the first storage data written into the memory buffer comprises:
acquiring a service type corresponding to first storage data written into the memory buffer area;
and determining a splicing sequence corresponding to the first storage data written into the memory buffer area based on the service type.
6. The method according to claim 3 or 4, wherein the obtaining the splicing order corresponding to the first storage data written into the memory buffer comprises:
acquiring the writing time of the first storage data written into the memory buffer area;
and determining a splicing order corresponding to the plurality of first storage data written into the memory buffer area based on the writing time, wherein the earlier the corresponding writing time is, the earlier the corresponding splicing order is.
7. The method of claim 1, wherein storing the first storage data requested to be stored to the memory buffer in response to the data storage request comprises: responding to a data storage request in a current data storage period, and storing first storage data requested to be stored into a memory buffer area;
when the write-in execution condition is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk, wherein the writing-in execution condition comprises the following steps: and when the write-in execution condition of the current data storage period is met, writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area in the current data storage period into the hard disk.
8. The method according to any of claims 1-6, wherein the write execution condition comprises at least one of:
the quantity of the first storage data stored in the memory buffer area meets a quantity threshold value;
the data volume of the first storage data stored in the memory buffer area meets a data volume threshold; and
the expiration time of the current data write cycle is reached.
9. The method of claim 1, wherein storing the first stored data to the memory buffer when the first stored data is detected further comprises: enabling a storage caller who generates the first write data to be in a blocking state;
when the write-in execution condition is met, after writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk, the method further comprises: and when the second storage data is successfully written into the hard disk, enabling the storage calling party in the blocking state to release the data blocking state so as to return a message of successful writing.
10. The method of claim 1, wherein after the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer into a memory queue further comprises:
and deleting the first storage data written into the memory buffer area from the memory buffer area.
11. The method of claim 1, wherein after the second storage data is successfully written into the hard disk, storing the first storage data written into the memory buffer into a memory queue further comprises:
and deleting the first storage data taken out from the memory queue from the hard disk after the first storage data are taken out from the memory queue.
12. A data storage device, characterized in that the device comprises:
the data buffer unit is used for responding to a data storage request and storing first storage data requested to be stored into a memory buffer area, wherein the first storage data is data to be stored into a hard disk corresponding to a storage calling party;
the persistent write-in unit is used for writing second storage data obtained by combining a plurality of first storage data written into the memory buffer area into the hard disk when a write-in execution condition is met, wherein the hard disk is a mechanical hard disk;
and the memory writing unit is used for storing the first storage data written into the memory buffer area into a memory queue after the second storage data is successfully written into the hard disk.
13. An electronic device comprising a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the methods of claims 1-11.
14. A computer-readable storage medium, having program code stored therein, wherein the program code when executed by a processor performs the method of any of claims 1-11.
CN202011016833.9A 2020-09-24 2020-09-24 Data storage method and device, electronic equipment and storage medium Pending CN112099736A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011016833.9A CN112099736A (en) 2020-09-24 2020-09-24 Data storage method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011016833.9A CN112099736A (en) 2020-09-24 2020-09-24 Data storage method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112099736A true CN112099736A (en) 2020-12-18

Family

ID=73755344

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011016833.9A Pending CN112099736A (en) 2020-09-24 2020-09-24 Data storage method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112099736A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113407550A (en) * 2021-08-19 2021-09-17 支付宝(杭州)信息技术有限公司 Data storage and query method, device and database system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113407550A (en) * 2021-08-19 2021-09-17 支付宝(杭州)信息技术有限公司 Data storage and query method, device and database system

Similar Documents

Publication Publication Date Title
EP3547715A1 (en) Method and apparatus for reducing continuous-wakeup delay of bluetooth loudspeaker, and bluetooth loudspeaker
AU2019256257B2 (en) Processor core scheduling method and apparatus, terminal, and storage medium
CN111200606A (en) Deep learning model task processing method, system, server and storage medium
WO2021179156A1 (en) Message processing method, device and system, and server
CN112099736A (en) Data storage method and device, electronic equipment and storage medium
CN113014608A (en) Flow distribution control method and device, electronic equipment and storage medium
CN111107147B (en) Message pushing method and device
CN110502631B (en) Input information response method and device, computer equipment and storage medium
CN111338710A (en) Application program control method and device, electronic equipment and storage medium
CN111274047A (en) Information processing method, terminal, system, computer device and storage medium
CN110719232A (en) Data transmission method and device, mobile terminal and storage medium
CN109766347B (en) Data updating method, device, system, computer equipment and storage medium
CN111813529B (en) Data processing method, device, electronic equipment and storage medium
CN114363268B (en) Message delay consumption method and related product
CN107168648B (en) File storage method and device and terminal
CN107124353B (en) Message processing method and device, computer device and storage medium
CN114710482A (en) File detection method and device, electronic equipment and storage medium
CN114374657A (en) Data processing method and device
CN114071192A (en) Information acquisition method, terminal, server, electronic device, and storage medium
CN108829824B (en) Resource processing method and device in internet operation activity
CN112245906A (en) Data synchronization method and device, electronic equipment and storage medium
CN106790428B (en) Data transmission method and device
CN111158725B (en) Program upgrading method, device, terminal and storage medium
CN108595281B (en) Moving object processing method, moving object processing device, storage medium and terminal
CN114221940B (en) Audio data processing method, system, device, equipment and 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