newWorkStealingPool max-threads & naming

Viewed 143

I define my rxjava scheduler as java excecutor service with newWorkStealingPool - 10 parallelism level.

@Bean("HttpClientScheduler")
public Scheduler httpClientScheduler() {
     return Schedulers.from( Executors.newWorkStealingPool(10));
}

Then in my async client call, I use that httpClientScheduler as my thread pool:

    public Single<Result> getData()  {    
         
        return Single.fromCallable( () -> {

           // some blocking call
           log.info("4444"); <------------------- some logging
           return resut;

        }).subscribeOn(httpClientScheduler); // <-- here I subscribe to the scheduler that uses the Executor with the newWorkStealingPool in it. supposedly limited to 10 threads.
    }

There I subscribe to the scheduler that uses the Executor with the newWorkStealingPool in it. supposedly limited to 10 threads.

yet what I see from the logs is:

INFO [] 155988 --- [Pool-1-worker-9] ClientRest  : 4444
INFO [] 155988 --- [ool-1-worker-13] ClientRest  : 4444
INFO [] 155988 --- [ool-1-worker-31] ClientRestt  : 4444
INFO [] 155988 --- [ool-1-worker-19] ClientRestt  : 4444
INFO [] 155988 --- [ool-1-worker-21] ClientRest  : 4444
INFO [] 155988 --- [Pool-1-worker-3] ClientRest  : 4444
INFO [] 155988 --- [ool-1-worker-17]  ...

There are 2 questions:

  1. Should amount of threads (workerks) be maximum to 10 (or 9 if starterf from 0)? Now, I see number 17,19,21 etc. which exceeds expected max 10
  2. Why do I have different name prefixes. One is Pool-, another is ooo-1-workerks? My guess is that ool is part of the "Pool", I guess some logging issue, not able to print all printing all at once. (the #1 is more critical to answer)

I noticed also, yet not proven fact, that all logs within the 0-9 range is fully printed with "Pool", the test "ool" ones - are out of the of the [0-9] thread range.


My simple hello world program works as expected though:

Question remains.. why in spring boot I got that issue #1.. with more than 10 threads.

enter image description here

-- UPDATE:

from my hello world app I see that there is thread "1 and 3", 2 is missing. Then tuning my real app to have 2 threads as well, I also DO see "1 & 3". Seems I all is all right.. I just cannot rely on those numbers - numbers is just numbers. as long as they are unique, it is ok.

I.e. If I set 100 as thread limit, it is Ok to see 200 in the logs. But it does not mean that there are 200 running threads.. I was it was so, so one (like me) could readon about how many threads are in there from the logs. I guess it is too much to ask.

Initially, I just a bit scared seeing big thread numbers in my logs, much bigger than my threshold (100). But that's turned out to be Ok.

1 Answers

about #1

From my hello world app I see that there is thread "1 and 3", 2 is missing (see the qustion).

Then tuning my real app to have 2 threads as well, I also DO see "1 & 3". Seems I all is all right..

I just cannot rely on those numbers - numbers is just numbers. as long as they are unique, it is ok.

I.e. If I set 100 as thread limit, it is Ok to see "200" in the logs. But it does not mean that there are 200 running threads.. I was it was so, so one (like me) could readon about how many threads are in there from the logs.

I guess it is too much to ask.

Initially, I just a bit scared seeing big thread numbers in my logs, much bigger than my threshold (100). But that's turned out to be Ok.

#2 question is still OPEN though.

Related