Method, device and electronic device for reading disk data of cache disk

By obtaining the historical request time delay of the cache server in the distributed file system, calculating the average request time delay and read ratio, and prioritizing reading files from the cache server, the problem of excessive use of mechanical disks is solved, the service life of mechanical disks is extended, and data security is improved.

CN113971161BActive Publication Date: 2025-09-26SHENZHEN IPANEL TECH LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010710344.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-22
Publication Date
2025-09-26
Estimated Expiration
2040-07-22

AI Technical Summary

Technical Problem

In the existing technology, the reading methods of cache servers and disk servers fail to effectively distinguish task loads, resulting in excessive use of mechanical disks, shortening their service life and affecting data security.

Method used

By obtaining the historical request time delay of the cache server, calculating the average request time delay and read ratio, we can prioritize reading files from the cache server and reduce the number and time of reading from the mechanical disk.

Benefits of technology

It effectively reduces the read tasks of the disk server, extends the service life of the mechanical disk and improves data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113971161B_ABST
    Figure CN113971161B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, and electronic device for reading disk data. The method and device are applied to a distributed file system. Specifically, when a cache server stores a file required by a user, at least one historical request time delay of the cache server is obtained; and based on the historical request time delay, the file is read from the cache server, or from the cache server and the disk server. That is, the file is read from the cache server first. In this way, the number of times and time the disk server is read can be reduced, thereby effectively reducing the reading task and avoiding a negative impact on the service life of the mechanical disk in the disk server and the security of its data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a method, device, and electronic device for reading disk data from a cache disk. Background Art

[0002] In a distributed file system, files on a mechanical hard drive are snapshotted to one or more cache disks based on their full or partial hotness or coldness. Cache disks generally use solid-state drives (SSDs) with faster access speeds. In addition to fast read and write speeds, SSDs also offer the advantage of avoiding mechanical wear.

[0003] When current file operating systems read files based on user requests, they balance reads across all cache servers and disk servers as a single request. This means that, based on the latency of the cache servers and the latency of the disk servers, when a data read request arrives, the server with the shorter latency is read, regardless of which server is prioritized. The disks in cache servers are typically solid-state drives with fast read and write speeds, while the disks in disk servers are typically mechanical drives with better data security.

[0004] After actual testing, it was found that the number of times the cache server and disk server were read using this reading method was basically the same, that is, the mechanical disk in the disk server also needs to undertake a large number of reading tasks. The mechanical disk will continue to wear during non-stop work, which will not only reduce its service life, but also endanger the security of the data itself due to disk wear. Summary of the Invention

[0005] In view of this, the present application provides a method, device and electronic device for reading disk data of a cache disk, which are used to avoid excessive reading operations on a mechanical disk, so as to avoid negative impacts on the service life of the mechanical disk and the security of its data.

[0006] In order to achieve the above objectives, the following solutions are proposed:

[0007] A method for reading disk data from a cache disk is applied to a distributed file system, wherein the distributed file system includes a cache server and a disk server, and the disk server includes at least one cache disk. The method comprises the following steps:

[0008] In a case where the cache server stores the file required by the user, obtaining at least one historical request time delay of the cache server;

[0009] The file is read from the cache server, or from the cache server and the disk server according to the historical request time delay.

[0010] Optionally, the reading of the file from the cache server, or from the cache server and the disk server according to the historical request time delay, comprises the steps of:

[0011] Calculating an average request time delay based on the historical request time delays;

[0012] When the average request time delay is less than or equal to a first preset value, reading the file from the cache server according to a read request of the user;

[0013] When the average request time delay is greater than the first preset value, calculating the read ratio according to the average request time delay;

[0014] The file is read from the cache server and the disk server respectively according to the read request and the read ratio.

[0015] Optionally, the calculating the average request time delay based on the historical time delay comprises the steps of:

[0016] If the historical request time delay is unique, taking the historical request time delay as the average request time delay;

[0017] If the historical request time delay is not unique, all the acquired historical request time delays are averaged to obtain the average request time delay.

[0018] Optionally, reading the file from the cache server according to the user's read request includes the following steps:

[0019] Obtaining the cache address and cache offset address of the file in the cache server;

[0020] The file is read from the cache server according to the cache address and the cache offset address.

[0021] Optionally, calculating the read ratio according to the average request time delay includes:

[0022] Calculating a difference between the average request time delay and the first preset value;

[0023] The reading ratio is determined based on the difference, and the reading ratio includes a first ratio and a second ratio, the first ratio being the ratio of the amount of data read from the cache server to the total amount of data of the file, and the second ratio being the ratio of the amount of data read from the hard disk server to the total amount of data, and the first ratio being greater than or equal to a second preset value.

[0024] Optionally, the second preset value is 50%.

[0025] Optionally, reading the file from the cache server and the disk server respectively according to the read request and the read ratio includes the steps of:

[0026] Acquire a cache address and a cache offset address of the file in the cache server, and a disk offset address and a disk offset address of the file in the disk server according to the read ratio;

[0027] Reading first data from the cache server according to the cache address and the cache offset address;

[0028] Reading second data from the disk server according to the disk address and the disk offset address;

[0029] The first data and the second data are concatenated into the file.

[0030] Optionally, the following steps may also be included:

[0031] The request time delay to the cache server is recorded as the historical request time delay.

[0032] A device for reading disk data from a cache disk is applied to a distributed file system. The distributed file system includes a cache server and a disk server. The disk server includes at least one cache disk. The reading method includes:

[0033] a parameter acquisition module, configured to acquire at least one historical request time delay of the cache server when the cache server stores the file required by the user;

[0034] A reading control module is configured to read the file from the cache server, or from the cache server and the disk server, according to the historical request time delay.

[0035] Optionally, the reading control module includes:

[0036] a first calculation unit, configured to calculate an average request time delay based on the historical request time delays;

[0037] a first reading unit, configured to read the file from the cache server according to a read request of a user when the average request time delay is less than or equal to a first preset value;

[0038] a second calculation unit, configured to calculate a read ratio according to the average request time delay when the average request time delay is greater than the first preset value;

[0039] The second reading unit is configured to read the file from the cache server and the disk server respectively according to the read request and the read ratio.

[0040] Optionally, also include:

[0041] A parameter recording unit is configured to record a request delay time to the cache server as the historical request time delay.

[0042] An electronic device, optionally provided with the reading device as described above.

[0043] An electronic device, optionally comprising at least one processor and a memory connected to the processor, wherein:

[0044] The memory is used to store computer programs or instructions;

[0045] The processor is used to obtain and execute the computer program or instruction, so that the electronic device can implement the reading method as described above.

[0046] It can be seen from the above technical solution that the present application discloses a method, device and electronic device for reading disk data of a cache disk. The method and device are applied to a distributed file system. Specifically, when a cache server stores files required by a user, at least one historical request time delay of the cache server is obtained; files are read from the cache server, or from the cache server and the disk server according to the historical request time delay. That is, files are read from the cache server first. In this way, the number of times and time that the disk server is read can be reduced, thereby effectively reducing the reading task and avoiding negative impacts on the service life of the mechanical disk in the disk server and the security of its data. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0048] Figure 1 This is a flowchart of a method for reading disk data from a cache disk according to an embodiment of the present application;

[0049] Figure 2 This is a flowchart of a file reading embodiment of the present application;

[0050] Figure 3 This is another flowchart of reading a file according to an embodiment of the present application;

[0051] Figure 4 A block diagram of a device for reading disk data from a cache disk according to an embodiment of the present application;

[0052] Figure 5 A block diagram of another device for reading disk data from a cache disk according to an embodiment of the present application;

[0053] Figure 6 A block diagram of a device for reading disk data from a cache disk according to another embodiment of the present application;

[0054] Figure 7 This is a block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0056] Example 1

[0057] Figure 1 This is a flowchart of a method for reading disk data from a cache disk according to an embodiment of the present application.

[0058] The reading method provided in this embodiment is applied to a distributed file system, which includes at least a cache server and a disk server. The cache server is used to store cache metadata information about files. The cache metadata is file description information, which describes the storage blocks on which server the file fragments are stored. The file fragment information includes the disk's IP address, disk number, data offset on the disk, and data block size.

[0059] A disk server is a server used to manage disks and provide disk read and write services. Each disk has a unique disk address in the disk server.

[0060] like Figure 1 As shown, the disk data reading method provided in this embodiment specifically includes the following steps:

[0061] S1. Get the historical request time delay of the cache server.

[0062] That is, when a user sends a data request through the data module of the distributed file system, the system determines whether the file is stored in the cache server. If the file is not in the cache server, the system directly queries the hard disk address and offset address of the file in the hard disk server from the information management server of the system, and then directly reads the file based on the hard disk address and offset address.

