Reprint please indicate source: http://blog.csdn.net/goldenfish1919/article/details/47829755
Let's do an experiment and use JMeter to test a JSP page under Tomcat:
(1) The content of JSP is very simple, 1.jsp:
<%@ page language= "java" pageencoding= "Utf-8" contenttype= "Text/html;charset=utf-8"%>
Without any complicated processing, just a very simple JSP page. We know that Tomcat will have session enabled for each JSP by default.(2) We set the startup parameters for Tomcat, modify the Catalina.bat, add:
Set java_opts=%java_opts%-xms64m-xmx64m
(3) Start JMeter, set 100 threads to simulate 100 users, and then continue to visit this page, observe the results:
As can be seen in the figure, when the number of requests reaches 33165, Tomcat is already out of memory.
(4) Export the Tomcat memory image file:
Jps-v: Find the PID of Tomcat
Jmap-dump:format=b,file=tomcat.bin 6616
(5) Open Tomcat.bin with Mat:
There is no surprise, standardsession unexpectedly have 33,197, accounted for the memory reached 52m! This is due to the fact that each request Tomcat creates a session for it.
Here is also a question: even if there is nothing in the session, the default will be almost 1.5k! So, the session is a heavyweight object!
(6) So if the JSP does not generate a session is not the problem? Let's change the JSP page:
Re-do the pressure test:
Tomcat says it's easy, no pressure!
Conclusion: The session of Tomcat is a very heavyweight object, the initialization is about the size of 1.5K, can be disabled must be disabled.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Why does tomcat disable session?