성능과 튜닝/WAS 튜닝

Tomcat 7.0 Parameter Tuning

Terry Cho 2013. 3. 1. 00:51

server.xml

--

<?xml version='1.0' encoding='utf-8'?>

<Server port="8005" shutdown="SHUTDOWN">

  <!-- Security listener. Documentation at /docs/config/listeners.html -->

  <Listener className="org.apache.catalina.security.SecurityListener" checkedOsUsers="root" /> root 사용자로 start 하지 못하게 함

  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->

  <Listener className="org.apache.catalina.core.JasperListener" />

  <!-- Prevent memory leaks due to use of particular java/javax APIs-->

  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> 메모리 leak detector

  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />


  <!-- Global JNDI resources

       Documentation at /docs/jndi-resources-howto.html

  -->

  <GlobalNamingResources>

    <!-- Editable user database that can also be used by

         UserDatabaseRealm to authenticate users

    -->

    <Resource name="UserDatabase" auth="Container"

              type="org.apache.catalina.UserDatabase"

              description="User database that can be updated and saved"

              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

              pathname="conf/tomcat-users.xml" />

  </GlobalNamingResources>


  <Service name="Catalina">


    <Connector port="8080" 

protocol="org.apache.coyote.http11.Http11Protocol" BIO 사용

acceptCount="30" back log를 30으로 제안

enableLookups="false" DNS 사용 금지. 

compression="off" 압축 금지 (REST 사용 및 Mobile 고려)

                connectionTimeout="10000" Connection time out 10초

maxConnections="8192" 

maxKeepAliveRequests="1"

maxThreads="100"

tcpNoDelay="true"

               redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

               resourceName="UserDatabase"/>

      </Realm>


      <Host name="localhost"  

   appBase="webapps" <!-- /bin/apps/ -->

            unpackWARs="true" 

   autoDeploy="false">


        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

               prefix="localhost_access_log." suffix=".txt"

               pattern="%h %l %u %t &quot;%r&quot; %s %b" />


      </Host>

    </Engine>

  </Service>

</Server>


--

Context에서 auto reload 부분 제외 해야 하고..
dbcp connection pool 튜닝 필요 --> dbcp 말고 tomcat pool 사용
context.xml에 설정
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/javatest"/>

애플리케이션 배포를 쉽게 하기 위해서, 위의 Context.xml은 war/META-INF/context.xml을 사용하는게 좋음


shared lib 처리 필요
JVM은 -server -Xms1024m -Xmx1024m -XX:NewSize=384m -XX:PermSize=128m + ParallelGC, GCThread=3, +PrintGCDetial
디렉토리 처리 (1 server , 1was를 기준으로 함)
tomcat 설치는 /usr/local/tomcat
JVM은 /usr/local/jvm
application은 /applications/war/
log는 /applications/log/access.log catalina.out 기타 application logs
기타 스크립트는 /applications/scripts
설정 파일 /appllications/properties

아니면
/product/j2ee/jdk
/product/j2ee/tomcat

/applications/j2ee/war
/applications/j2ee/logs
/applications/j2ee/scripts
/applications/j2ee/properties

아니면
/product/tomcat
/product/jdk
/product/tomcat7 (link)
/product/jdk1.6 (link)
/applications/tomcat/war
/applications/tomcat/logs/access.log, catalina.out
/applications/tomcat/scripts/deploy/fabfile
/applications/tomcat/scripts/logbackup/fabfile
/applications/tomcat/properties

boot up시 최신 war 파일을 repository에서 읽어오는 부분 추가

튜닝 하려면 한 2일 걸리겠네...