[0063] If the file is stored in the cache server, at least one historical request time delay of the cache server is read for the file. In a specific embodiment of the present application, the historical request time delays are stored in an array, the array including multiple data elements, each array element storing a historical request time delay.

[0064] When the historical request time delay is obtained, all historical request time delays in the data are obtained.

[0065] In the distributed file system's data module, at startup, the cache disk array is initialized to 20 elements. POS is set as the array cursor, starting at 0 and with a maximum cursor size equal to the number of elements in the array minus 1. This array is a circular array. After POS points to the largest element, it starts again at 0, looping endlessly to record the request latency of the cache server's disk corresponding to the current IP address.

[0066] The variable count records the number of recent requests to this IP address. The default value is 0 and the maximum value is the number of elements in the array. If count is less than the number of elements in the array, count is incremented by 1 each time a delay is recorded until count equals the number of elements in the array.

[0067] S2. Delay reading the file based on the historical request time.

[0068] Specifically, the file is read from the cache server alone based on the historical request delay, or the file is read from the cache server and the hard disk server in proportion based on the historical request delay. That is, the file is read from the cache server first.

[0069] As can be seen from the above technical solution, this embodiment provides a method for reading disk data, which is applied to a distributed file system. Specifically, when a cache server stores a file required by a user, at least one historical request time delay of the cache server is obtained; based on the historical request time delay, the file is read from the cache server, or from the cache server and the disk server. In other words, files are read preferentially from the cache server. This reduces the number of times and the time required to read the disk server, effectively reducing the number of read requests and avoiding negative impacts on the service life of the mechanical disk in the disk server and the security of the data.

[0070] In a specific embodiment of the present application, the delayed reading of files according to the historical request time is realized by the following method: Figure 2 shown.

[0071] S201. Calculate the average request time delay based on historical request time delays;

[0072] As can be seen from the previous description, this system can record 20 historical request time delays. In order to ensure the accuracy of the solution, it is necessary to calculate based on multiple historical request time delays to obtain the average request time delay.

[0073] Specifically, if only one historical request time delay is stored in the array, the unique historical request time delay is used as the economic request time delay; if the historical request time delay is not unique, multiple elements in the array, that is, multiple historical request time delays, are averaged to obtain the average request time delay.

[0074] After obtaining the average request time delay, the average request time delay is compared with a first preset value. The first preset value may be 400ms. If the average request time delay is equal to or less than the first preset value, step S202 is executed; if the average request time delay is greater than the first preset value, step S203 is executed.

[0075] S202, reading a file from a cache server according to a user's read request;

[0076] That is, if the average request time delay is equal to or less than the first preset value, then when a read request is received from the user, the file is read only from the cache server's disk. In other words, at this time, only the cache server's solid-state drive can meet the delay requirement.

[0077] During actual reading, the cache address and cache offset address of the file in the cache server are first obtained; then, the actual cache disk is determined according to the cache address, and the file is read from the cache disk according to the cache offset address.

[0078] S203, calculating the read ratio according to the average request time delay;

[0079] That is, if the average request time delay is greater than the first preset value, the file is no longer read only from the cache server. At this time, the reading ratio is calculated according to the average request time delay, so that the reading ratio is used as the basis for the next step of reading.

[0080] During actual calculation, the difference between the average request time delay and the first preset value is first calculated, and then the read ratio is determined based on the difference.

[0081] The read ratio includes a first ratio and a second ratio, the sum of which equals 100%. The first ratio is the ratio of the amount of data read from the cache server to the total amount of data in the file to be read, and the second ratio is the ratio of the amount of data read from the disk server to the total amount of data. Generally speaking, the first ratio is greater than the second preset value, which is generally greater than 50%, to ensure that files are read preferentially from the cache server.

[0082] If the average request time delay average in this calculation is less than or equal to 400ms, then this request will continue to read from the cache disk. If average is greater than 400ms, we use the preset step size to determine whether to read from the cache disk or the mechanical hard disk. Assuming our step size is 20ms, the number of times we read from the cache disk decreases by 5% with each step. Until the second preset value. We set the second preset value to 50%. That is, in the worst case, 50% of the requests are read from the cache disk, and the other 50% of the requests are read from the mechanical hard disk.

