<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      web應(yīng)用性能測(cè)試-Tomcat 7 連接數(shù)和線程數(shù)配置

      轉(zhuǎn)自:http://www.jianshu.com/p/8445645b3aff

      引言

      這段時(shí)間折騰了哈java web應(yīng)用的壓力測(cè)試,部署容器是tomcat 7。期間學(xué)到了蠻多散碎的知識(shí)點(diǎn),及時(shí)梳理總結(jié),構(gòu)建良好且易理解的知識(shí)架構(gòu)把它們組織起來,以備忘。
      對(duì)web應(yīng)用開發(fā)者來說,我們很關(guān)心應(yīng)用可同時(shí)處理的請(qǐng)求數(shù),以及響應(yīng)時(shí)間。應(yīng)用本身和它運(yùn)行在其中的web容器是兩個(gè)很重要的影響因素。
      對(duì)tomcat來說,每一個(gè)進(jìn)來的請(qǐng)求(request)都需要一個(gè)線程,直到該請(qǐng)求結(jié)束。如果同時(shí)進(jìn)來的請(qǐng)求多于當(dāng)前可用的請(qǐng)求處理線程數(shù),額外的線程就會(huì)被創(chuàng)建,直到到達(dá)配置的最大線程數(shù)(maxThreads屬性值)。如果仍就同時(shí)接收到更多請(qǐng)求,這些來不及處理的請(qǐng)求就會(huì)在Connector創(chuàng)建的Server Socket中堆積起來,直到到達(dá)最大的配置值(acceptCount屬性值)。至此,任何再來的請(qǐng)求將會(huì)收到connection refused錯(cuò)誤,直到有可用的資源來處理它們。

      分析、梳理、組織

      這里我們關(guān)心的是tomcat能同時(shí)處理的請(qǐng)求數(shù)和請(qǐng)求響應(yīng)時(shí)間,顯然Connector元素的maxThreads和acceptCount屬性對(duì)其有直接的影響。無論acceptCount值為多少,maxThreads直接決定了實(shí)際可同時(shí)處理的請(qǐng)求數(shù)。而不管maxThreads如何,acceptCount則決定了有多少請(qǐng)求可等待處理。然而,不管是可立即處理請(qǐng)求還是需要放入等待區(qū),都需要tomcat先接受該請(qǐng)求(即接受client的連接請(qǐng)求,建立socket channel),那么tomcat同時(shí)可建立的連接數(shù)(maxConnections屬性值)也會(huì)影響可同時(shí)處理的請(qǐng)求數(shù)。
      我們可把tomcat想象成一家醫(yī)院,你來到醫(yī)院大廳掛號(hào)看病,如果人家接受了,就相當(dāng)于client和server建立socket連接了。接著你來到相應(yīng)的科室,科室里每位醫(yī)生都有一間診室,這就相當(dāng)于處理請(qǐng)求的線程;如果所有診室都有病人,科室的調(diào)度護(hù)士會(huì)讓你在科室小廳中耐心等待,直到他們通知你去幾號(hào)診室就診;如果有空閑醫(yī)生,你就可以立即就診。
      有的病人到醫(yī)院很倉促,結(jié)果輪到他掛號(hào)或者就診了,他還在包里翻找病例本和醫(yī)保卡,如果超過了護(hù)士或醫(yī)生心里可承受的等待時(shí)間,他們就會(huì)讓病人到旁邊找去,先服務(wù)下位。這種情形跟Connector元素的connectionTimeout屬性所起的作用很相像。如果當(dāng)前連接器(Connector)在接受連接后,等待了指定的時(shí)間但仍未接收到request URI line,就會(huì)拋出超時(shí)異常。

      知識(shí)點(diǎn)收集

      tomcat 7 的配置參考文檔對(duì)相關(guān)屬性已經(jīng)描述的很詳細(xì)了,這里把它們收集到一起:

      protocol

      Sets the protocol to handle incoming traffic. The default value is HTTP/1.1 which uses an auto-switching mechanism to select either a blocking Java based connector or an APR/native based connector. If the PATH (Windows) or LD_LIBRARY_PATH (on most unix systems) environment variables contain the Tomcat native library, the APR/native connector will be used. If the native library cannot be found, the blocking Java based connector will be used. Note that the APR/native connector has different settings for HTTPS than the Java connectors.
      To use an explicit protocol rather than rely on the auto-switching mechanism described above, the following values may be used:
      org.apache.coyote.http11.Http11Protocol - blocking Java connector
      org.apache.coyote.http11.Http11NioProtocol - non blocking Java connector
      org.apache.coyote.http11.Http11AprProtocol - the APR/native connector.

      Custom implementations may also be used.
      Take a look at our Connector Comparison chart. The configuration for both Java connectors is identical, for http and https.
      For more information on the APR connector and APR specific SSL settings please visit the APR documentation

      maxThreads

      The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

      acceptCount

      The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.

      maxConnections

      The maximum number of connections that the server will accept and process at any given time. When this number has been reached, the server will accept, but not process, one further connection. This additional connection be blocked until the number of connections being processed falls below maxConnections at which point the server will start accepting and processing new connections again. Note that once the limit has been reached, the operating system may still accept connections based on the acceptCount setting. The default value varies by connector type. For BIO the default is the value of maxThreads unless an Executor is used in which case the default will be the value of maxThreads from the executor. For NIO the default is 10000. For APR/native, the default is 8192.
      Note that for APR/native on Windows, the configured value will be reduced to the highest multiple of 1024 that is less than or equal to maxConnections. This is done for performance reasons.
      If set to a value of -1, the maxConnections feature is disabled and connections are not counted.

      connectionTimeout

      The number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. Use a value of -1 to indicate no (i.e. infinite) timeout. The default value is 60000 (i.e. 60 seconds) but note that the standard server.xml that ships with Tomcat sets this to 20000 (i.e. 20 seconds). Unless disableUploadTimeout is set to false, this timeout will also be used when reading the request body (if any).

      進(jìn)一步分析

      tomcat的http connector有三種:bio、nio、apr。從上面的屬性描述中可以看出對(duì)于不同的connector實(shí)現(xiàn),相同的屬性可能會(huì)有不同的默認(rèn)值和不同的處理策略,所以在調(diào)整配置前,要先弄清楚各種實(shí)現(xiàn)之間的不同,以及當(dāng)前部署容器使用的是哪種connector。
      查閱Tomcat 7 http connector 配置文檔Connector Comparison部分便可獲知各種connector實(shí)現(xiàn)間的差異。
      怎樣才能知道容器使用的是何種connector實(shí)現(xiàn)?啟動(dòng)tomcat后,訪問Server Status Page,看到如下信息即可知道使用的是何種connector:

      我的OS是windows,所以tomcat默認(rèn)使用的是apr connector。在linux上,默認(rèn)使用的是bio connector。與nio相比,bio性能較低。將<TOMCAT_HOME>/conf/server.xml中的如下配置片段:

      <Connector port="8080" protocol="HTTP/1.1"
                     connectionTimeout="20000"
                     redirectPort="8443" />

      修改為:

      <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
                     connectionTimeout="20000"
                     redirectPort="8443" />

      就可將http connector切換至nio了。更多細(xì)節(jié)請(qǐng)參考修改Tomcat Connector運(yùn)行模式,優(yōu)化Tomcat運(yùn)行性能

      posted @ 2015-06-17 17:40  tyb1222  閱讀(6748)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 国产稚嫩高中生呻吟激情在线视频| 国产亚洲国产精品二区| 一二三四日本高清社区5| 日韩精品一区二区高清视频| 新平| 国产一区二区不卡在线看| 国产成人a在线观看视频免费| 亚洲一区成人av在线| 欧美videosdesexo吹潮| 9色国产深夜内射| 91精品午夜福利在线观看| 内地自拍三级在线观看| 日本高清成本人视频一区| 成人啪精品视频网站午夜 | 蓬溪县| 国产精品久久久久7777| 日韩精品亚洲专在线电影| 中文人妻AV大区中文不卡| 一区二区三区在线色视频| 国产精品疯狂输出jk草莓视频| 国产精品免费中文字幕| 成全高清在线播放电视剧| 人妻体内射精一区二区三四| 不卡一区二区三区视频播放 | 麻豆精品传媒一二三区| 中文字幕国产精品综合| 精品尤物TV福利院在线网站| 国产一区二区不卡在线| 伊人久久大香线蕉AV网| 日韩激情无码免费毛片| 极品少妇无套内射视频| 日本亚洲欧洲无免费码在线| 亚洲国产精品嫩草影院久久| 日本视频一区二区三区1| 色哟哟www网站入口成人学校| 国产毛片子一区二区三区| 肥东县| 成人啪精品视频网站午夜| 国产精品久久久一区二区三区| 人妻综合专区第一页| 91精品蜜臀国产综合久久|