Why does tomcat disable session?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.