[0083] If the cache server's output capacity is insufficient, indicating that the system is already very busy, it is necessary to expand the cache server's cache disk to solve the related problems. Data cannot be read endlessly from the mechanical hard disk.

[0084] See the table below:

[0085]

[0086]

[0087] According to the table above, the step size is 5. The score is 100, and 100 divided by 5 equals 20. So in our quotient, the largest cycle is 20. That is, the cache disk and the mechanical hard disk are requested as a large round, and 20 times as a cycle.

[0088] In this 20-time cycle, we try to make the cache disk request n times, and the mechanical hard disk request at least once, so that the mechanical hard disk cannot have continuous requests. So we need to find a way to reduce the number of requests to the mechanical hard disk to 1.

[0089] There are many ways to do this calculation, such as (20-step length): step length (where: represents a ratio). For example, if the compensation is 4, then by calculating: (20-4):4, simplified: 4:1. That is to say, for every 4 requests to the cache disk, there is 1 request to the mechanical hard disk. For example, if the compensation is 3, then (20-3):3, simplified: 17:3, then 17 of the 20 requests are from the cache disk, and 3 are from the mechanical hard disk. In actual use, it is impossible for the first 17 requests to be from the cache disk and the last 3 requests to be from the mechanical hard disk. The request to the mechanical hard disk must be simplified to 1. The simple calculation method is:

[0090] 17÷3=5……2

[0091] That is to say, 17 is divided into 3 parts, with an average of 5 in each part, and the extra 2 requests are added to the number of the first two requests, increasing by 1 each time. In other words,

[0092] The number of cache requests for the first group is equal to 5+1, with 1 remaining, and the mechanical disk request is 1;

[0093] The number of cache requests for the second group is equal to 5+1, with 0 times remaining, and the mechanical disk request is 1 time.

[0094] The third group has 5 cache requests and 1 mechanical disk request.

[0095] The total number of requests is 20.

[0096] According to the above calculation method, we can calculate how many times the cache is requested and the mechanical hard disk is requested once.

[0097] To simplify the calculation formula, the calculated results were slightly adjusted. For example, the above formula for 11:9 yields the following results: 2:1, 2:1, 1:1, 1:1, 1:1, 1:1, 1:1, 1:1. It can be seen that the previous group of requests cached the disk twice and the mechanical hard drive once. The seventh group cached both the disk and the mechanical hard drive once. To make it look more balanced, the above combination was slightly adjusted:

[0098] 2:1,1:1,1:1,1:1,1:2:1,1,1:1,1:1,1:1

[0099] After the adjustment, the requests look more balanced. This is just a fine-tuning. Depending on the implementation of the application, you can fine-tune it or not. It just looks better after the fine-tuning.

[0100] Similarly, we have made fine-tuning and slight improvements to 7:3, 13:7, 4:3, and 11:9, and compiled the actual application methods in the table above into the table below.

[0101] step length 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 3 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 0 4 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 5 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 6 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 7 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 0 8 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 9 1 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 10 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0

[0102] The above table is divided into 10 steps according to the step size. Each step reduces the request volume from the cache disk by 5% and increases the request data volume from the mechanical hard disk by 5%. There cannot be continuous requests during each mechanical disk request. At the same time, the requests are spelled as evenly as possible during the request.

[0103] In the figure above, 1 indicates that data is requested from the cache disk; 0 indicates that data is requested from the mechanical hard disk.

[0104] After obtaining the IP address and offset address of the corresponding cache disk from the cache server, the score under the IP address is divided by 5 and then modulo 20 to obtain the index, specifically index = (score / 5)% 20

[0105] Here index is the corresponding column.

[0106] Row: The row index is calculated by dividing the current average by the first preset value of 400ms and then dividing it by the step size of 20. The maximum row index is 10. If the calculated result is greater than 10, 10 is used instead.

[0107] By querying the table by rows and columns, you can find out whether the data is read from the cache disk or the mechanical hard disk.

[0108] In addition, if a cache disk or multiple cache disks are idle for a long period of time, that is, there are no file data requests for a period of time, then the recently recorded average value and related information are no longer meaningful. In this case, regular cleaning is required.

[0109] S204: Read files from the cache server and the disk server according to the read ratio.

[0110] That is, after determining the above read ratio, the cache server and the disk server are read according to the read request and the above read ratio.

