Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to know if spring boot app is using nio?

If we search our spring boot 2.0.3 project source code (all files), there is no mention of nio.

According to the spring docs, nio is disabled by default, so we would expect to not be using nio.

However, when the app starts, it says "restartedMain org.apache.coyote.http11.Http11NioProtocol [] => Initializing ProtocolHandler ["http-nio-8080"]"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Does this mean that we Are using nio? If so, are the docs wrong about defaulting to not using it?

2024-10-23T09:10:56,001Z INFO  restartedMain o.s.b.web.embedded.tomcat.TomcatWebServer [] => Tomcat initialized with port(s): 8080 (http)
2024-10-23T09:10:56,031Z INFO  restartedMain org.apache.coyote.http11.Http11NioProtocol [] => Initializing ProtocolHandler ["http-nio-8080"]
2024-10-23T09:10:56,052Z INFO  restartedMain org.apache.catalina.core.StandardService [] => Starting service [Tomcat]
2024-10-23T09:10:56,052Z INFO  restartedMain org.apache.catalina.core.StandardEngine [] => Starting Servlet Engine: Apache Tomcat/8.5.31

>Solution :

Http11NioProtocol is the non-blocking IO (NIO) connector for Tomcat.

Tomcat 8 typically uses the http-nio protocol unless specifically configured to use the blocking I/O (BIO) protocol (Http11Protocol). Therefore, even if you haven’t explicitly configured NIO in your project, Tomcat itself is using it by default.

Try:

server.tomcat.protocol=org.apache.coyote.http11.Http11Protocol

This would force the use of the blocking IO connector if you want to switch away from NIO.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading