1

I was wondering if it is possible to increase buffer size on WebClient Async data upload, because currently it pushes ~320kB/s maximum.

My current code:

using (WebClient Client = new WebClient())
{
    byte[] Buffer = File.ReadAllBytes(this.WorkItem.FileLocation);

    Client.UploadProgressChanged += new UploadProgressChangedEventHandler(Client_UploadProgressChanged);
    Client.UploadDataCompleted += new UploadDataCompletedEventHandler(Client_UploadDataCompleted);
    Client.UploadDataAsync(new Uri("-snip-"), Buffer);
}

Edit
Connection is not the limiting factor. ( its 300mbit connection, web-servers push content at ~30-40mB/s mark )

Miz
  • 81
  • 9
  • and what's the speed of your connection? – nothrow Jul 30 '12 at 10:41
  • Are you sure that isn't the limit of your network / connection? 0.3Mbps upstream sounds about right for many connections... – Marc Gravell Jul 30 '12 at 10:41
  • Re your edit; is this you calling to yourself? pretty much any other combination there may be other factors that throttle you... – Marc Gravell Jul 30 '12 at 10:56
  • I have tested Dedicated server to Other dedicated server in same datacenter and Me to dedicated server. Speeds are same in both cases. – Miz Jul 30 '12 at 10:59

1 Answers1

3

If you want more control over how the data is buffered you need to use the HttpWebRequest class. With this class you can choose your read buffer reading from a FileStream and then how much you are writing to the network stream. Doing 4MB reads and 32KB writes was optimal for maxing out my network throughput (although you will have to do your own benchmarks to see which buffers work best in your scenario).

Despertar
  • 21,627
  • 11
  • 81
  • 79