[0111] When reading a file, the first step is to obtain the file's cache address and cache offset on the cache server, as well as the file's disk offset and disk offset on the disk server, based on the read ratio. Specifically, the cache disk address and corresponding offset are obtained, as well as the disk address and corresponding offset of the subsequent disk. Then, the first data is read from the cache server based on the cache address and cache offset, while the second data is read from the disk server based on the disk address and disk offset. Finally, the first and second data are concatenated into the file requested by the user and returned to the user.

[0112] In addition, in another specific embodiment of the present application, the following steps are also included: Figure 3 shown.

[0113] S205: Record the current request time delay as a historical request time delay.

[0114] That is, on the basis of completing this reading, the request time delay of the cache server for the reading request is recorded, that is, recorded as the latest historical request time delay.

[0115] From the previous description, it can be seen that the system uses 20 array elements to record 20 historical request time delays. If 20 data have been recorded, when recording a new historical request time delay, recording starts again from the first element in the 20 arrays, that is, using 20 array elements to cyclically record the historical request time delay.

[0116] Example 2

[0117] Figure 4 This is a block diagram of a device for reading disk data from a cache disk according to an embodiment of the present application.

[0118] The reading device provided in this embodiment is applied to a distributed file system, which includes at least a cache server and a disk server. The cache server is used to store cache metadata information about files. The cache metadata is file description information, which describes the storage blocks on which file fragments are stored on which servers. The information about the file fragments includes the disk's IP address, disk number, data offset on the disk, and data block size.

[0119] A disk server is a server used to manage disks and provide disk read and write services. Each disk has a unique disk address in the disk server.

[0120] like Figure 4 As shown, the disk data reading device provided in this embodiment specifically includes a parameter acquisition module 10 and a reading control module 20 .

[0121] The parameter acquisition module is used to obtain the historical request time delay of the cache server.

[0122] That is, when a user sends a data request through the data module of the distributed file system, the system determines whether the file is stored in the cache server. If the file is not in the cache server, the system directly queries the hard disk address and offset address of the file in the hard disk server from the information management server of the system, and then directly reads the file based on the hard disk address and offset address.

[0123] If the file is stored in the cache server, at least one historical request time delay of the cache server is read for the file. In a specific embodiment of the present application, the historical request time delays are stored in an array, the array including multiple data elements, each array element storing a historical request time delay.

[0124] When the historical request time delay is obtained, all historical request time delays in the data are obtained.

[0125] In the distributed file system's data module, at startup, the cache disk array is initialized to 20 elements. POS is set as the array cursor, starting at 0 and with a maximum cursor size equal to the number of elements in the array minus 1. This array is a circular array. After POS points to the largest element, it starts again at 0, looping endlessly to record the request latency of the cache server's disk corresponding to the current IP address.

[0126] The variable count records the number of recent requests to this IP address. The default value is 0 and the maximum value is the number of elements in the array. If count is less than the number of elements in the array, count is incremented by 1 each time a delay is recorded until count equals the number of elements in the array.

[0127] The read control module is used to delay reading files according to historical request times.

[0128] Specifically, the file is read from the cache server alone based on the historical request delay, or the file is read from the cache server and the hard disk server in proportion based on the historical request delay. That is, the file is read from the cache server first.

[0129] As can be seen from the above technical solution, this embodiment provides a disk data reading device, which is applied to a distributed file system. Specifically, when a cache server stores a file required by a user, the device is configured to obtain at least one historical request time delay of the cache server; based on the historical request time delay, the device reads the file from the cache server, or from both the cache server and the disk server. Specifically, the device prioritizes reading files from the cache server. This reduces the number of times and the time required to read the disk server, effectively reducing the number of read requests and avoiding negative impacts on the service life of the mechanical disk in the disk server and the security of the data.

[0130] In a specific embodiment of the present application, the reading control module specifically includes a first calculation unit 21, a first reading unit 22, a second calculation unit 23 and a second reading unit 24, specifically as follows Figure 5 shown.

[0131] The first calculation unit is used to calculate the average request time delay according to the historical request time delay;

[0132] As can be seen from the previous description, this system can record 20 historical request time delays. In order to ensure the accuracy of the solution, it is necessary to calculate based on multiple historical request time delays to obtain the average request time delay.

[0133] Specifically, if only one historical request time delay is stored in the array, the unique historical request time delay is used as the average request time delay; if the historical request time delay is not unique, multiple elements in the array, that is, multiple historical request time delays, are averaged to obtain the average request time delay.

