隨筆 - 0, 文章 - 264, 評論 - 170, 引用 - 0
          數據加載中……

          Tomcat 6.0 共享線程池的配置Shared Executor Thread pool(注:轉載于http://www.java2000.net/p11864)


          配置很簡單
          第一步,打開共享的線程池

          1. <Service name="Catalina">  
          2.   <!--The connectors can use a shared executor, you can define one or more named thread pools-->  
          3.   
          4.     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"   
          5.     maxThreads="1000" minSpareThreads="50" maxIdleTime="600000"/>  


          默認前后是注釋<!-- -->掉的,去掉就可以了。其中

          name
          The name used to reference this pool in other places in server.xml. The name is required and must be unique.
          這個是線程池的名字,必須唯一,我們在后面的配置里要用到這個東西

          namePrefix
          (String) The name prefix for each thread created by the executor. The thread name for an individual thread will be namePrefix+threadNumber
          線程的名字前綴,用來標記線程名字的,這樣每個線程就用這個前綴加上線程編號了,比如
          catalina-exec-1
          catalina-exec-2

          maxThreads
          (int) The max number of active threads in this pool, default is 200
          允許的最大線程池里的線程數量,默認是200,大的并發應該設置的高一些,反正只是限制而已,不占用資源

          minSpareThreads
          (int) The minimum number of threads always kept alive, default is 25
          最小的保持活躍的線程數量,默認是25.這個要根據負載情況自行調整了。太小了就影響反應速度,太大了白白占用資源。

          maxIdleTime
          (int) The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads. Default value is 60000(1 minute)
          超過最小活躍線程數量的線程,如果空閑時間超過這個設置后,會被關別。默認是1分鐘。

          threadPriority
          (int) The thread priority for threads in the executor, the default is Thread.NORM_PRIORITY
          線程的等級。默認是Thread.NORM_PRIORITY


          第二步
          在 Connector里指定使用共享線程池
          1. <Connector  
          2.   port="8009"  
          3.   protocol="AJP/1.3"  
          4.   maxThreads="5000"  
          5.   executor="tomcatThreadPool"  

          注意,一旦使用了線程池,則其它的線程屬性,比如 maxThreads等將被忽略


          我測試了一下,由于每次請求不再需要重新分配線程,系統響應速度還是有很明顯的改善的。

          posted on 2010-09-09 09:53 小一敗涂地 閱讀(2324) 評論(0)  編輯  收藏 所屬分類: tomcat、apache、jboss等服務器相關

          主站蜘蛛池模板: 肥乡县| 鹤庆县| 宜宾县| 商南县| 闽侯县| 当涂县| 义马市| 阿拉善盟| 明星| 台北县| 雷波县| 双峰县| 平和县| 获嘉县| 苍南县| 兴安盟| 华池县| 恩施市| 高雄市| 醴陵市| 东乡族自治县| 庄浪县| 鲜城| 涟水县| 咸阳市| 共和县| 苏尼特右旗| 大荔县| 阜新| 依安县| 南汇区| 仙桃市| 珠海市| 京山县| 宝鸡市| 保康县| 永定县| 漳州市| 肇州县| 纳雍县| 茌平县|