spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Detect virtual threads and reduce memory needs

Open StefanLobbenmeierObjego opened this issue 1 year ago • 5 comments

Describe the Enhancement

Virtual Threads require less memory (source). Now that spring boot supports them in 3.2, is it possible to detect that they are enabled and reduce thread memory in the build pack?

Possible Solution

There is already detection for reactive spring, which reduces the thread count:

If the application is a reactive web application
Configures $BPL_JVM_THREAD_COUNT to 50

Since virtual threads are configured in the application.properties, I am not sure if it is also possible or if the build pack just looks at dependencies.

Motivation

Less memory reserved for threads = more memory for the application, or cheaper hosting costs.

Also looking for input from others, because I am not sure how much memory this will save / How many threads are still there with this setting. For me the best way to test this would be to run the application once with virtual threads and once without and compare memory needs.

StefanLobbenmeierObjego avatar Nov 27 '23 09:11 StefanLobbenmeierObjego