Method and system for dynamically uploading data files in pieces
By dynamically adjusting the shard size and number of concurrencies, combined with network status monitoring and fault-tolerance mechanisms, the stability and efficiency issues of data file uploading in changing network environments are solved, and stable and fast uploading of data files is achieved.
Patent Information
- Application Number
- CN202211588894.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-12
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-12-12
AI Technical Summary
Existing data file upload technology is difficult to achieve stable and fast upload in changing network environments, and resource occupancy is uneven, resulting in data interruption and low efficiency.
Adopting the dynamic fragmented upload method of data files, by dynamically adjusting the fragment size and the number of concurrency, combined with network condition monitoring and fault-tolerance mechanisms, the fragmented upload scheme is optimized to ensure the stability and rapid upload of data files.
It maximizes the stable and fast upload of data files, improves the upload efficiency and success rate, and ensures the success of file transfer especially when the network condition is poor.
Smart Images

Figure CN116016549B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data communication, relates to a data file uploading technology, and specifically relates to a method and a system for dynamically uploading data files in segments. Background Art
[0002] Data file upload is affected by many factors. The real network environment is changeable and there are multiple files being transmitted concurrently, which inevitably leads to data interruption, loss, or malfunctions. If the uploaded data is the same large file and undergoes a change in network status, such as from 5G to 3G, or from wireless to 5G, it is difficult for the data to be transmitted successfully at one time. When receiving large file transmissions, the receiving end may experience problems such as uneven resource usage and low efficiency.
[0003] Therefore, a new technical solution is needed to solve these problems. Summary of the invention
[0004] Purpose of the invention: In order to overcome the deficiencies in the prior art, a method and system for dynamically uploading data files in segments are provided, which solves the problem of uploading data files in segments under a changeable network environment. The segment uploading is also the beginning of network status monitoring. The completed segment upload results are important reference data for the dynamic allocation scheme, thereby maximizing the allocation upload efficiency and success rate, and achieving the final stable and fast upload of data files.
[0005] Technical solution: To achieve the above purpose, the present invention provides a method for dynamically uploading data files in pieces, comprising the following steps:
[0006] S1: Create a new shard task and obtain the recommended shard size, recommended number of concurrent connections, and the unique ID of the corresponding upload task;
[0007] S2: Check whether there is recent upload speed data. If not, use the recommended shard size and recommended concurrency number obtained in step S1 as the allocation plan; if there is recent upload speed data, calculate the shard size and concurrency number as the allocation plan based on the recent upload shard speed data and concurrency number;
[0008] S3: Execute the upload according to the allocation scheme obtained in step S2, and record the uploaded shard size, number of concurrent uploads, and upload time;
[0009] S4: According to the multi-segment upload result, confirm whether all the segments are uploaded successfully. If so, merge the uploaded segments to complete the multi-segment upload task; if not, start the fault tolerance mechanism.
[0010] Furthermore, the shard size and the number of concurrent connections recommended in step S1 are the shard size and the number of concurrent connections preset in advance.
[0011] Furthermore, the calculation method of the slice size and the number of concurrent connections in step S2 is: the initial default slice size is 4M, and the number of concurrent connections is the number of CPU cores of the server; the minimum slice size is 1K, and the number of concurrent connections is twice the number of CPU cores of the server. The speed base reference value is 16KB / S.
[0012] Optionally, the settings of the above-mentioned initial fragment size and speed base can be preset preferred values according to actual conditions. For example, the fragment size can be adjusted when the network infrastructure is good.
[0013] The calculation is divided into two stages and one exception:
[0014] The first case is the initial stage. The initial default concurrency number C and the default fragment size P are used for uploading to obtain the speed V. If the speed is lower than the above base value, this stage ends. If the speed is higher than the above base value, the default fragment size P2 is increased (it can be increased by 4M or doubled) to obtain V2. If V2>
[0015] V1*110%, then P=P2, V=V2, and continue to expand the shards; if V2<=V1*110%, end this stage;
[0016] Optionally, the above ratio value 110% is a preferred value that can be preset according to actual conditions.
[0017] The second stage: dynamic testing and tuning; detect in four directions of C and P increase and decrease (without exceeding the limit), add 1 or subtract 1 to the number of shards C, and increase or decrease P (if less than 4M, double or halve, if more than 4M, increase by 4M, decrease by 4M but the minimum is 4M), get 4 speed values, select the largest speed, if this maximum speed value is greater than the current V*110%, update C, V and P, and continue in this direction, of course, do not exceed the limit of C and P. In this way, a maximum speed value is obtained, and after running for a period of time, this detection is continued; during stable operation, if the speed also changes significantly (for example, the speed changes by 30%), this detection can also be started.
[0018] Exception handling: If an exception is encountered during the transmission of the shards, such as a connection interruption or a server return error, the concurrency number is adjusted to 1. If an error still occurs at this time, the shards are halved until the transmission is normal. If it runs normally for a period of time, the second stage mentioned above can be entered again.
[0019] Furthermore, the uploaded segment size, concurrent number and upload time recorded in step S3 form a query list, which can be used to query the status of uploading in progress and uploaded. The results of uploaded can be a reference for the next segment upload allocation.
[0020] Furthermore, in the step S1, the recommended fragment size and the number of concurrent connections are determined according to a preset transmission duration threshold.
[0021] Furthermore, in the process of uploading the segments in step S3, the completed continuous segments are automatically merged first to generate the segmentation results.
[0022] Furthermore, the fault tolerance mechanism in step S4 includes abnormal segment upload and incomplete data. According to the query list and the data of the most recent upload speed, the process returns to step S2.
[0023] Furthermore, in step S4, when the server merges the uploaded results, it needs to re-verify the MD5 of the entire file and use segmented hash calculation to merge the uploaded results, that is, the segmented results are synchronously calculated and verified when the segments are uploaded, and can be directly merged and returned to the client after confirming the integrity.
[0024] The purpose of the present invention is to solve the problem of 99% progress being stuck for a long time. In traditional piece-by-piece uploading, there may be no verification or the verification time is too long when the files are merged at the end, resulting in the 99% progress lasting for a while. The present invention reduces the verification time to a level that is almost imperceptible, and there is no longer a 99% stagnation.
[0025] The solution of the present invention is to preset the value of the segment, so as to calculate the value that is more suitable for solving the actual technical problem, and the segment can be multiple segments, or a fixed segment hash can be used for calculation. The exact value is not mentioned in detail here, because the content of this document provides a method, and the reader can adjust the value preset suitable for solving the problem by combining the method with the actual operation.
[0026] The present invention also provides a data file dynamic segmentation uploading system, comprising a client and a server;
[0027] The client is used to create a sharding task, send a sharding request to the server, decide the sharding size and the number of concurrent sharding according to the network conditions, and obtain the data file result;
[0028] The server is the corresponding background for processing data files. The server is used to accept the fragmentation request from the client, combine the received fragments, and return the combined request result accordingly.
[0029] The client comprises:
[0030] The creation module is used to create new upload tasks and send existing files to be uploaded to the server;
[0031] The query module is used to generate a query list, which can query the details of the upload being completed and the uploaded files;
[0032] The client management module is used to allocate the size and concurrency of multi-segment uploads, reasonably calculate the currently available network link transmission rate based on the uploaded segments, and dynamically allocate the optimal multi-segment upload solution.
[0033] The server comprises:
[0034] The server management module is used to send the UploadId of the data file upload task, preferentially merge the completed continuous fragments, and merge the fragment results by segment hash;
[0035] The judgment module is used to judge the transmission time of the segment upload, compare it with the preset threshold interval, and judge whether the segment upload result message (whether it is abnormal) is returned;
[0036] The confirmation module is used to accept the upload task, confirm whether the recent upload speed data is recorded, confirm the execution of the sharding task, and return the merge result and index information after confirming the integrity.
[0037] The present invention provides a method and system for uploading data in dynamic segments, which has the functions of dynamic segmentation (the size of each segment can be dynamically adjusted according to the previous upload record), can judge the network situation, and supports the concurrent upload of multiple segments. The problem of uploading data files in segments under a changeable network environment is solved. The segment upload is also the start of network status monitoring. The completed segment upload results are important reference data for the dynamic allocation scheme, thereby maximizing the allocation upload efficiency and success rate, and realizing the final stable and fast upload of data files.
[0038] Regarding the success rate, it mainly refers to very poor network conditions. If 1M+ of data is transmitted at one time, it will not succeed no matter what. If the segmentation is adjusted to less than 1M, it will succeed. Then this dynamic segmentation can make the file succeed even when the network conditions are poor, so it can maximize the distribution upload efficiency and success rate.
[0039] Beneficial effects: Compared with the prior art, the present invention provides a method and system for dynamically uploading data in segments, which realizes simultaneous uploading of multiple files and solves the concurrency problem; the dynamic segmentation scheme based on network status optimizes the shortcomings of unstable network status, transmission interruption, and unbalanced resource allocation and low efficiency. What is more prominent is that it is suitable for scenarios with large network dynamic changes such as riding in transportation or sharing networks to achieve fast, stable and successful end-to-end data upload. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a three-stage schematic diagram of the method of the present invention;
[0041] Figure 2 The figure is an overall flow chart of the method of the present invention. DETAILED DESCRIPTION
[0042] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.
[0043] The present invention provides a data file dynamic segmentation uploading system, comprising a client and a server;
[0044] The client includes mobile terminals, PC terminals, Web terminals and other terminals, which are used to create sharding tasks, send sharding requests to the server, decide the sharding size and the number of concurrent sharding according to the network conditions, and obtain the data file results;
[0045] The server is the corresponding background for processing data files. The server is used to accept the client's sharding request, combine the received shards, and return the merged request result accordingly.
[0046] The client includes:
[0047] The creation module is used to create new upload tasks and send existing files to be uploaded to the server;
[0048] The query module is used to generate a query list, which can query the details of the upload being completed and the uploaded files;
[0049] The client management module is used to allocate the size and concurrency of multi-segment uploads, reasonably calculate the currently available network link transmission rate based on the uploaded segments, and dynamically allocate the optimal multi-segment upload solution.
[0050] The server includes:
[0051] The server management module is used to send the UploadId of the data file upload task, preferentially merge the completed continuous fragments, and merge the fragment results by segment hash;
[0052] The judgment module is used to judge the transmission time of the segment upload, compare it with the preset threshold interval, and judge whether the segment upload result message (whether it is abnormal) is returned;
[0053] The confirmation module is used to accept the upload task, confirm whether the recent upload speed data is recorded, confirm the execution of the sharding task, and return the merge result and index information after confirming the integrity.
[0054] Based on the above data file dynamic segmentation uploading system, the present invention provides a data file dynamic segmentation uploading method, such as Figure 1 As shown, the method can be generally divided into three stages, namely, the segment pre-upload stage, the segment upload stage and the segment upload completion stage.
[0055] Reference Figure 1 and Figure 2 The specific process of this method includes the following steps:
[0056] S1: Segment pre-upload stage:
[0057] Create a new sharding task through the client creation module and send a pre-upload task instruction to the server;
[0058] After receiving the instruction, the server obtains the upload task and returns the recommended shard size, recommended number of concurrent connections and the unique ID (UploadId) of the corresponding upload task to the client through the server management module;
[0059] The recommended shard size and concurrent number are the pre-set shard size and concurrent number, and are determined according to the pre-set transmission time threshold;
[0060] UploadId will serve as the unique identifier of the upload task and as the basis for subsequent data file segment uploads.
[0061] S2: Multi-part upload phase:
[0062] After accepting the recommendation result from the server, the client starts uploading and checks whether there is recent upload speed data through the query module. If not, the recommended shard size and recommended concurrency number obtained in step S1 are used as the allocation plan; if there is recent upload speed data, the shard size and concurrency number are calculated based on the recent upload shard speed data and concurrency number as the allocation plan;
[0063] The calculation method of shard size and concurrency is as follows: the initial default shard size is 4M, and the concurrency is the number of CPU cores of the server; the minimum shard size is 1K, and the concurrency is twice the number of CPU cores of the server. The speed base reference value is 16KB / S.
[0064] The calculation is divided into two stages and one exception:
[0065] The first case is the initial stage. First, use the initial default concurrency number C and the default fragment size P to upload and get the speed V. If the speed is lower than the base number, this stage ends. If the speed is higher than the base number, the default fragment size P2 is enlarged (it can be increased by 4M or doubled) to get V2. If V2>V1*110%, P=P2, V=V2, and continue to expand the fragment. If V2<=V1*110%, this stage ends.
[0066] The second stage: dynamic testing and tuning; detect in four directions of C and P increase and decrease, add 1 or decrease 1 to the number of shards C, and increase or decrease P (if less than 4M, double or halve, if more than 4M, increase by 4M, decrease by 4M but the minimum is 4M), get 4 speed values, select the largest speed, if this maximum speed value is greater than the current V*110%, update C, V and P, and continue in this direction, of course, do not exceed the limit of C and P. In this way, a maximum speed value is obtained, and after running for a period of time, this detection is continued; during stable operation, if the speed also changes significantly (for example, the speed changes by 30%), this detection can also be started.
[0067] Exception handling: If an exception is encountered during the transmission of the shards, such as a connection interruption or a server return error, the concurrency number is adjusted to 1. If an error still occurs at this time, the shards are halved until the transmission is normal. If it runs normally for a period of time, the second stage mentioned above can be entered again.
[0068] S3: Execute the upload according to the allocation scheme obtained in step S2, and record the uploaded shard size, number of concurrent uploads, and upload time;
[0069] Here, the allocation arrangement during multi-segment upload is a dynamic process. The start of multi-segment upload is also the beginning of judging the network status. The upload results (such as the upload time) after the subsequent multi-segment upload is successful will be recorded in sequence to form a <query list>, which can be used to query the status of upload completion and upload completion. The uploaded results can serve as a reference for the next multi-segment upload allocation.
[0070] Through the judgment module, the number of concurrent shards and the size of the shards can be used to calculate the currently available network link transmission rate (number of concurrent shards * size of shards), and the corresponding relationship can also be used to determine the current network status. Conversely, the upload speed data of the shards can also serve as a reference for the size of the shards and the number of concurrent shards, so that when multiple files are uploaded concurrently, the data calculated for the network status can be reused, and the subsequent uploaded files can reuse the previous network performance data as appropriate.
[0071] S4: Multipart upload completion stage:
[0072] The server uses the confirmation module to confirm whether all the segments have been uploaded successfully based on the segment upload results. If so, the uploaded segments are merged. The server returns the multiple segment upload results to the client, accepts the merge request sent by the client, and returns the merge result and file index information to the client after confirming the integrity, thus completing the segment upload task;
[0073] Here, during the process of uploading fragments, the server can automatically merge completed continuous fragments first to generate fragment results, thereby reducing the data pressure during network transmission;
[0074] When the server merges the uploaded results, it needs to re-verify the MD5 of the entire file. It uses segmented hash calculation to merge the uploaded results. That is, it synchronously calculates and verifies the fragment results when uploading fragments. After confirming the integrity, it can be directly merged and returned to the client, thus avoiding the jamming problem caused by merging large files and improving the merging efficiency.
[0075] The server will pre-set the transmission time threshold. If the transmission time of the current segment upload exceeds the preset threshold, the segment size and concurrency number of the next segment can be reasonably adjusted accordingly. For example, if the segment upload is completed at 1 / 2 of the set threshold interval, the segment size can be increased or the number of segment concurrency can be increased to ensure the success rate of high data segment upload and improve upload efficiency;
[0076] If the server confirms that not all shards have been uploaded successfully, the fault tolerance mechanism is activated, and the abnormal situation is determined by the judgment module through the query list and the data of the recent upload speed;
[0077] If the upload is resumed, you can first query the size of the uploaded segments;
[0078] If there is an abnormal situation in the multi-part upload process, you need to request confirmation <query list> to confirm the uploaded parts, so as to determine the completed parts, so as to ensure the continued upload of the unfinished parts;
[0079] If the server fails to return the upload result normally, you can confirm the <query list> to confirm the status of the shards to be processed;
[0080] If an error occurs in multi-part upload, confirm the <query list> according to the abnormal situation of the error and try to upload again;
[0081] The multi-segment upload task management sets an automatic cleanup interval, and a certain time interval is preset to clean up the file data that has not been successfully uploaded.
[0082] This embodiment also provides a data file dynamic segmented upload system, which includes a network interface, a memory and a processor; wherein the network interface is used to realize the reception and transmission of signals in the process of sending and receiving information between other external network elements; the memory is used to store computer program instructions that can be run on the processor; the processor is used to execute the steps of the above-mentioned consensus method when running the computer program instructions.
[0083] The present embodiment also provides a computer storage medium, which stores a computer program, and the method described above can be implemented when the processor executes the computer program. The computer readable medium can be considered to be tangible and non-temporary. Non-limiting examples of non-temporary tangible computer-readable media include non-volatile memory circuits (such as flash memory circuits, erasable programmable read-only memory circuits or mask read-only memory circuits), volatile memory circuits (such as static random access memory circuits or dynamic random access memory circuits), magnetic storage media (such as analog or digital tapes or hard drives) and optical storage media (such as CDs, DVDs or Blu-ray discs), etc. The computer program includes processor executable instructions stored on at least one non-temporary tangible computer-readable medium. The computer program may also include or rely on stored data. The computer program may include a basic input / output system (BIOS) that interacts with the hardware of a special-purpose computer, a device driver that interacts with a specific device of a special-purpose computer, one or more operating systems, user applications, background services, background applications, etc.
[0084] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0085] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.
[0086] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0087] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
Claims
1. A method for dynamically uploading data files in pieces, characterized in that: The steps include: S1: Create a new shard task and obtain the recommended shard size, recommended number of concurrent connections, and the unique ID of the corresponding upload task; S2: Check whether there is recent upload speed data. If not, use the recommended shard size and recommended concurrency number obtained in step S1 as the allocation plan; if there is recent upload speed data, calculate the shard size and concurrency number as the allocation plan based on the recent upload shard speed data and concurrency number; S3: Execute the upload according to the allocation scheme obtained in step S2, and record the uploaded shard size, number of concurrent uploads, and upload time; S4: According to the multi-segment upload result, confirm whether all the segments are uploaded successfully. If yes, merge the uploaded segments to complete the multi-segment upload task; if not, start the fault tolerance mechanism; The calculation of shard size and concurrency in step S2 is divided into two stages and one exception: Initial stage: First use the initial default concurrency number C and default fragment size P to upload, and get the speed V; If the speed is lower than the base value, this phase ends; if the speed is higher than the base value, the default shard size P2 is expanded to get V2; if V2> V*110%, P=P2, V=V2, and the shards continue to expand; if V2 <= V*110%, this phase ends; The second stage: dynamic testing and tuning; perform detection in four directions of C and P increase and decrease, add 1 or subtract 1 to the number of shards C, and increase or decrease P, and get 4 speed values. Select the largest speed. If this maximum speed value is greater than the current V*110%, update C, V and P, and continue in this direction, of course, do not exceed the limits of C and P; get a maximum speed value in this way, run for a period of time, and then continue this detection; Abnormal situation handling: If an abnormality is encountered during the transmission of shards, the concurrency number is adjusted to 1. If errors still occur at this time, the shards are halved until the transmission is normal; If it runs normally for a period of time, it can enter the second stage mentioned above; In step S4, when the server merges the uploaded results, it needs to re-verify the MD5 of the entire file and use segmented hash calculation to merge the uploaded results, that is, when uploading the fragments, it synchronously calculates and verifies the fragment results, and after confirming the integrity, it can be directly merged and returned to the client.
2. A method for dynamically uploading data files in pieces according to claim 1, characterized in that: The shard size and the number of concurrent connections recommended in step S1 are the shard size and the number of concurrent connections preset in advance.
3. A method for dynamically uploading data files in pieces according to claim 1, characterized in that: The uploaded segment size, concurrent number and upload time recorded in step S3 form a query list, which can be used to query the status of uploading being completed and uploaded. The results of uploaded can be a reference for the next segment upload allocation.
4. A method for dynamically uploading data files in pieces according to claim 2, characterized in that: In the step S1, the recommended fragment size and the number of concurrent connections are determined according to a preset transmission duration threshold.
5. A method for dynamically uploading data files in pieces according to claim 1, characterized in that: In the process of uploading the segments in step S3, the completed continuous segments are automatically merged first to generate the segmentation results.
6. A method for dynamically uploading data files in pieces according to claim 3, characterized in that: The fault tolerance mechanism in step S4 includes abnormal segment upload and incomplete data. According to the query list and the data of the most recent upload speed, return to step S2.
7. The data file dynamic segmentation uploading system according to the method of claim 1, characterized in that: comprising a client for executing steps S1 to S3 and a server for executing step S4; The client is used to create a sharding task, send a sharding request to the server, decide the sharding size and the number of concurrent sharding according to the network conditions, and obtain the data file result; The server is the corresponding background for processing data files. The server is used to accept the fragmentation request from the client, combine the received fragments, and return the combined request result accordingly.
8. The data file dynamic segmentation uploading system according to claim 7 is characterized in that: The client comprises: The creation module is used to create new upload tasks and send existing files to be uploaded to the server; The query module is used to generate a query list, which can query the details of the upload being completed and the uploaded files; The client management module is used to allocate the size and concurrency of multi-segment uploads, calculate the currently available network link transmission rate based on the uploaded segments, and dynamically allocate the optimal multi-segment upload solution.
9. The data file dynamic segmentation uploading system according to claim 7, characterized in that: The server comprises: The server management module is used to send the Upload ID of the data file upload task, preferentially merge the completed continuous fragments, and merge the fragment results by segment hash; A judgment module is used to judge the transmission time of the multi-segment upload, compare it with the preset threshold interval, and judge and return the multi-segment upload result message; The confirmation module is used to accept the upload task, confirm whether the recent upload speed data is recorded, confirm the execution of the sharding task, and return the merge result and index information after confirming the integrity.
Citation Information
Patent Citations
A cross-network breakpoint resuming method and system
CN109714330A
Fragmentation uploading method and device, equipment and storage medium
CN113518108A
File fragment uploading verification method and system
CN113938269A
File transmission method based on http (Hyper Text Transfer Protocol) at web end
CN114915622A
File uploading method and file uploading system
CN115412547A
