0

I'm working on a Spring Boot web application and facing an issue with thread management. My goal is to execute platform threads for certain operations, but it seems like my application is only capable of running NIO threads.

Details: Spring Boot Version: 3.2.1 Tomcat Version: Embedded Tomcat 10.1.17 (default with Spring Boot) Java Version: Java 21

Context: Since the new Virtual Thread released, i want to compare the performance of an I/O bound web application by using this three different scenarios:

  1. Executing my service setting Tomcat to use virtual threads
  2. Executing my service setting Tomcat to use NIO threads
  3. Executing my service setting Tomcat to use BIO threads (as known as platform threads)

I can easily execute the service with 1) and 2) by simply setting my application.yaml (or .properties) file with the following line:

spring: threads: virtual: enabled: true 

What i am looking for now is to set my Tomcat to use platform thread as a default thread pool. I know that since java 8 BIO thread has been removed as a standard connector for Tomcat (https://tomcat.apache.org/migration-85.html#BIO_connector_removed) For that reason i am having trouble setting my springboot application to use platform threads. I am very interested in make that works since i expect to see a huge gap performance by using BIO threads compared with Virtual Threads.

Goal: To use platform threads (BIO model). Issue: Whenever I try to use platform threads, they seem to default back to NIO threads. Is this due to the Tomcat version being used, or am I missing some configuration?

Thanks for reading, please let me know if you need further information

3
  • Like you said all BIO-related Protocols and Endpoints were removed since Tomcat 8.5. The only (potentially) viable way I see at the moment is to use Tomcat 8.0, run it under JDK 21 and configure BIO Connector/Protocol with (custom) Virtual Thread Executor, something along the lines of stackoverflow.com/questions/77622056/…. If this sounds like a plan to you, I could have a look. Spring Boot 3 may or may not be a right environment for such experiment, Commented Jan 4, 2024 at 17:47
  • You list tomcat 10 and tag tomcat 8. Also, I don't understand if you talk about generic threads or about connectors. A lot of details is missing, please provide a minimal reproducible example Commented Jan 4, 2024 at 19:47
  • @OlafKock, the OP wants to use whatever is embedded in the Spring Boot 3.2.1, which happens to be Tomcat 10.1.17, but wants to use BIO type of Connectors, which is removed in Tomcat 8.5. So either he has to somehow bring BIO Connector to Tomcat 10, which is quite difficult, or, like I suggested, bring virtual threads to Tomcat 8.0, which is also manual work (if at all possible). Another thing the OP messes up is Connectors/Endpoints and threads. The former could execute under any type of thread (virtual or platform). Therefore there are no such things like BIO or NIO threads. Commented Jan 4, 2024 at 22:39

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.