Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# HttpClient slow uploading speed

Tags:

I'm trying to upload large (50 MB - 32 GB) files to Google.Drive. I'm using google-api-dotnet which provides upload logic and encryption support. The main problem is slow uploading speed.

I looked through api source code. Each file is uploaded by chunks (I set chunk size to 4 MB) Each chunk is uploaded via new HttpRequestMessage instance. HttpClient is created once the api service started and reused for all requests.

The upload speed is 600 kbytes/s and stable while my uplink is 10 times faster.

I captured traffic with Wireshark: slow-uploading-screenshot Each chunk is divided into hundreds or thousands small TLS packets. And for each small TLS packed a confirmation is expected. So the resulting speed is very low.

But when I start Fiddler proxy, the speed becomes as fast as my uplink can do. The TLS packets going very fast in parallel and the confirmations are received later: tls-packets-first-screenshottcp-ack-later

I tried my code on 5 PC's with Win7 and all showed similar low uploading speed. But when I tried on Win10 PC - the speed was very good. Also I tried Google.Drive client application and it had same problems with speed. I tried to search about this behaviour, but I didn't found anything.

  1. Why are 4 MB chunks divided into 4 KB TLS packets? Can I increase TLS packets size?
  2. How can I make the TLS packets sending in parallel as Fiddler does?
  3. Or is there other methods of increasing upload speed?
like image 615
Ivan Peresedov Avatar asked Nov 22 '15 17:11

Ivan Peresedov


1 Answers

It is highly possible that the problem is the google link, not anything else. I have been uploaded things to google drive with chrome and besides my upload link is giant (50mbps up), google seems limited.

like image 64
user7358693 Avatar answered Sep 21 '22 15:09

user7358693