Spring batch multithreading: throttle-limit impact

余生长醉 提交于 2021-02-11 08:00:51

问题


I have a multi-threaded Step configured with a threadpool with a corePoolSize of 48 threads (it's a big machine) but I did not configure the throttle-limit.

I am wondering if I have been under utilizaing the machine because of this.

The Spring Batch documentation says that throttle-limit is the max amount of concurrent tasks that can run at one time and the default is 4.

I can see in jconsole that in fact there are 48 threads created and they seem to be executing (I can also see that in my logs).

But, so, even though I can see the 48 threads created, does the throttle-limit of 4 mean that only 4 of those 48 threads are indeed executing work concurrently?

Thank you in advance.


回答1:


Yes, your understanding is correct i.e. only threads equal to throttle limit be doing work concurrently.

In your case, since its a thread - pool , any four threads could be chosen randomly to do the work and rest of threads will remain idle but since threads get rotated for those four tasks, it will give an impression that all threads are doing work concurrently.

corePoolSize simply indicates the number of threads to be started and maintained during job run but that doesn't mean that all are running concurrently what it means that you are trying to avoid thread creation overhead etc during job run.

You have not shared any code or job structure so its hard to point any more specifics.

Hope it helps !!



来源:https://stackoverflow.com/questions/41871647/spring-batch-multithreading-throttle-limit-impact

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!