Influence of JSP session Configuration on web Application

  • 2021-12-13 08:58:43
  • OfStack

Influence of JSP session Configuration on web Application

Previously, the company did an web project. After the release, with the increasing number of visits, it is found that JVM uses more memory, full gc frequently, and the size of old area changes little after full gc. At first, we thought that the parameters of JVM virtual machine were unreasonable, so we adjusted the parameters of JVM virtual machine, and found that GC was still very frequent after adjustment.

funll GC frequently affects the performance. We export heapdump (snapshot of Java stack) file of jvm and analyze it with IBM HeapAnalyzer analysis tool. After analysis, it is found that there are many session objects in the heap. These session objects take up a large amount of space and a large proportion of heap memory. Obviously, the problem appears on session.

Because when the client accesses, when there is no session of the client in the server, session objects will be generated. Because the expiration time of session in the project is set to be relatively large, when the access volume is relatively large, there are many session objects generated, which leads to occupying a large heap memory.
session was set to 30 minutes before, and then set to 1 minute. The code is as follows:


<!--  Settings session Failure, unit points  --> 
  <session-config> 
    <session-timeout>1</session-timeout> 
  session-config> 

After setting the expiration time of session to 1 minute, the stress test shows that full gc is reduced a lot, and the memory consumption of JVM is also reduced a lot. Draw a conclusion from this result and set

Reasonable session expiration time is very necessary.

Note: Since no information is put into session in this web project, session can be set up for a short time. If there is information in session, then everyone needs to

Consider setting a reasonable expiration time for yourself.

Thank you for reading, hope to help everyone, thank you for your support to this site!


Related articles: