Solved

ExecutorService

Posted on 2014-12-08
5
79 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
  • 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 26

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 26

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now