Spring Boot嵌入式Tomcat性能 [英] Spring Boot Embedded Tomcat Performance
问题描述
我正在为我的应用程序开发Microservices API.我从Spring Boot应用程序开始.我创建了两个工件-带有嵌入式tomcat的业务代码" 和没有嵌入式tomcat的业务代码" .
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".
比较性能结果时,我可以看到非嵌入式tomcat"(即在独立的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.
那么基本上嵌入式tomcat和独立tomcat在实现方面有什么区别?
两次执行之间的性能如何变化?
How the performance varies between two executions?
推荐答案
我发现了此问题的根本原因.
I found out actual root cause of this issue.
APR(Apache可移植运行时)在tomcat线程执行中起着重要作用.
APR (Apache Portable Runtime) plays important role in tomcat thread execution.
默认情况下,嵌入式tomcat执行NIO. NIO和BIO是基于Java的执行,而APR是本机执行.当我们比较NIO和APR的性能时,APR快得多.
事实上,所有基于Linux的tomcat捆绑包都随附于tomcat lib文件夹下的APR库.
In fact all the Linux based tomcat bundles are shipped with APR libs under the tomcat lib folder.
与嵌入式tomcat相比,在嵌入式tomcat(即Spring Boot)中启用APR后,性能执行是相同的.
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
这篇关于Spring Boot嵌入式Tomcat性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!