隨筆 - 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等服務器相關

          主站蜘蛛池模板: 辽中县| 治多县| 松滋市| 桃江县| 武邑县| 鄂州市| 荣成市| 库尔勒市| 上高县| 湘潭县| 临安市| 乌兰察布市| 廊坊市| 溆浦县| 噶尔县| 水城县| 余庆县| 黎城县| 洛阳市| 富锦市| 万载县| 河间市| 乐业县| 右玉县| 巩义市| 萍乡市| 长泰县| 丰台区| 兴海县| 尉犁县| 临江市| 景洪市| 芜湖县| 梧州市| 札达县| 汉川市| 宿松县| 柳河县| 新乐市| 三穗县| 大悟县|