You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace Executor Thread Pools with Virtual Threads where applicable
Description
Now that we are using Java 21, we should likely replace most or all of our thread pools with virtual threads. This should increase performance and scalability as we will no longer use platform threads for sending emails or events.
We are currently using thread pools in a few locations:
Email Sender (See FusionAuthEmailExecutorServiceProvider)
Event Sender (See EventExecutorProvider)
Task Manager (See DefaultAsyncTaskManager)
At least two of our current executor service provides are instrumented for DropWizard. We can optionally leave this in place as it should not hurt anything. But the metrics around thread pools and executor services are not that interesting once we move to virtual threads, so we may wish to consider removing the instrumentation.
The EmailExecutorServiceProvider is in prime-email so this library will need to be updated if we wish to continue to use the ExecutorService interface even with Virtual Threads. This should be ok, but not really necessary either. The drop in replacement for the Executor Service builder is Executors.newVirtualThreadPerTaskExecutor. So the simplest change will be to drop this into the current providers.
We could also choose to no longer submit Callable tasks, and just inline the code using a Virtual Thread using a runnable. TBD what makes the most sense.
Replace Executor Thread Pools with Virtual Threads where applicable
Description
Now that we are using Java 21, we should likely replace most or all of our thread pools with virtual threads. This should increase performance and scalability as we will no longer use platform threads for sending emails or events.
We are currently using thread pools in a few locations:
FusionAuthEmailExecutorServiceProvider
)EventExecutorProvider
)DefaultAsyncTaskManager
)At least two of our current executor service provides are instrumented for DropWizard. We can optionally leave this in place as it should not hurt anything. But the metrics around thread pools and executor services are not that interesting once we move to virtual threads, so we may wish to consider removing the instrumentation.
The
EmailExecutorServiceProvider
is inprime-email
so this library will need to be updated if we wish to continue to use theExecutorService
interface even with Virtual Threads. This should be ok, but not really necessary either. The drop in replacement for the Executor Service builder isExecutors.newVirtualThreadPerTaskExecutor
. So the simplest change will be to drop this into the current providers.We could also choose to no longer submit Callable tasks, and just inline the code using a Virtual Thread using a runnable. TBD what makes the most sense.
Related
Community guidelines
All issues filed in this repository must abide by the FusionAuth community guidelines.
The text was updated successfully, but these errors were encountered: