Tomcat (3) - Performance Optimization

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Lectures

Review the lesson at work ---- discover a problem, most of the participants did not notice a problem - in fact, that starts Tomcat in two ways, one is through the Tomcat start, one by catalina start, we after the note.

 

1.  Performance Optimization is a systematic project

These three indicators are not alone, but together, they are a triangle, various indicators are based on the basis of other indicators. They influence each other, interrelated.

Ideal is full, the reality is skinny, optimization pay attention to add up a little bit to optimize every aspect of the global impact of the increased recently had to say. Performance optimization is actually such a theme.

 

2.  Tomcat performance optimization tools used

meter This tool is a pure java to write, it is also a distributed tool that can do a stand-alone test, you can do a stress test distributed multi-machine. Specifically how to do stress testing may be distributed to Baidu, we only use this to do a stand-alone test today. He can also be seamlessly combined with some recording a script, such as badboy this tool can record a script

King teacher like in-depth analysis of the contents with you. Let's explore that next is how it started. Know these, you must know the course.

3.  Tomcat in the server.xml optimization

老师在家附近的一个很大的理发店办了张会员卡,那个店子生意太好,每次去剪头发都需要排队,这个剪头发的过程本身就是一个长时间的过程,是一个长连接。如果是采用BIO的方式,一个理发师只能同时服务一个人,如果采用NIO的话,可以把过程进行拆解,把剪发分为洗发、剪发、吹法。现在理发店都是采用雇佣很多年轻的小伙子,不管人多少,洗发这个过程可以不阻塞,洗完可能需要等理发师剪发,理发师剪完发后再转给之前洗发的小伙子给你吹干。前面老师这个剪头发的流程就是一个典型的NIO。最大压榨了理发师,把理发师的时间片段都利用了起来。这个就是Tomcat 8.5已经9的版本后把bio给废掉了的原因。

线程池的好处在于统一管理,使用线程池的话如果发现线程空闲时间达到比如(60秒的时间),会自动回收。如果不使用线程池的话就把线程池丢给的gc去回收。(jvm的回收机制),这个就很难控制了,所以使用线程池最大的好处是保证系统的稳定性,很多时候我们做项目,稳定性是排在第一位的。

 

4. Tomcatweb.xml优化

JSP中其实是jsp -> java -> class的一个过程。

Tomcat在运行过程中会把你访问的这些jsp做这些操作,其实我们可以预先编译下,节约性能。

5. SpringBootTomcat的优化

 

springboot中用了TomcatcontextCustomizer 和TomcatConnectorCustomizer来实现Tomcat,可以看看这个方面的源码(按照第三节课 嵌入式Tomcat的方式去分析和看就行了)

 

 

 

Guess you like

Origin www.cnblogs.com/zqLoveSym/p/12354152.html