Solved

ExecutorService

Posted on 2014-12-08
5
84 Views
Last Modified: 2014-12-09
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
0
Comment
Question by:thready
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 40488148
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"
0
 
LVL 27

Expert Comment

by:dpearson
ID: 40488330
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.
0
 
LVL 1

Author Comment

by:thready
ID: 40488380
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...
0
 
LVL 27

Accepted Solution

by:
dpearson earned 500 total points
ID: 40489720
ThreadPoolExecutor
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html
can take a minimum and maximum thread pool size and figures out how many threads to actually use, based on the way the tasks execute and block.

It may be what you're looking for?

Doug
0
 
LVL 1

Author Closing Comment

by:thready
ID: 40490432
Awesome!  Thank you!
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fibonacci ten numbers 4 54
Java string replace 11 61
Why doesn't this text field show up on my Applet frame? 2 28
web project error add remove 1 51
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question