Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Executor Thread Pools with Virtual Threads where applicable #2974

Open
robotdan opened this issue Jan 22, 2025 · 0 comments
Open

Replace Executor Thread Pools with Virtual Threads where applicable #2974

robotdan opened this issue Jan 22, 2025 · 0 comments

Comments

@robotdan
Copy link
Member

robotdan commented Jan 22, 2025

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.

Related

Community guidelines

All issues filed in this repository must abide by the FusionAuth community guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant