So in the past when I was working on a file transferring application I used streaming, and I seemed to be able to transfer files at fast speeds at least to and from my local machine.
I ran into problems though with very large files, over 4GB(I want any file size to be possible, small to large), and needed to think about separating the file into smaller chunks. So now I'm working on a different incarnation of my program and have it successfully splitting a large file into chunks specified by a certain chunk size(in this case 4MB).
I transfer those files over to the client via a callback method, but the transfers seem to take quite long compared to the streaming.
Are there certain settings within WCF that can really increase the performance of message transfers, or maybe some that might be hindering my performance?
public void RequestFile()
{
IFileTransferCallback callback = OperationContext.Current.GetCallbackChannel<IFileTransferCallback>();
while (chunkedFile.MoreChunks)
{
callback.ReceiveFile(chunkedFile.NextChunk(), chunkedFile.MoreChunks);
}
host.Close();
}
These are the binding settings I'm using right now. Some are just arbitrarily set.
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);
binding.MaxBufferPoolSize = int.MaxValue;
binding.ReaderQuotas.MaxDepth = int.MaxValue;
binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;
binding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;
binding.MaxConnections = 500;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.TransferMode = TransferMode.Buffered;
binding.SendTimeout = new TimeSpan(0, 5, 0);
binding.ReceiveTimeout = new TimeSpan(0, 5, 0);
BindingElementCollection collection = binding.CreateBindingElements();
collection.Add(new MtomMessageEncodingBindingElement());
UnityContainer.RegisterInstance(typeof(Binding), binding);
Edit:
I've been messing around with all sorts of options trying to get the speed to increase. When I run the server localhost it can do a 700mb file in just a couple of seconds, obviously... but when I do it with my external IP it's taking considerable amount of time, way longer than my 15mbps upload speed should allow me.
What's going on? Is there a hard cap for speed on WCF? How do I unlock it? Surely it can go faster than it's going now. I can't honestly tell how fast my data transfer is going because I do not know how to calculate it yet, but it's probably around 250kbps or less.
Second Edit:
I set up a streaming system again, but utilizing my chunks. So I'm streaming chunks of an overall larger file.
With 64mb chunks over the internet I just streamed an 862mb file to myself in 11 minutes and 30 seconds. I have a maximum of 25mbps download and about 5mbps upload speeds. I think that's pretty good.
It's a shame I cannot attain these speeds with buffered streaming mode.
Why is this? Why such a limitation? Why is streaming so much faster?
Further information
Decreasing the chunk size from 64 to 8 then to 4 and finally to 2 produced faster and faster results, with a file transfer of 862mb in 2 minutes for the 2mb chunk size. I could never attain anything like this with buffered transfer mode.