Solved

ExecutorService

Posted on 2014-12-08
5
87 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 36

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

707 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