Uploading files to WCF service approaches

I have a WCF service that I can load.

XElement upload = service.UploadFiles(id, File.ReadAllBytes(filePath));

      

This works, but I'm just wondering if the best way is to download each one one by one when you have many (about a thousand) small files (15 ~ 20K). How can we compare the approaches of "Chunky" and "Chatty"?

1) Is it better to send each of them or zip them in one file to save the waiting time for each one to be confirmed.

2) Having said that, I need to increase the maximum array size or other settings, since I want them all together. Is this recommended? Because I read that this confirmation for each of them might be more expensive compared to sending one big file and one confirmation at the end ?

thank,

+2


source to share


1 answer


As you see it, you usually want your services to be "short" rather than "chatty". The answer in your specific scenario will depend on:

  • How large is the total of all files.
  • If and how you use the confirmations you are currently receiving. If you need to update the UI every file will be uploaded, it will be difficult for you to maintain the level of detail if you submit them right away.
  • What type of reliability / reuse do you need. Right now, if your service or connection dies, you can simply resubmit the files that weren't sent. If you combine all the files together, you have to start over, which may or may not be a big problem.

If possible, you can look at the support for sending streams with WCF:



By uploading a Stream, you get size benefits for the entire batch of files, while still being able to know your progress as you upload.

I am not sure of any specific issues with increasing the maximum message size beyond the impact it has on memory usage. Finally, I would say that you should zip these files regardless of whether you send everything together.

+2


source







All Articles