[0134] After obtaining the average request time delay, the average request time delay is compared with a first preset value, which may be 400 ms.

[0135] The first reading unit is used to read the file from the cache server according to the user's reading request;

[0136] That is, if the average request time delay is equal to or less than the first preset value, then when a read request is received from the user, the file is read only from the cache server's disk. In other words, at this time, only the cache server's solid-state drive can meet the delay requirement.

[0137] During actual reading, the cache address and cache offset address of the file in the cache server are first obtained; then, the actual cache disk is determined according to the cache address, and the file is read from the cache disk according to the cache offset address.

[0138] The second calculation unit is used to calculate the read ratio according to the average request time delay;

[0139] That is, if the average request time delay is greater than the first preset value, the file is no longer read only from the cache server. At this time, the reading ratio is calculated according to the average request time delay, so that the reading ratio is used as the basis for the next step of reading.

[0140] During actual calculation, the difference between the average request time delay and the first preset value is first calculated, and then the read ratio is determined based on the difference.

[0141] The read ratio includes a first ratio and a second ratio, the sum of which equals 100%. The first ratio is the ratio of the amount of data read from the cache server to the total amount of data in the file to be read, and the second ratio is the ratio of the amount of data read from the disk server to the total amount of data. Generally speaking, the first ratio is greater than the second preset value, which is generally greater than 50%, to ensure that files are read preferentially from the cache server.

[0142] If the average request time delay average in this calculation is less than or equal to 400ms, then this request will continue to read from the cache disk. If average is greater than 400ms, we use the preset step size to determine whether to read from the cache disk or the mechanical hard disk. Assuming our step size is 20ms, the number of times we read from the cache disk decreases by 5% with each step. Until the second preset value. We set the second preset value to 50%. That is, in the worst case, 50% of the requests are read from the cache disk, and the other 50% of the requests are read from the mechanical hard disk.

[0143] If the cache server's output capacity is insufficient, indicating that the system is already very busy, it is necessary to expand the cache server's cache disk to solve the related problems. Data cannot be read endlessly from the mechanical hard disk.

[0144] In addition, if a cache disk or multiple cache disks are idle for a long period of time, that is, there are no file data requests for a period of time, then the recently recorded average value and related information are no longer meaningful. In this case, regular cleaning is required.

[0145] The second reading unit is used to read files from the cache server and the disk server according to the reading ratio.

[0146] That is, after determining the above read ratio, the cache server and the disk server are read according to the read request and the above read ratio.

[0147] When reading a file, the first step is to obtain the file's cache address and cache offset on the cache server, as well as the file's disk offset and disk offset on the disk server, based on the read ratio. Specifically, the cache disk address and corresponding offset are obtained, as well as the disk address and corresponding offset of the subsequent disk. Then, the first data is read from the cache server based on the cache address and cache offset, while the second data is read from the disk server based on the disk address and disk offset. Finally, the first and second data are concatenated into the file requested by the user and returned to the user.

[0148] In addition, in another specific embodiment of the present application, a parameter recording unit 25 is also included, such as Figure 6 shown.

[0149] The parameter recording unit is used to record the current request time delay as the historical request time delay.

[0150] That is, on the basis of completing this reading, the request time delay of the cache server for the reading request is recorded, that is, recorded as the latest historical request time delay.

[0151] From the previous description, it can be seen that the system uses 20 array elements to record 20 historical request time delays. If 20 data have been recorded, when recording a new historical request time delay, recording starts again from the first element in the 20 arrays, that is, using 20 array elements to cyclically record the historical request time delay.

[0152] Example 3

[0153] This embodiment provides an electronic device, which can be understood as a server of the above-mentioned distributed file system, and is provided with the above-mentioned reading device. The device is specifically used to obtain at least one historical request time delay of the cache server when the cache server stores the file required by the user; and read the file from the cache server, or from the cache server and the disk server based on the historical request time delay. That is, the file is read from the cache server first. In this way, the number of times and time that the disk server is read can be reduced, thereby effectively reducing the reading task and avoiding a negative impact on the service life of the mechanical disk in the disk server and the security of its data.

[0154] Example 4

[0155] Figure 7 This is a block diagram of an electronic device according to an embodiment of the present application.

[0156] like Figure 7 As shown, the electronic device provided in this embodiment can be understood as a server of the above-mentioned distributed file system, specifically including at least one processor 101 and a memory 102, which are connected via a data bus 103.

