I have a calculation heavy spring boot application that runs on an AWS t3.large EC2 instance, with 2 virtual CPUs.
I have two steps in the calculation and for the first step, I intend to use supplyAsync with a thread pool of 2 threads because of the 2vcpus.
The second step involves a fork join (happens after step 1 is completed). However, with this, if I use the commonPool, which I can because it is only doing calculations, that would mean it runs on parallelism = 1. This means JVM will create a thread for each task (reference : https://dzone.com/articles/be-aware-of-forkjoinpoolcommonpool). I am anticipating the sub tasks to be over 10. Therefore creating 10 or more threads feels like an overkill due to the memory it consumes.
Does it make sense to use the fork join approach if I only have 2 vcpus?