Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

downloading with curl using multiple connections

I'm trying to tranfer a multi-gb file from one server to another; problem is RTT is 150ms+. Ive already tried using aria2 but its limited to 16 connections, lftp doesn't have any protection against stalled transfers.

I'm wondering if its possible to download one file with multiple connections using curl cli.

like image 266
user1030749 Avatar asked Dec 04 '11 21:12

user1030749


2 Answers

It's possible. Fetch the total file size with -I option in curl.

Then you can fork many process in a shell, every curl connection with a different Content-Length header to download different part of the file.

After all the tasks finish, then merge all the download slices to a big file.

I have written a simple script and it's available here mcurl.sh, with -s option you can specify how many tasks you create to download the big file.

like image 145
alijandro Avatar answered Oct 07 '22 09:10

alijandro


No, the curl tool has no such ability built-in. To do it with curl, you need to invoke it multiple times with range downloads.

(oh and btw, a large RTT is very rarely the explanation to why a plain TCP transfer is slow)

like image 24
Daniel Stenberg Avatar answered Oct 07 '22 09:10

Daniel Stenberg