Spring Boot Embedded Tomcat Performance

Peter Jerald picture Peter Jerald · Oct 29, 2016 · Viewed 12.8k times · Source

I am developing Microservices API for my application. I started with Spring Boot application. I created two artifacts - "business code with embedded tomcat" and "business code without embedded tomcat".

When I compare the performance results, I can see that the "non-embedded tomcat" (i.e. executing on standalone tomcat) gives good output because of native execution.

So basically what is the difference between the embedded tomcat and the standalone tomcat regarding implementation?

How the performance varies between two executions?

Answer

Peter Jerald picture Peter Jerald · Nov 6, 2016

I found out actual root cause of this issue.

APR (Apache Portable Runtime) plays important role in tomcat thread execution.

By Default, embedded tomcat executes NIO. NIO and BIO are Java based executions whereas APR is native execution. When we compare performance of NIO and APR, APR is pretty much faster.

In fact all the Linux based tomcat bundles are shipped with APR libs under the tomcat lib folder.

After I enabled APR in embedded tomcat (i.e. Spring Boot) performance execution was same compared to standalone tomcat.

http://tomcat.apache.org/tomcat-7.0-doc/apr.html