I'm using HTTP API provided by MS to upload video to YouTube, I noticed the total elapsed time is different with different buffer size, what size of buffer is the best for uploading file to internet? Thanks in advance.
Try it out. Depends on your network speed and other settings. If there would be the one optimal size, it would have been preconfigured.
The right one?
TCP/IP has lots of self-tuning functionality built in (although by default window scaling is disabled). If you are seeing different behaviours using different application level buffers then this is most likely due to anomolies within the application code. If the code is closed-source then you can only ever do black box testing to find the optimal behaviour. However at a guess it sounds like the source reads are delayed until the buffer is empty - try using rotating buffers with a pre-fetch, e.g.
i) read X bytes into buffer 1
ii) start writing buffer 1 to the output in a seperate thread
iii) read X bytes into buffer 2
iv) when the thread created in ii returns, swap the buffers around and repeat steps from ii
C.