apache +mod_jk+tomcat 高并发优化

作者: admin 分类: linux 发布时间: 2010-10-21 12:27 ė 6 1条评论

 apache +mod_jk+tomcat 高并发优化

本机部署了多个MYSQL 多个TOMCAT 并发大概5000

主要配置JK  和TOMCAT下的server.xml

以下是我的配置效果还算不错

workers.java_home=/usr/local/jdk
    ps=/
    worker.list=controller,tomcat,tomcat1,tomcat2,tomcat3,tomcat4,tomcat5
    worker.tomcat.port=8009
    worker.tomcat.host=localhost
    worker.tomcat.type=ajp13
    worker.tomcat.lbfactor=1

    worker.tomcat5.port=11009
    worker.tomcat5.host=localhost
    worker.tomcat5.type=ajp13
    worker.tomcat5.socket_keepalive=1
    worker.tomcat5.lbfactor=1

    worker.tomcat1.port=10003
    worker.tomcat1.host=localhost
    worker.tomcat1.type=ajp13
    worker.tomcat1.socket_keepalive=1
    worker.tomcat1.lbfactor=1

    worker.tomcat2.port=10006
    worker.tomcat2.host=localhost
    worker.tomcat2.type=ajp13
    worker.tomcat2.lbfactor=1

     worker.tomcat3.port=7003
     worker.tomcat3.host=localhost
     worker.tomcat3.type=ajp13
     worker.tomcat3.lbfactor=1

     worker.tomcat4.port=9199
     worker.tomcat4.host=localhost
     worker.tomcat4.type=ajp13
     worker.tomcat4.lbfactor=1

    worker.controller.type=lb
    worker.controller.balance_workers=tomcat,tomcat1,tomcat2,tomcat3,tomcat4,tomcat5
    worker.controller.sticky_session=1
    worker.status.type=status

     worker.controller.sticky_session=1
    worker.status.type=status
    worker.controller.recovery_options=3
    worker.controller.socket_keepalive=True
    worker.controller.connection_pool_size=120
    worker.controller.connection_pool_minsize=0
    worker.controller.connection_pool_timeout=20000

以下2参数重要

worker.controller.recovery_options=3
worker.controller.connection_pool_minsize=0

 下面是SERVER.XML的配置

 <Connector port=”8080″ protocol=”HTTP/1.1″
               maxHttpHeaderSize=”8192″ useBodyEncodingForURI=”true”
               acceptCount=”500″
               maxThreads=”2000″
               minSpareThreads=”100″
               maxSpareThreads=”2000″
               tcpNoDelay=”true”
               socketBuffer=”4096″
               enableLookups=”false”
               redirectPort=”8443″
               connectionTimeout=”200000″  />
    <!– A “Connector” using the shared thread pool–>
    <!–
    <Connector executor=”tomcatThreadPool”
               port=”8080″ protocol=”HTTP/1.1″
               connectionTimeout=”20000″
               redirectPort=”8443″ />
    –>
    <!– Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation –>
    <!–
    <Connector port=”8443″ protocol=”HTTP/1.1″ SSLEnabled=”true”
               maxThreads=”150″ scheme=”https” secure=”true”
               clientAuth=”false” sslProtocol=”TLS” />
    –>

    <!– Define an AJP 1.3 Connector on port 8009 –>
    <Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″
    connectionTimeout=”200000″  maxThreads=”2000″ acceptCount=”500″
            />

   注意 :压力大了 会抱JK连不到TOMCAT的错误 我也找了好久 是JK仍给TOMCAT是通过AJP13端口去处理 所有优化AJP13

把参数加到 <Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″
    connectionTimeout=”200000″  maxThreads=”2000″ acceptCount=”500″
            />

就没什么问题了 大家可以试下

转载注明(LINUXQQ)

本文出自 小Q,转载时请注明出处及相应链接。

本文永久链接: http://www.linuxqq.com/archives/175.html

0
更多
Ɣ回顶部