Method, device, equipment and medium for transmitting massive small files
By utilizing concurrent transfer technology to split directories and perform concurrent transfers in massive small file transfers, the problem of low transfer efficiency is solved, faster transfer times and higher CPU bandwidth utilization are achieved, and data integrity is ensured.
Patent Information
- Application Number
- CN202210910755.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-07-29
AI Technical Summary
Massive small files result in low CPU utilization, low bandwidth utilization, and long transmission time in full transmission scenarios, and the decompression process after pre-packaging and transmission consumes a lot of time, resulting in low transmission efficiency.
Obtain the directory information of massive small files by scanning the server, split the target directory based on the number of concurrent transmissions and the directory tree structure, perform concurrent transmissions, make full use of the server's concurrency capabilities, shorten the transmission time, and perform consistency verification after the transmission is completed to ensure Data integrity.
It improves the transmission efficiency of massive small files, shortens the transmission time, avoids excessive occupation of source and destination server disk space, and ensures the integrity of data transmission.
Smart Images

Figure CN115499426B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular to a method, device, equipment and medium for transmitting massive small files. Background Art
[0002] In the full transmission scenario of massive small files, there are problems such as low central processing unit (CPU) and bandwidth utilization and long transmission time.
[0003] In the related art, in order to solve the above technical problems, the files are packaged and transmitted in advance, and then decompressed. However, this method of transmission easily leads to excessive use of disk space on the source and destination servers, and the decompression process after transmission also consumes a lot of time, resulting in low transmission efficiency. Summary of the invention
[0004] In view of this, the embodiments of the present invention provide a method, apparatus, device and medium for transmitting a large number of small files to solve the problem of low efficiency in transmitting a large number of small files.
[0005] According to a first aspect, an embodiment of the present invention provides a method for transmitting a large number of small files, the method comprising:
[0006] Scan the server to obtain directory information of a first target directory storing a large number of small files, wherein the directory information at least includes a directory tree structure of the first target directory;
[0007] Based on the number of concurrent transmissions of the server and the directory tree structure, split the first target directory to obtain a first number of directory subsets, wherein each directory subset includes at least one target subdirectory;
[0008] The first number of directory subsets are concurrently transmitted to a receiving device, so that the receiving device obtains the massive small files.
[0009] In this way, the concurrent capabilities of the server can be fully utilized during the transmission process, which helps to shorten the transmission time of massive small files and improve transmission efficiency.
[0010] In combination with the first aspect, in a first embodiment of the first aspect, the directory information further includes a directory size of the first target directory; and splitting the first target directory based on the number of concurrent transmissions of the server and the directory tree structure to obtain a first number of directory subsets includes:
[0011] Determining a set base size of the directory subset according to a quotient between the directory size and the number of concurrent transmissions;
[0012] Determine the splitting benchmark size of the directory subset according to the product between the set benchmark size and the specified splitting factor;
[0013] Determine the directory size of each subdirectory in the directory tree structure respectively;
[0014] Based on the set reference size, the split reference size, and the directory size of each sub-directory, the first target directory is split to obtain a first number of directory subsets, wherein each directory subset includes at least one target sub-directory.
[0015] In combination with the first embodiment of the first aspect, in a second embodiment of the first aspect, splitting the first target directory based on the set benchmark size, the split benchmark size, and the directory size of each subdirectory to obtain a first number of directory subsets includes:
[0016] Determine the node type of each subdirectory in the directory tree structure respectively;
[0017] Determine the target subdirectory according to the node type and / or directory size of each subdirectory, and obtain a second number of target subdirectories, wherein the target subdirectory is a subdirectory whose node type is a leaf node type, or a subdirectory whose directory size is smaller than the splitting benchmark size;
[0018] Based on the set reference size and the directory size of each target sub-directory, the second number of target sub-directories are combined to obtain the first number of directory subsets.
[0019] In combination with the second embodiment of the first aspect, in a third embodiment of the first aspect, the first number of directory subsets includes a first directory subset and / or a second directory subset; and combining the second number of target subdirectories based on the set benchmark size and the directory size of each target subdirectory to obtain the first number of directory subsets includes:
[0020] sorting the second number of target subdirectories from largest to smallest according to the directory size of each target subdirectory;
[0021] Traversing the second number of target sub-directories according to the sorting result, if the directory size of the current target sub-directory is greater than or equal to the set reference size, dividing the current target sub-directory separately to form a first directory subset;
[0022] If the directory size of the current target subdirectory is smaller than the set benchmark size, then based on the difference between the directory size of the current target subdirectory and the set benchmark size, a second target subdirectory combined with the current target subdirectory is determined from the remaining target subdirectories to obtain a second directory subset.
[0023] In combination with the third embodiment of the first aspect, in a fourth embodiment of the first aspect, determining a second target subdirectory combined with the current target subdirectory from the remaining target subdirectories based on the difference between the directory size of the current target subdirectory and the set reference size to obtain the second directory subset includes:
[0024] Based on the difference, traverse the remaining target subdirectories to see whether there is a first subdirectory whose directory size is equal to the difference;
[0025] If the remaining target subdirectories include the first subdirectory, determining the first subdirectory as the second target subdirectory, and combining the first subdirectory with the current target subdirectory to obtain a second directory subset;
[0026] If the remaining target subdirectories do not include the first subdirectory, based on the difference, obtaining a second subdirectory from the remaining target subdirectories whose directory size is closest to the difference;
[0027] Obtaining a first variance value according to the square of a difference between the second subdirectory size of the second subdirectory and the difference value;
[0028] Obtaining a second variance value according to the square of the difference between the directory size of the current target subdirectory and the difference value;
[0029] Based on the comparison result between the set reference size and the first variance value and the second variance value, the second target subdirectory is determined from the remaining target subdirectories, and the second target subdirectory is combined with the current target subdirectory to obtain a second directory subset.
[0030] In combination with the first aspect, in a fifth embodiment of the first aspect, the method further includes:
[0031] In response to the received transmission failure instruction, determining at least one third directory subset to be re-transmitted concurrently, wherein the third directory subset is a directory subset of the first number of directory subsets for which concurrent transmission fails;
[0032] The at least one third directory subset is retransmitted concurrently to the receiving device.
[0033] In this manner, the transmission status can be monitored in real time during the concurrent transmission process, and when there is a third directory subset that fails in concurrent transmission, it can be retransmitted, thereby helping to ensure the effectiveness of the transmission and improve the transmission efficiency.
[0034] In combination with the first aspect, in a sixth embodiment of the first aspect, the method further includes:
[0035] If the concurrent transmission ends, reading the second target directory received by the receiving device;
[0036] A consistency check is performed on the second target directory and the first target directory to determine whether the second target directory is complete.
[0037] In this manner, a consistency check can be automatically performed on the second target directory received by the receiving device after the concurrent transmission is completed, thereby helping to ensure the integrity of data transmission so that a subset of directories that has not been transmitted or has failed to be transmitted can be discovered in a timely manner.
[0038] According to a second aspect, an embodiment of the present invention provides a transmission device for a large number of small files, the device comprising:
[0039] A scanning unit, used for scanning a server to obtain directory information of a first target directory storing a large number of small files, wherein the directory information at least includes a directory tree structure of the first target directory;
[0040] a splitting unit, configured to split the first target directory based on the number of concurrent transmissions of the server and the directory tree structure, to obtain a first number of directory subsets, wherein each directory subset includes at least one target subdirectory;
[0041] The transmission unit is used to concurrently transmit the first number of directory subsets to a receiving device, so that the receiving device obtains the massive small files.
[0042] According to the third aspect, an embodiment of the present invention also provides a computer device, including a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for transmitting massive small files of the first aspect and any one of its optional embodiments by executing the computer instructions.
[0043] According to a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method for transmitting massive small files of the first aspect and any one of its optional embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 The present invention is a flowchart of a method for transmitting a large number of small files according to an exemplary embodiment.
[0046] Figure 2 is a schematic diagram of a target tree structure proposed according to an exemplary embodiment.
[0047] Figure 3 It is a schematic diagram of a sorting result proposed according to an exemplary embodiment.
[0048] Figure 4 It is a schematic diagram of the division result of a directory subset proposed according to an exemplary embodiment.
[0049] Figure 5 It is a flowchart of another method for transmitting a large number of small files according to an exemplary embodiment.
[0050] Figure 6 It is a flowchart of another method for transmitting massive small files according to an exemplary embodiment.
[0051] Figure 7 It is a flowchart of another method for transmitting massive small files according to an exemplary embodiment.
[0052] Figure 8 It is a structural block diagram of a transmission device for massive small files proposed according to an exemplary embodiment.
[0053] Fig. 9 It is a schematic diagram of the hardware structure of a computer device proposed according to an exemplary embodiment. DETAILED DESCRIPTION
[0054] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] In the related art, when transmitting a large number of small files, the files are packaged and transmitted in advance, and then decompressed. However, this method of transmission easily leads to excessive use of disk space on the source and destination servers, and the decompression process after transmission also consumes a lot of time, resulting in low transmission efficiency.
[0056] In order to solve the above problems, a method for transmitting a large number of small files is provided in an embodiment of the present invention, which is used in a computer device. It should be noted that the execution subject can be a transmission device for a large number of small files, and the device can be implemented as part or all of the computer device through software, hardware, or a combination of software and hardware. The computer device can be a terminal, a client, or a server. The server can be a single server or a server cluster composed of multiple servers. The terminal in the embodiment of the present application can be a smart phone, a personal computer, a tablet computer, a wearable device, and other intelligent hardware devices such as an intelligent robot. In the following method embodiments, the execution subject is a computer device as an example for explanation.
[0057] The computer device of this embodiment is applied to application scenarios for full transmission of massive small files, such as I / O intensive scenarios. According to the transmission method of massive small files provided by the present invention, the massive small files can be split based on the directory information of the first target directory storing the massive small files and the number of concurrent transmissions of the server, and then concurrent transmission is performed according to the splitting results, so that the concurrent capacity of the server can be fully utilized during the transmission process, which is conducive to shortening the transmission time and improving the transmission efficiency.
[0058] Figure 1 FIG. 1 is a flow chart of a method for transmitting a large number of small files according to an exemplary embodiment. Figure 1 As shown, the method for transmitting a large number of small files includes the following steps S101 to S103.
[0059] In step S101, the server is scanned to obtain directory information of a first target directory storing a large number of small files.
[0060] In an embodiment of the present invention, the server can be understood as a source end. Among them, the massive small files (TB / PB level file volume) to be sent are stored in the server in the form of directories. In order to transfer the massive small files required by the receiving device to the receiving device, the server is scanned to obtain the directory information of the first target directory storing the massive small files. Among them, the first target directory can be understood as a target directory stored in the server to be transmitted to the receiving device, and the directory information at least includes the directory tree structure of the first target directory. In one example, the scan can be performed when the server is in an idle state to avoid affecting the server's service provision to other devices during the scanning process.
[0061] In step S102, based on the concurrent transmission quantity of the server and the directory tree structure, the first target directory is split to obtain a first number of directory subsets.
[0062] In the embodiment of the present invention, the number of concurrent transmissions is obtained based on the concurrent capability of the server when performing file transmission. The association relationship between different small files can be determined according to the target tree structure of the first target directory, so that the integrity of the files can be guaranteed during the splitting process.
[0063] Therefore, in order to improve the transmission efficiency, the first target directory is split based on the number of concurrent transmissions of the server and the directory tree structure to obtain a first number of directory subsets, so that in the process of concurrent transmission, the directory subsets can be used as units for transmission, thereby helping to reduce the number of small files transmitted at one time, thereby helping to shorten the time required for one transmission. Among them, the number of concurrent transmissions of the server can be determined based on the number of threads that the thread pool can provide. The first number can be understood as the total number of directory subsets.
[0064] In step S103, a first number of directory subsets are concurrently transmitted to a receiving device, so that the receiving device obtains a large number of small files.
[0065] Through the above-mentioned embodiments, the concurrent capability of the server can be fully utilized during the transmission process, thereby helping to shorten the transmission time of a large number of small files and improve the transmission efficiency.
[0066] The following embodiment will specifically illustrate the process of obtaining the first number of directory subsets.
[0067] In the present invention, the target information also includes the directory size of the first target directory. The directory size can be used to determine the size of the disk space occupied by the first target directory. In order to fully utilize the concurrent capabilities of the server and determine the size of the amount of data transmitted by each thread under ideal conditions, the set benchmark size of the directory subset is determined based on the quotient between the directory size and the number of concurrent transmissions. For example, if the number of concurrent transmissions is N and the directory size is X, then the set benchmark size of each directory subset is In one example, the number of concurrent transmissions can be determined according to the number of central processing units (CPU) of the server. For example, the number of concurrent transmissions N = n*the number of CPU cores, where n can be 2.
[0068] The directory sizes of different subdirectories in the directory tree structure may be different. Therefore, in order to balance the set size of each directory subset and avoid excessive differences in the set sizes of different directory subsets, the split benchmark size of the directory subset is determined based on the product of the set benchmark size and the specified split factor, so as to determine the number of subdirectories in each directory subset based on the split benchmark size. Among them, the smaller the specified split factor θ (0<≤1), the more average the set size of each directory subset and the more complicated the splitting process. In one example, the specified split factor θ can be 0.8. In another example, the specified split factor can be determined based on the upper limit of the resource utilization of the server.
[0069] The directory size of each subdirectory in the directory tree structure is determined respectively. Then, based on the determined set reference size, split reference size and directory size of each subdirectory, the first target directory is split to obtain a first number of directory subsets. Each directory subset includes at least one target subdirectory.
[0070] In one embodiment, the first number of directory subsets can be obtained in the following manner: Figure 2 The directory tree structure shown in the figure determines the node type of each subdirectory in the directory tree structure respectively. Among them, the node type includes a leaf node type, a child node type and a root node type. Different letters represent different subdirectories, and the number under each subdirectory represents the directory size of each subdirectory. According to the node type of each subdirectory, the directory size of the subdirectory, or the node type and directory size of the subdirectory, the target subdirectory is determined to obtain the second number of target subdirectories, and then based on the set reference size and the directory size of each target subdirectory, the second number of target subdirectories are combined to obtain the first number of directory subsets. Among them, the target subdirectory is a subdirectory whose node type is a leaf node type, or a subdirectory whose directory size is less than the split reference size. The second number can be understood as the total number of target subdirectories.
[0071] In the present invention, the first number of directory subsets may be composed of multiple first directory subsets, multiple second directory subsets, or multiple first directory subsets and second directory subsets. The first directory subset may be understood as a directory subset including only one target subdirectory. The second directory subset may be understood as a directory subset including at least two target subdirectories.
[0072] Specific, combined Figure 2 The target tree structure shown in FIG. 1 is obtained by sorting the second number of target subdirectories from large to small according to the directory size of each target subdirectory. Figure 3The sorting result is shown. The second number of target subdirectories are traversed according to the sorting result. If the directory size of the current target subdirectory is greater than or equal to the set reference size, the current target subdirectory is divided separately to form a first directory subset. If the directory size of the current target subdirectory is less than the set reference size, based on the difference between the directory size of the current target subdirectory and the set reference size, a second target subdirectory combined with the current target subdirectory is determined from the remaining target subdirectories to obtain a second directory subset, so that the set size of each directory subset is equal to or close to the set reference size.
[0073] In one example, based on the difference between the directory size of the current target subdirectory and the set reference size, a second target subdirectory combined with the current target subdirectory is determined from the remaining target subdirectories, and a process of obtaining the second directory subset may be as follows:
[0074] Based on the difference, traverse the remaining target subdirectories to see whether there is a first subdirectory whose directory size is equal to the difference. If the remaining target subdirectories include the first subdirectory, determine that the first subdirectory is the second target subdirectory, and combine the first subdirectory with the current target subdirectory to obtain a second directory subset. If the remaining target subdirectories do not include the first subdirectory, based on the difference, obtain the second subdirectory whose directory size is closest to the difference from the remaining target subdirectories. Determine the square of the difference between the second subdirectory size of the second subdirectory and the difference to obtain a first variance value. Determine the square of the difference between the directory size of the current target subdirectory and the difference to obtain a second variance value. Based on the comparison result between the set benchmark size and the first variance value and the second variance value, determine the second target subdirectory from the remaining target subdirectories, and combine the second target subdirectory with the current target subdirectory to obtain a second directory subset. Among them, the number of second target subdirectories may not be unique.
[0075] In one implementation scenario, combined with Figure 3 The sorting result shown in the figure compares the directory size of each target subdirectory with the set benchmark size one by one. If the current target subdirectory Y i The directory size Size(Y i ) is greater than or equal to the collection base size Then the target subdirectory Y i Separately divide them into a set to form the first directory subset.
[0076] If the current target subdirectory Y i The directory size Size(Y i ) is smaller than the collection base size Then determine Size(Y i ) and the collection base size If there is a first subdirectory Y in the remaining target subdirectories whose directory size is equal to the difference Δ j , then the current target subdirectory Y i and the first subdirectory Y j Combined in the same set, forming the second directory subset.
[0077] If there is no first subdirectory Y in the remaining target subdirectories whose directory size is equal to the difference Δ j , then obtain the second subdirectory Y whose directory size is closest to the difference Δ from the remaining target subdirectories j+1 . According to the second subdirectory Y j+1 The size of the second subdirectory Size(Y j+1 ) and the square of the difference between the difference Δ to obtain the first square error value. i The directory size Size(Y i ) and the square of the difference between the difference Δ to obtain the second variance value. If the first variance value is less than or equal to the second variance value, the second subdirectory Y j+1 Determine the current target subdirectory Y i The second target subdirectory of the second directory subset is formed, and the second target subdirectory is continuously obtained from the remaining target subdirectories based on the equality principle until the set size of the obtained second directory subset is equal to or close to the set reference size. If the first variance value is greater than the second variance value, the second variance value is temporarily stored, and the second subdirectory size (Y j+1 ) and the difference Δ′, and obtain the third subdirectory whose directory size is closest to the difference Δ′ from the remaining target subdirectories. According to the square of the difference between the directory size of the third subdirectory and the difference Δ′, the third difference is obtained. According to the size of the second subdirectory Size(Y j+1 ) and the square of the difference between the difference Δ′ to obtain the fourth variance value. The subdirectory with the smallest variance value is determined as the second target subdirectory through the third difference value and the fourth variance value, and is compared with the current target subdirectory Y i The sub-sets are combined into the same set, and so on, until a second directory subset is obtained whose set size is equal to or close to the set base size.
[0078] According to the first directory subset and the second directory subset, the first number of directory subsets finally formed can be as follows Figure 4 As shown in the figure, each line is a directory subset.
[0079] Figure 5 FIG. 1 is a flow chart of another method for transmitting a large number of small files according to an exemplary embodiment. Figure 5 As shown, the method for transmitting a large number of small files includes the following steps.
[0080] In step S501, the server is scanned to obtain directory information of a first target directory storing a large number of small files.
[0081] In step S502, based on the concurrent transmission quantity of the server and the directory tree structure, the first target directory is split to obtain a first number of directory subsets.
[0082] In step S503, a first number of directory subsets are concurrently transmitted to a receiving device, so that the receiving device obtains a large number of small files.
[0083] In step S504, in response to the received transmission failure instruction, at least one third directory subset to be re-transmitted concurrently is determined.
[0084] In an embodiment of the present invention, the server can perform concurrent transmission tasks through a data mirroring backup tool (e.g., rsync), and the data mirroring backup tool can monitor the transmission status of each directory subset during the transmission process. If at least one third directory subset that fails in concurrent transmission is detected during the monitoring process, a transmission failure instruction is sent to the server to inform the server that at least one third directory subset has failed in transmission. In response to the received transmission failure instruction, the server determines at least one third directory subset to be re-transmitted concurrently. The third directory subset is a directory subset in the first number of directory subsets that fails in concurrent transmission.
[0085] In step S505, at least one third directory subset is re-concurrently transmitted to the receiving device.
[0086] Through the above embodiment, the transmission status can be monitored in real time during the concurrent transmission process, and when there is a third directory subset that fails in concurrent transmission, it can be retransmitted, which helps to ensure the effectiveness of transmission and improve transmission efficiency.
[0087] Figure 6 FIG. 1 is a flow chart of another method for transmitting a large number of small files according to an exemplary embodiment. Figure 6 As shown, the method for transmitting a large number of small files includes the following steps.
[0088] In step S601, the server is scanned to obtain directory information of a first target directory storing a large number of small files.
[0089] In step S602, based on the concurrent transmission quantity of the server and the directory tree structure, the first target directory is split to obtain a first number of directory subsets.
[0090] In step S603, a first number of directory subsets are concurrently transmitted to a receiving device, so that the receiving device obtains a large number of small files.
[0091] In step S604, if the concurrent transmission is finished, the second target directory received by the receiving device is read.
[0092] In step S605, the second target directory is checked for consistency with the first target directory to determine whether the received second target directory is complete.
[0093] In an embodiment of the present invention, a consistency check can be performed by comparing the directory sizes between the second target directory and the first target directory. A consistency check can be performed by comparing the directory sizes between the second target directory and the first target directory and the timestamp of the second target directory being received. Or a consistency check can be performed by comparing the difference between the information digest (e.g., md5) of the second target directory and the information digest of the first target directory. In one example, if the target subdirectory is a key directory, a consistency check can be performed by comparing the difference between the information digest (e.g., md5) of the second target directory and the information digest of the first target directory. If the target subdirectory is a secondary directory, a consistency check can be performed by comparing the directory sizes between the second target directory and the first target directory and the timestamp of the second target directory being received, thereby helping to save verification time.
[0094] Through the above embodiment, the second target directory received by the receiving device can be automatically checked for consistency after the concurrent transmission is completed, thereby helping to ensure the integrity of data transmission so that the directory subset that has not been transmitted or failed to be transmitted can be discovered in time.
[0095] In one embodiment, in order to avoid excessive occupation of server resources during concurrent transmission, which may affect server performance, the actual resource occupation rate of the server is periodically detected during concurrent transmission to determine whether to enable server resource protection. If the actual resource occupation rate is greater than the upper limit of resource occupation rate, server resource protection is enabled, and at least one target subdirectory with a higher resource occupation rate in concurrent transmission is suspended to ensure the normal operation of the server until the actual resource occupation rate is less than the upper limit of resource occupation rate, and the target subdirectory whose transmission is suspended is resumed. In one example, the upper limit of resource occupation rate may include the upper limit of CPU threshold (e.g., 80%), the upper limit of memory threshold (e.g., 80%), and the maximum transmission rate MB / s (e.g., limited to 0.8*bandwidth / 8).
[0096] In one implementation scenario, the process of transmitting a large number of small files can be as follows: Figure 7 shown. Figure 7 It is a flowchart of another method for transmitting massive small files according to an exemplary embodiment.
[0097] In step S701, it is determined whether to perform preliminary scanning and task optimization processing.
[0098] In step S702, the server is scanned to obtain directory information of a first target directory storing a large number of small files.
[0099] In step S703, the number of concurrent transmissions, the splitting reference size of the directory subset, and the splitting reference size are determined.
[0100] In step S704, the first target directory is split to obtain a first number of directory subsets.
[0101] In step S705, a first number of directory subsets are concurrently transmitted to a receiving device.
[0102] In step S706, it is determined whether to perform a consistency check according to the concurrent transmission status.
[0103] In step S707, if the concurrent transmission is finished, a consistency check is performed on the second target directory received by the receiving device according to the first target directory.
[0104] In step S708, during the concurrent transmission process, the actual resource occupancy rate of the server is periodically detected to determine whether to enable server resource protection.
[0105] In step S709, if the actual resource occupancy rate is greater than the resource occupancy rate upper limit, server resource protection is started.
[0106] Through the above embodiments, it is possible to adapt to the resources of the server, optimize a single target task into a subtask set with uniform task volume, make full use of the concurrent capacity of the server, and thus help to shorten the transmission time of a large number of small files and improve the transmission efficiency. In addition, the method provided by the present invention does not require additional disk space, which also helps to save resources.
[0107] Based on the same inventive concept, the present invention also provides a transmission device for massive small files.
[0108] In a transmission device for massive small files, a directory scanning module, an adaptive task planning module, a concurrent transmission module, a server resource protection module and a consistency verification module are included. Among them, the directory scanning module is used to scan the first target directory during the idle period of the server business to obtain the directory information of the first target directory. The adaptive task planning module is used to split the first target directory to obtain a first number of directory subsets to be transmitted concurrently. The concurrent transmission module is used to transmit the first number of directory subsets to a receiving device. The server resource protection module is used to protect server resources to avoid excessive occupation of server resources during concurrent transmission. The consistency verification module is used to perform consistency verification on the first target directory and the second target directory.
[0109] Based on the same inventive concept, the present invention also provides another device for transmitting massive small files.
[0110] Figure 8 is a structural block diagram of a transmission device for a large number of small files according to an exemplary embodiment. Figure 8 As shown, the transmission device for massive small files includes a scanning unit 801, a splitting unit 802 and a transmission unit 803.
[0111] A scanning unit 801 is used to scan the server to obtain directory information of a first target directory storing a large number of small files, wherein the directory information at least includes a directory tree structure of the first target directory;
[0112] A splitting unit 802 is used to split the first target directory based on the concurrent transmission quantity of the server and the directory tree structure to obtain a first number of directory subsets, wherein each directory subset includes at least one target subdirectory;
[0113] The transmission unit 803 is used to concurrently transmit the first number of directory subsets to the receiving device, so that the receiving device obtains a large number of small files.
[0114] In one embodiment, the directory information also includes the directory size of the first target directory; the splitting unit 802 includes: a first determining unit, used to determine the set base size of the directory subset according to the quotient between the directory size and the number of concurrent transmissions. A second determining unit, used to determine the splitting base size of the directory subset according to the product between the set base size and the specified splitting factor. A third determining unit, used to determine the directory size of each subdirectory in the directory tree structure respectively. The splitting subunit, used to split the first target directory based on the set base size, the splitting base size and the directory size of each subdirectory, to obtain a first number of directory subsets, wherein each directory subset includes at least one target subdirectory.
[0115] In another embodiment, the split sub-unit includes: a fourth determination unit, which is used to determine the node type of each sub-directory in the directory tree structure respectively. A fifth determination unit, which is used to determine the target sub-directory according to the node type and / or directory size of each sub-directory, and obtain a second number of target sub-directories, wherein the target sub-directory is a sub-directory whose node type is a leaf node type, or a sub-directory whose directory size is smaller than the splitting reference size. A combination unit, which is used to combine the second number of target sub-directories based on the set reference size and the directory size of each target sub-directory, and obtain the first number of directory subsets.
[0116] In another embodiment, the first number of directory subsets includes the first directory subset and / or the second directory subset. The combination unit includes: a sorting unit, which is used to sort the second number of target subdirectories from large to small according to the directory size of each target subdirectory. The first combination unit is used to traverse the second number of target subdirectories according to the sorting result, and if the directory size of the current target subdirectory is greater than or equal to the set reference size, the current target subdirectory is divided separately to form the first directory subset. The second combination unit is used to determine the second target subdirectory combined with the current target subdirectory from the remaining target subdirectories based on the difference between the directory size of the current target subdirectory and the set reference size if the directory size of the current target subdirectory is less than the set reference size, and obtain the second directory subset.
[0117] In another embodiment, the second combination unit includes: a traversal unit, which is used to traverse the remaining target subdirectories based on the difference value to determine whether there is a first subdirectory with a directory size equal to the difference value. A first subdirectory combination unit, which is used to determine that the first subdirectory is the second target subdirectory if the remaining target subdirectories include the first subdirectory, and combine the first subdirectory with the current target subdirectory to obtain a second directory subset. A search unit, which is used to obtain a second subdirectory with a directory size closest to the difference value from the remaining target subdirectories based on the difference value if the remaining target subdirectories do not include the first subdirectory. A first calculation unit, which is used to obtain a first variance value based on the square of the difference between the second subdirectory size of the second subdirectory and the difference value. A second calculation unit, which is used to obtain a second variance value based on the square of the difference between the directory size of the current target subdirectory and the difference value. A second subdirectory combination unit, which is used to determine a second target subdirectory from the remaining target subdirectories based on the comparison result between the set benchmark size and the first variance value and the second variance value, and combine the second target subdirectory with the current target subdirectory to obtain a second directory subset.
[0118] In another embodiment, the apparatus further includes: a sixth determining unit, configured to determine, in response to the received transmission failure instruction, at least one third directory subset to be re-concurrently transmitted, wherein the third directory subset is a directory subset of the first number of directory subsets for which concurrent transmission fails. The transmission unit 803 is further configured to re-concurrently transmit the at least one third directory subset to the receiving device.
[0119] In another embodiment, the apparatus further comprises: a reading unit, configured to read the second target directory received by the receiving device if the concurrent transmission ends; and a checking unit, configured to perform consistency checking between the second target directory and the first target directory to determine whether the second target directory is complete.
[0120] The specific definition and beneficial effects of the above-mentioned transmission device for massive small files can be found in the above-mentioned definition of the transmission method for massive small files, which will not be repeated here. The above-mentioned modules can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned modules.
[0121] Fig. 9 FIG. 1 is a schematic diagram of a hardware structure of a computer device according to an exemplary embodiment. Fig. 9 As shown, the device includes one or more processors 960 and a memory 920, and the memory 920 includes a persistent memory, a volatile memory, and a hard disk. Fig. 9 A processor 960 is taken as an example. The device may also include: an input device 930 and an output device 940.
[0122] The processor 960, the memory 920, the input device 930 and the output device 940 may be connected via a bus or other means. Fig. 9 The example of connecting through bus is taken in the following.
[0123] The processor 960 may be a central processing unit (CPU). The processor 960 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips. A general-purpose processor may be a microprocessor or the processor may be any conventional processor.
[0124] The memory 920, as a non-transient computer-readable storage medium, includes a persistent memory, a volatile memory, and a hard disk, and can be used to store non-transient software programs, non-transient computer executable programs, and modules, such as program instructions / modules corresponding to the business management method in the embodiment of the present application. The processor 960 executes various functional applications and data processing of the server by running the non-transient software programs, instructions, and modules stored in the memory 920, that is, realizing any of the above-mentioned methods for transmitting a large number of small files.
[0125] The memory 920 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data required for use, etc. In addition, the memory 920 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 920 may optionally include a memory remotely arranged relative to the processor 960, and these remote memories may be connected to the data processing device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0126] The input device 930 can receive input digital or character information and generate key signal input related to user settings and function control. The output device 940 can include display devices such as display screens.
[0127] One or more modules are stored in the memory 920, and when executed by one or more processors 960, the execution is as follows: Figure 1-Figure 7 The method shown.
[0128] The above-mentioned product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to Figure 1-Figure 7 Related description of the illustrated embodiment.
[0129] The embodiment of the present invention also provides a non-transitory computer storage medium, which stores computer executable instructions, and the computer executable instructions can execute the authentication method in any of the above method embodiments. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memory.
[0130] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the invention.
Claims
1. A method for transmitting a large number of small files, characterized in that: The method comprises: Scan the server to obtain directory information of a first target directory storing a large number of small files, wherein the directory information includes a directory tree structure of the first target directory and a directory size of the first target directory; Based on the concurrent transmission quantity of the server and the directory tree structure, splitting the first target directory to obtain a first number of directory subsets, including: determining a set base size of the directory subset according to a quotient between the directory size and the concurrent transmission quantity; determining a split base size of the directory subset according to a product between the set base size and a specified split factor; determining a directory size of each subdirectory in the directory tree structure respectively; splitting the first target directory based on the set base size, the split base size and the directory size of each subdirectory to obtain a first number of directory subsets, wherein each directory subset includes at least one target subdirectory; The first number of directory subsets are concurrently transmitted to a receiving device, so that the receiving device obtains the massive small files.
2. The method according to claim 1, characterized in that The step of splitting the first target directory based on the set reference size, the split reference size, and the directory size of each sub-directory to obtain a first number of directory subsets includes: Determine the node type of each subdirectory in the directory tree structure respectively; Determine the target subdirectory according to the node type and / or directory size of each subdirectory, and obtain a second number of target subdirectories, wherein the target subdirectory is a subdirectory whose node type is a leaf node type, or a subdirectory whose directory size is smaller than the splitting benchmark size; Based on the set reference size and the directory size of each target sub-directory, the second number of target sub-directories are combined to obtain the first number of directory subsets.
3. The method according to claim 2, characterized in that The first number of directory subsets includes a first directory subset and / or a second directory subset; the second number of target subdirectories are combined based on the set reference size and the directory size of each target subdirectory to obtain the first number of directory subsets, including: sorting the second number of target subdirectories from largest to smallest according to the directory size of each target subdirectory; Traversing the second number of target sub-directories according to the sorting result, if the directory size of the current target sub-directory is greater than or equal to the set reference size, dividing the current target sub-directory separately to form a first directory subset; If the directory size of the current target subdirectory is smaller than the set benchmark size, then based on the difference between the directory size of the current target subdirectory and the set benchmark size, a second target subdirectory combined with the current target subdirectory is determined from the remaining target subdirectories to obtain a second directory subset.
4. The method according to claim 3, characterized in that The step of determining a second target subdirectory combined with the current target subdirectory from the remaining target subdirectories based on the difference between the directory size of the current target subdirectory and the set reference size, to obtain a second directory subset, comprises: Based on the difference, traverse the remaining target subdirectories to see whether there is a first subdirectory whose directory size is equal to the difference; If the remaining target subdirectories include the first subdirectory, determining the first subdirectory as the second target subdirectory, and combining the first subdirectory with the current target subdirectory to obtain a second directory subset; If the remaining target subdirectories do not include the first subdirectory, based on the difference, obtaining a second subdirectory from the remaining target subdirectories whose directory size is closest to the difference; Obtaining a first variance value according to the square of a difference between the second subdirectory size of the second subdirectory and the difference value; Obtaining a second variance value according to the square of the difference between the directory size of the current target subdirectory and the difference value; Based on the comparison result between the set reference size and the first variance value and the second variance value, the second target subdirectory is determined from the remaining target subdirectories, and the second target subdirectory is combined with the current target subdirectory to obtain a second directory subset.
5. The method according to claim 1, characterized in that The method further comprises: In response to the received transmission failure instruction, determining at least one third directory subset to be re-transmitted concurrently, wherein the third directory subset is a directory subset of the first number of directory subsets for which concurrent transmission fails; The at least one third directory subset is retransmitted concurrently to the receiving device.
6. The method according to claim 1 or 5, characterized in that: The method further comprises: If the concurrent transmission ends, reading the second target directory received by the receiving device; A consistency check is performed on the second target directory and the first target directory to determine whether the second target directory is complete.
7. A transmission device for a large number of small files, characterized in that: The device comprises: A scanning unit, used for scanning a server to obtain directory information of a first target directory storing a large number of small files, wherein the directory information includes a directory tree structure of the first target directory and a directory size of the first target directory; The splitting unit is used to split the first target directory based on the concurrent transmission quantity of the server and the directory tree structure to obtain a first number of directory subsets, including: determining a set reference size of the directory subset according to a quotient between the directory size and the concurrent transmission quantity; determining a split reference size of the directory subset according to a product between the set reference size and a specified split factor; determining a directory size of each subdirectory in the directory tree structure respectively; splitting the first target directory based on the set reference size, the split reference size and the directory size of each subdirectory to obtain a first number of directory subsets, wherein each directory subset includes at least one target subdirectory; The transmission unit is used to concurrently transmit the first number of directory subsets to a receiving device, so that the receiving device obtains the massive small files.
8. A computer device, characterized in that: It comprises a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for transmitting a large number of small files according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method for transmitting a large number of small files according to any one of claims 1 to 6.
Citation Information
Patent Citations
File downloading method and device and storage medium
CN110784528A
