Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET VB.NET
Actually I got some 1000 individual processes to be executed independently. Each process will take 2 to 3 mins to complete. I want to execute all the process in Thread mode. My question is how many Threads can I use. In other words, how can I compute an optimum combination of no. of Threads and memory management to execute all these 1000 processes in a minimal time?
Posted 10-May-13 10:31am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

For the overall throughput, practically, it makes little sense to use more threads then CPU cores. Let's assume your all your other process are in the wait mode and don't take CPU resources. All correctly designed UI applications are like that. It means that your threads take all the time. Now the question is: do they use 1) each other, 2) external resources, such as network or external devices? If some of the above is correct, threading can really help, because, for example, the communication can be a bottleneck and then you can use several channels. In other works, parallel computing can help only if your have resources which can be used in parallel. Also, (case #1), the threading is dictated by the poor logic; for example, the UI should remain responsive anytime.
 
If you don't have anything like that, then number of threads should be the same as the number of cores. If number of cores is low (and apparently, if you have only 1 core), executing such independent tasks in more then one thread can even slow down the overall execution. Why? Because threading has some performance overhead.
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The number of threads is limited by the runtime or in the case of ASP, IIS. Finding a balance of concurrent execution versus wait times is a matter of academics, and finding what works best for you is designing a framework that you can easily change the number of concurrent threads and increase that value until you see a performance drop. This depends heavily on the processor architecture and other overhead on the system at any given time, so it's really not as simple as giving a number.
  Permalink  
Comments
chenthil28 at 10-May-13 15:41pm
   
I do have experience in writing Thread based coding. If each process executes for a few secs then it'll be ok but in this case, i've a problem like the thread executes for a little long time of 2 mins...
 
anyway thanks for your reply...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100