Reputation: 4511
I have a javascript downloader that gets big files by multiple HTTP range requests:
xhr.setRequestHeader("Range", "bytes=" + start + "-" + end);
while end is
var end = start + length
The range request is a must, because I need to get specific offsets in the file (think a download from multiple HTTP servers) If the downloader is about to download ~100MB file using this method, what is the optimal length for good throughput?
Upvotes: 2
Views: 1076
Reputation: 11611
I'm afraid that there's no simple answer to your question. There are many types of connections, and for every pair of client-server the answer would be different, depending on the latency, the bandwidth, the quality of the connection, the frequency of disconnections, and even more complex stuff, since in certain situations there might be a limit on the number of parallel connections, on the maximum size transfered in one request, and so on. If you're only interested in a certain kind of such scenarios, like a fast, good connection to a nearby server, then I'd say that the value you choose doesn't matter that much since the connection overhead is usually under a tenth of a second.
It also depends on what you do with the response; if you load it in memory, then take into account that you're going to consume memory from a computer that you don't know, and assuming that nobody would mind an extra 16Mb consumed for a segment is a big assumption.
Upvotes: 1