Web servers & Deployment
Java get property of system with given string
1 |
System.getProperty("catalina.base") + File.separator + "bin" |
Apache Tomcat Performance optimization
1- Memory problems
1 2 3 |
# Find the catalina.sh file, export CATALINA_OPTS="-Xms256m -Xmx256m" #change 256 to 128 or what every you want |
1 2 3 4 5 6 7 |
The Heap: This is the memory used to store your objects and is controlled by the -Xms and -Xmx parameters. The Stack: This is the memory used to store the stack frames for the threads that your program maintains and can be controlled with the -Xss parameter. Permgen Memory: This is the memory used to store your compiled classes and pooled strings as well as some other things and can usually be controlled with -XX:MaxPermSize although the -XX represents a debugging parameter, so there's no guarantee it's on all JVM's. But, the default Sun/Oracle reference implementations have always had them. JNI Allocated Memory Any classes utilizing native methods and JNI could potentially allocate unlimited memory. This memory comes from the OS and not the heap and there's no way of knowing how much memory a native class will use without having access to the source. |
2- CPU ( For number of Threads, server.xml)
1 2 3 |
1- Limit the number of Java threads. 2- Limit the maximum Java heap size. |
Example
1 2 |
<Connector port="8080" address="localhost" minSpareThreads="20" /> |