Link to home
Start Free TrialLog in
Avatar of thready
thready

asked on

ExecutorService

Hi Experts,

I'm doing a simulation of a bunch of sessions that do 3 or 4 REST calls.  I'd like to do as many as possible simultaneously that won't start degrading the machine and give diminishing performance.  I don't care to make it right at the critical point, but I'm wondering what's a good number of threads to use?  I'm thinking 150 is likely a good number.

Thanks for any advice,
Mike
Avatar of mccarl
mccarl
Flag of Australia image

I'm wondering what's a good number of threads to use?
We aren't going to be able to give you the answer that you are seeking. What is a good number for your particular situation would be a totally different number for the next persons. I mean you haven't even given any detail about what it is that you are doing AND even if you had it is very unlikely that anyone could give you a number you are looking for.

SO... what would I do in your situation? Firstly, you mention "give diminishing performance" so I would make sure that you have some way of measuring performance. And then it is a case of trial and error to see what you can get out of it before you performance begins to "diminish"
Avatar of dpearson
dpearson

If you want maximum throughput you generally only want about twice as many threads as cores on your CPU - so you're looking at maybe 10 rather than 150.  But that's assuming you're not going to be blocking and waiting for I/O - which it sounds like you will be if you're making REST calls?  In that case it really depends how long the REST calls take to respond and whether the threads will block waiting for the response.

So the answer is "it depends".

Like mccarl said - not really enough info here to help you much.
Avatar of thready

ASKER

Yes, the threads will block while waiting for responses, but that's just because it's easier to program this way- each of the 3 or 4 REST calls are sequential...  Of course I could have chained the asynch callbacks instead...  So I'm guessing a definite minimum is about 100 threads for this reason.  I did something similar about ten years ago and since then computers have gotten faster, and I think my magic number was at about 150.  Of course, the two servers are doing different things, but they're basically the same amount of work.
Anyway, I knew this was a vague question....  I'm just fishing for out of the box thinking.  Among other things, I was hoping for someone to tell me about something that can add the correct number of threads based on performance, but that's a whole other ball game...
ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thready

ASKER

Awesome!  Thank you!