[0157] The memory is used to store computer programs or instructions, and the processor is used to obtain the computer program or instructions through a data bus. The processor can enable the electronic device to implement the disk data reading method in this application by executing the computer program or instructions. The method specifically obtains at least one historical request time delay of the cache server when the cache server stores the file required by the user; and reads the file from the cache server, or from the cache server and the disk server according to the historical request time delay. That is, the file is read from the cache server first. In this way, the number of times and time that the disk server is read can be reduced, thereby effectively reducing the reading task and avoiding negative impacts on the service life of the mechanical disk in the disk server and the security of its data.

[0158] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0159] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0160] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0161] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0162] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0163] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0164] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0165] The technical solution provided by the present invention is introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for reading disk data from a cache disk, applied to a distributed file system, wherein the distributed file system includes a cache server and a disk server, and the disk server includes at least one cache disk, characterized in that: The reading method comprises the steps of: In a case where the cache server stores the file required by the user, obtaining at least one historical request time delay of the cache server; Calculating an average request time delay based on the historical request time delays; When the average request time delay is less than or equal to a first preset value, reading the file from the cache server according to a read request of the user; When the average request time delay is greater than the first preset value, calculating the read ratio according to the average request time delay; The file is read from the cache server and the disk server respectively according to the read request and the read ratio.

2. The reading method according to claim 1, wherein: The calculating the average request time delay according to the historical request time delay comprises the steps of: If the historical request time delay is unique, taking the historical request time delay as the average request time delay; If the historical request time delay is not unique, all the acquired historical request time delays are averaged to obtain the average request time delay.

3. The reading method according to claim 1, wherein: The method of reading the file from the cache server according to the user's read request comprises the following steps: Obtaining the cache address and cache offset address of the file in the cache server; The file is read from the cache server according to the cache address and the cache offset address.

4. The reading method according to claim 1, wherein: Calculating the read ratio according to the average request time delay includes: Calculating a difference between the average request time delay and the first preset value; The reading ratio is determined based on the difference, and the reading ratio includes a first ratio and a second ratio, the first ratio being the ratio of the amount of data read from the cache server to the total amount of data of the file, and the second ratio being the ratio of the amount of data read from the disk server to the total amount of data, and the first ratio being greater than or equal to a second preset value.

5. The reading method according to claim 4, wherein: The second preset value is 50%.

6. The reading method according to claim 4, wherein: The step of reading the file from the cache server and the disk server according to the read request and the read ratio comprises the following steps: Acquire a cache address and a cache offset address of the file on the cache server, and a disk address and a disk offset address of the file on the disk server according to the read ratio; Reading first data from the cache server according to the cache address and the cache offset address; Reading second data from the disk server according to the disk address and the disk offset address; The first data and the second data are concatenated into the file.

7. The reading method according to any one of claims 1 to 6, wherein: Also includes the steps: The request time delay to the cache server is recorded as the historical request time delay.

8. A device for reading disk data of a cache disk, applied to a distributed file system, wherein the distributed file system comprises a cache server and a disk server, wherein the disk server comprises at least one cache disk, characterized in that: The reading device comprises: a parameter acquisition module, configured to acquire at least one historical request time delay of the cache server when the cache server stores the file required by the user; a reading control module, configured to read the file from the cache server, or from the cache server and the disk server, according to the historical request time delay; Wherein, the reading control module includes: a first calculation unit, configured to calculate an average request time delay based on the historical request time delays; a first reading unit, configured to read the file from the cache server according to a read request of a user when the average request time delay is less than or equal to a first preset value; a second calculating unit, configured to calculate a read ratio according to the average request time delay when the average request time delay is greater than the first preset value; The second reading unit is configured to read the file from the cache server and the disk server respectively according to the read request and the read ratio.

9. The reading device according to claim 8, wherein Also includes: A parameter recording unit is configured to record a request delay time to the cache server as the historical request time delay.

10. An electronic device, characterized in that: A reading device according to any one of claims 8 to 9 is provided.

11. An electronic device, characterized in that: comprising at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs or instructions; The processor is configured to acquire and execute the computer program or instruction, so as to enable the electronic device to implement the reading method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for reducing energy consumption of server by using mixed storage of solid-state drive and mechanical hard disk

    CN102662459A

  • Data replacement method for memory, server node, and data storage system

    WO2019109209A1