Advertisement
Javi

Tomcat: setenv.sh

Nov 25th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. #! /bin/sh
  2. # ==================================================================
  3. # ______ __ _____
  4. # /_ __/___ ____ ___ _________ _/ /_ /__ /
  5. # / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
  6. # / / / /_/ / / / / / / /__/ /_/ / /_ / /
  7. #/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
  8.  
  9. # Multi-instance Apache Tomcat installation with a focus
  10. # on best-practices as defined by Apache, SpringSource, and MuleSoft
  11. # and enterprise use with large-scale deployments.
  12.  
  13. # Credits:
  14. # Google -> Couldn't survive without it
  15. # Stackoverflow.com -> Community support
  16. # SpringSource -> Specifically best-practices and seminars (Expert Series)
  17.  
  18. # Based On:
  19. # http://www.springsource.com/files/uploads/tomcat/tomcatx-performance-tuning.pdf
  20. # http://www.springsource.com/files/u1/PerformanceTuningApacheTomcat-Part2.pdf
  21. # http://www.springsource.com/files/uploads/tomcat/tomcatx-large-scale-deployments.pdf
  22.  
  23. # Created By: Terrance A. Snyder
  24. # URL: http://www.terranceasnyder.com, http://shutupandcode.net
  25.  
  26. # Best Practice Documentation:
  27. # http://terranceasnyder.com/2011/05/tomcat-best-practices/
  28.  
  29. # Looking for the latest version?
  30. # github @ https://github.com/terrancesnyder
  31.  
  32. # ==================================================================
  33.  
  34. # Activa jmx
  35. export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1098 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
  36. export CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=ec2-52-32-63-100.us-west-2.compute.amazonaws.com"
  37. # discourage address map swapping by setting Xms and Xmx to the same value
  38. # http://confluence.atlassian.com/display/DOC/Garbage+Collector+Performance+Issues
  39. export CATALINA_OPTS="$CATALINA_OPTS -Xms64m"
  40. export CATALINA_OPTS="$CATALINA_OPTS -Xmx512m"
  41.  
  42. # Increase maximum perm size for web base applications to 4x the default amount
  43. # http://wiki.apache.org/tomcat/FAQ/Memoryhttp://wiki.apache.org/tomcat/FAQ/Memory
  44. export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"
  45.  
  46. # Reset the default stack size for threads to a lower value (by 1/10th original)
  47. # By default this can be anywhere between 512k -> 1024k depending on x32 or x64
  48. # bit Java version.
  49. # http://www.springsource.com/files/uploads/tomcat/tomcatx-large-scale-deployments.pdf
  50. # http://www.oracle.com/technetwork/java/hotspotfaq-138619.html
  51. export CATALINA_OPTS="$CATALINA_OPTS -Xss256k"
  52.  
  53. # Oracle Java as default, uses the serial garbage collector on the
  54. # Full Tenured heap. The Young space is collected in parallel, but the
  55. # Tenured is not. This means that at a time of load if a full collection
  56. # event occurs, since the event is a 'stop-the-world' serial event then
  57. # all application threads other than the garbage collector thread are
  58. # taken off the CPU. This can have severe consequences if requests continue
  59. # to accrue during these 'outage' periods. (specifically webservices, webapps)
  60. # [Also enables adaptive sizing automatically]
  61. export CATALINA_OPTS="$CATALINA_OPTS -XX:+UseParallelGC"
  62.  
  63. # This is interpreted as a hint to the garbage collector that pause times
  64. # of <nnn> milliseconds or less are desired. The garbage collector will
  65. # adjust the Java heap size and other garbage collection related parameters
  66. # in an attempt to keep garbage collection pauses shorter than <nnn> milliseconds.
  67. # http://java.sun.com/docs/hotspot/gc5.0/ergo5.html
  68. export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxGCPauseMillis=1500"
  69.  
  70. # A hint to the virtual machine that it.s desirable that not more than:
  71. # 1 / (1 + GCTimeRation) of the application execution time be spent in
  72. # the garbage collector.
  73. # http://themindstorms.wordpress.com/2009/01/21/advanced-jvm-tuning-for-low-pause/
  74. export CATALINA_OPTS="$CATALINA_OPTS -XX:GCTimeRatio=9"
  75.  
  76. # The hotspot server JVM has specific code-path optimizations
  77. # which yield an approximate 10% gain over the client version.
  78. export CATALINA_OPTS="$CATALINA_OPTS -server"
  79.  
  80. # Disable remote (distributed) garbage collection by Java clients
  81. # and remove ability for applications to call explicit GC collection
  82. #export CATALINA_OPTS="$CATALINA_OPTS -XX:+DisableExplicitGC"
  83.  
  84. # Check for application specific parameters at startup
  85. if [ -r "$CATALINA_BASE/bin/appenv.sh" ]; then
  86. . "$CATALINA_BASE/bin/appenv.sh"
  87. fi
  88.  
  89. echo "Using CATALINA_OPTS:"
  90. for arg in $CATALINA_OPTS
  91. do
  92. echo ">> " $arg
  93. done
  94. echo ""
  95.  
  96. echo "Using JAVA_OPTS:"
  97. for arg in $JAVA_OPTS
  98. do
  99. echo ">> " $arg
  100. done
  101. echo "_______________________________________________"
  102. echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement