Thead Performance

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

All,

I have an application that transfers files from one
machine to another machine (in a remote location) via FTP.
My question is in regards to the performance of the FTP
transfer. Am I better to run a single thread and transfer
one file at a time to the remote machine or am I better to
have a few threads running each transfering a file to that
machine? I have not been able to find any data regarding
such a situation. Any insight would be much appreciated.
Thanks!
 
Dan,

This depends on a number of factors. First, what is the connection of
the FTP server? Can it accept as much data at the same time as you want to
throw at it (in other words, what is the connection speed on the other end).
Also, what is the connection speed of the machine you are sending the files
from? If you try and send out 100 files at the same time, each connection
might transfer very slowly because your pipe going out isn't that wide.

Also, when it comes to performing processing on another thread, you
generally should take advantage of the ThreadPool class, which will allow
you to queue requests and then have them executed when there are enough
resources. The reason for this is that the ThreadPool would manage the
number of threads based on the number of processors and current system
resources.

Hope this helps.
 
You probably want to take advantage of the asynchronous I/O capabilities
built into the CLR/Framework.

There's a great async I/O sample in the original framework documentation.

http://msdn.microsoft.com/library/d...html/cpconnon-blockingserversocketexample.asp
http://msdn.microsoft.com/library/d...html/cpconnon-blockingclientsocketexample.asp

what's nice is that it uses the threadpool and leverages IO completeion
ports so things happen as fast as they can.

eAndy

p.s. reply to group, email is bogus.
 
Just try it and see. You can think about this for weeks and not come up
with a satisfactory answer. Take an hour to try it, and you will know right
away.
 
theading does not overcome the transfer rate over the wire. it only allows
you to do several more transfers at the same time. How many threads needed,
hard to tell, but the more is not necessarily the merrier due to context
switching. press me, i say 5 threads, each with its quota of files blasting
across the network would be a good start, then tune it, time it, vary the
threads and the load per thread to see what works optimally.
 
Back
Top