0

I'm running Tomcat 8.0.50 with JDK 1.8.0 update 111, on a box with 128 GB memory.

It's a default installation with no JAVA_OPTS configured, during pressure tests of a simple JSP file,

<%@ page import="java.io.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String normal_querystring = "?params=whatever";
session.setAttribute("time", normal_querystring+System.currentTimeMillis());
%>

The memory usage continue to grow,

root     21056  123 17.9 40884708 23744644 pts/1 Sl 11:10  52:18 /home/work/jdk1.8.0_111/jre/bin/java -Djava.util.logging.config.file=/home/test/apache-tomcat-8.0.50/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /home/test/apache-tomcat-8.0.50/bin/bootstrap.jar:/home/test/apache-tomcat-8.0.50/bin/tomcat-juli.jar -Dcatalina.base=/home/test/apache-tomcat-8.0.50 -Dcatalina.home=/home/test/apache-tomcat-8.0.50 -Djava.io.tmpdir=/home/test/apache-tomcat-8.0.50/temp org.apache.catalina.startup.Bootstrap start

I know that Java would use 1/4 of the physical memory available, but how could a simple JSP file like this consuming so much memory?

Also, gc does not work:

> jcmd 21056 GC.run
21056:
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
    at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
    at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
    at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
    at sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:147)
    at sun.tools.jcmd.JCmd.main(JCmd.java:131)

Any ideas?

daisy
  • 19,459
  • 24
  • 111
  • 218

1 Answers1

0

You can do the math: You're saving data to the session. I'm assuming that your tests are massive (I've never heard the term "pressure test", I'll file it as "load test") and try to request as many pages as possible in the time given.

Assuming that your load tests all come without a session cookie, thus each new requests starts a new session, you'll create a new session object each request. Figure out the size of a session object (hint: The timestamp, that you save there, is your least concern)

You'll know how many requests your server handles per second, or per minute. Now keep in mind that the default session lifetime in Tomcat (unless you configured it otherwise) is 30 minutes. This will give you a feeling for how many session objects you can expect after your test runs for 30 minutes. After that, the memory consumption will be more of a straight line - but until then, no GC will help you lower the demand, because they all are still in active use and not yet expired.

And, once you start configuring your server memory, do so with CATALINA_OPTS, not with JAVA_OPTS.

Olaf Kock
  • 43,342
  • 7
  • 54
  • 84