java - How to figure out N threads I need in a parallel execution context? -
i'm working in redelivery system. system attempt execute action, if action fails, try execute again 2 times interval of 5 minutes, use executorservice implementation perform first execution , scheduledexecutorservice schedule other ones, depending of results (fail).
what should consider figure out number of threads need? in moment use single thread model (created newsinglethreadscheduledexecutor method)
without knowing details load system has, environment using , how long take process 1 message hard number of threads need. however, can think of following base principles:
- having many threads bad, because you'll spend significant amount of time on context switch, chance of starvation , wasting system resources higher .
- each thread consumes space in memory stack. on
x64typically1mbper thread.
i create 2 thread pools (one scheduled, 1 non-scheduled) both sending , redelivery , test them under high load varying number of threads 2 10 see number suits best.
Comments
Post a Comment