3

I'm creating a service that will download files from a server, I Have a limited knowledge in this area and am asking advise on the settings for the service.

I have ruled out full file buffering on account of the memory usage that would impact on the server.

Which binding would be best used in a WCF for streaming downloads securely ? wsHttpBinding, basicHttpBinding, netTcpBinding etc

and if its not too much trouble could you write a few lines saying why your answer suits the functionality correctly ? (so i learn from the answer)

Thanks

ry4n

(currently working on Vs2008)

Also what format would information best be returned to be consumed by android ?

Update* More info: File Sizes: Between 1MB and 1GB, Multiple downloads concurrently.

Which WCF configurations should i employ to achieve this functionality ?

RY4N
  • 1,080
  • 3
  • 14
  • 31
  • 1
    i would suggest google brings up a couple of good links - this being one candidate: http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP – dice Mar 08 '12 at 11:53
  • or even better: http://blogs.msdn.com/b/endpoint/archive/2010/11/24/streaming-over-http-with-wcf.aspx ;) – dice Mar 08 '12 at 12:09
  • I think those simple examples don't take into account fact, that both IIS and WCF client like to buffer whole file into memory, before sending/recieving it. Thanks to that, we have our own complex infrastructure for file download/upload, to get around this problem. – Euphoric Mar 08 '12 at 12:20
  • How large will the downloads be? U could also use a download manager like windows BITS or a wrapper around it like SharpBITS http://www.codeproject.com/Articles/14727/SharpBITS-NET-A-Wrapper-for-the-BITS-API Windows Update uses BITS as well. – rfcdejong Mar 08 '12 at 13:54
  • they could be quite large 1GB+, I updated the above question with more info – RY4N Mar 08 '12 at 15:50
  • @Euphoric - Memory is cheap now-a-days, why not just allow IIS and WCF to do the buffering and add a few more sticks of RAM to that server? – evasilchenko Mar 08 '12 at 16:04
  • @ DevientSeev there could be up to 1000+ people using this at a time, that would be more than 1,000(gb) sticks if they dl 1GB files. buffering loads the whole message into ram.... unless you choose transport streaming in which case .. u buffer a few kb only then steam. – RY4N Mar 08 '12 at 16:23
  • http://stackoverflow.com/questions/1613586/c-sharp-wcf-inter-process-communication/1613601#1613601 – Matt Davis Mar 08 '12 at 19:31

1 Answers1

1

Not Streamed Mode: To most people familiar with WCF will say NetTcp with TransferMode.Streamed, however there are serious performance problems with that. Streaming will let you accommodate more concurrent downloads because it will not hog server's memory but WCF has a non-override-able stream chunks size, it slows down the download, a file over 100MB will be significantly slower that any other methods.

I suggest implement chunking method method, such as

byte[] GetBytes(int chunkNumber);

At the client side you can stitch the chunks as you download. Use HttpBinding for interoperability, since all you are transferring are bytes you will not incur too much overhead over NetTcp binding.