<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    放翁(文初)的一畝三分地

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      210 隨筆 :: 1 文章 :: 320 評論 :: 0 Trackbacks

    慢連接&LazyParser

    Author:放翁(文初)

    Mail:fangweng@taobao.com

    Tblog:weibo.com/fangweng

     

    這里要從實際的測試中給Web應用開發(fā)者一個比較直觀的關(guān)于慢連接優(yōu)化的建議。

     

    測試目標:

    1.  證明慢連接對于Java的應用容器的影響。

    2.  不同前端反向代理服務器對于慢連接的處理差異。

    3.  如何利用LazyParser的方式來優(yōu)化慢連接請求(特別是大數(shù)據(jù)量的一些異常請求的處理)

     

    測試部署環(huán)境描述:

    Apache服務器(2.2.19版本)配置基本沒變,增加了http proxy模塊作為反向代理。

    Nginx服務器(1.0.4版本)配置基本沒變,增加了反向代理。

    Jetty服務器(7.1.6版本)配置基本沒變。JettyLazy解析緩存為8k

    部署如下,外部請求可以通過三個入口訪問應用真實邏輯。(apache,nginx,jetty

                                      

     

    測試代碼:

    服務端:

    簡單描述一下邏輯:

    1.       根據(jù)http消息頭判斷采用lazy還是普通方式解析。

    2.       輸出start test表示開始。

    3.       獲取key1,key2的內(nèi)容,并記錄消耗時間輸出phase 1 use:xxx作為獲取這兩個參數(shù)的消耗。

    4.       獲取key4的內(nèi)容,并記錄消耗時間輸出phase 2 use:xxx作為獲取這個參數(shù)的消耗。

    5.       獲取key3的內(nèi)容,并記錄整個請求消耗的時間,輸出end total use:xxx,作為整個處理消耗的時間。

     

    客戶端代碼:

    1.  配置不同入口訪問應用。

    2.  是否設(shè)置使用lazyhttp header來引導服務端處理。

    3.  構(gòu)建參數(shù)集合,參數(shù)順序為(key1,key2,key3,key4)。其中key3作為一個大數(shù)據(jù)字段可變,用于多個場景測試。

     

     

    測試結(jié)果及分析:

    1.  設(shè)置key3大小為1000char,對比多個場景:

    a.       不用lazy解析模式

    (1)     通過nginx訪問:

    Nginx日志(第一位是消耗時間單位秒):0.002 115.193.162.12 - - [20/Jun/2011:10:50:44 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 19 "-" "Jakarta Commons-HttpClient/3.0.1" "-"

    Jetty日志:

    start test: not use lazy

    phase 1 use :0

    phase 2 use :1

    end total use:1

     

    (2)     通過 apache訪問:

    Apache日志:(第二位消耗時間單位微秒):0 3513 115.193.162.12 - - [20/Jun/2011:10:53:24 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 9

    Jetty日志:

    start test: not use lazy

    phase 1 use :0

    phase 2 use :0

    end total use:0

     

    (3)     直接訪問jetty

    Jetty日志:

    start test: not use lazy

    phase 1 use :1

    phase 2 use :0

    end total use:1

     

    b.       lazy解析模式

    同樣是上面三種模式,web容器的日志就不寫出來了結(jié)果一樣,下面主要是貼一下應用服務器的情況:

    ----------------------------------------------------jetty

    start test : uselazy

    Jun 20, 2011 10:57:24 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1019

    phase 1 use :1

    Jun 20, 2011 10:57:24 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: -1

    phase 2 use :0

    end total use:1

    -----------------------------------------------------------nginx

    start test : uselazy

    Jun 20, 2011 10:58:37 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1019

    phase 1 use :0

    Jun 20, 2011 10:58:37 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: -1

    phase 2 use :0

    end total use:0

    -----------------------------------------------------------apache

    start test : uselazy

    Jun 20, 2011 10:58:45 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1019

    phase 1 use :0

    Jun 20, 2011 10:58:45 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: -1

    phase 2 use :1

    end total use:1

     

       上面的輸出增加了一些,其實lazyparser在逐塊解析字節(jié)流的時候每次裝載數(shù)據(jù)的輸出,lazyparser的緩沖區(qū)當前設(shè)置最大為8k,根據(jù)上面的情況可以看到不論哪一種方式,數(shù)據(jù)一次性都被裝載,不存在后端處理的差異。

     

    2.  設(shè)置key3大小為100000char,對比多個場景:

    a.       不用lazy解析模式

    (1)     通過nginx訪問:

    Nginx日志(第一位是消耗時間單位秒):1.528 115.193.162.12 - - [20/Jun/2011:11:05:34 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 19 "-" "Jakarta Commons-HttpClient/3.0.1" "-"(消耗時間大幅上升)

    Jetty日志:

    start test: not use lazy

    phase 1 use :5

    phase 2 use :0

    end total use:6

     

    (2)     通過 apache訪問:

    Apache日志:(第二位消耗時間單位微秒):1 1502243 115.193.162.12 - - [20/Jun/2011:11:07:10 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 9

    Jetty日志:

    start test: not use lazy

    phase 1 use :609

    phase 2 use :0

    end total use:609

     

    (3)     直接訪問jetty

    Jetty日志:

    start test: not use lazy

    phase 1 use :1463

    phase 2 use :0

    end total use:1463

     

    從上面幾個數(shù)據(jù)來看,首先不論哪個入口進去,總的時間處理都在1.5秒左右(我的網(wǎng)絡(luò)狀況還是比較爛),但nginx的數(shù)據(jù)堆積效果對jetty起到了明顯的保護作用,使得jetty整個容器線程池生命周期較短,可以處理更多的請求,apache數(shù)據(jù)堆積不是全量堆積,因此對于jetty來說還需要自身的一些堆積處理(這點在后面的lazy模式下將會更加直觀的看到過程)

     

    b.       lazy解析模式

    (1)     通過nginx訪問:

    Nginx日志(第一位是消耗時間單位秒):1.513 115.193.162.12 - - [20/Jun/2011:11:13:22 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 19 "-" "Jakarta Commons-HttpClient/3.0.1" "-"(消耗時間大幅上升)

    Jetty日志:

    start test : uselazy

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 5911

    phase 1 use :1

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 8192

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 3996

    Jun 20, 2011 11:13:22 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: -1

    phase 2 use :7

    end total use:8

     

    從上面的結(jié)果可以看到,nginx的數(shù)據(jù)堆積效果很好,jetty都是塞滿lazyparser的緩存大小來處理的,所以Java IO次數(shù)少,整體消耗時間短。

     

    (2)     通過 apache訪問:

    Apache日志:(第二位消耗時間單位微秒):1 1521576 115.193.162.12 - - [20/Jun/2011:11:16:37 -0400] "POST /cometpipe/slowtest?key1=1 HTTP/1.1" 200 9

    Jetty日志:

    start test : uselazy

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 5787

    phase 1 use :1

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 2405

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:13,count: 8096

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:280,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:6,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:13,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:10,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:265,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:7,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:13,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:7,count: 8192

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 448

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:6,count: 6419

    Jun 20, 2011 11:16:38 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: -1

    phase 2 use :627

    end total use:628

                       可以看到第一階段處理由于是lazy的模式,沒有像普通請求處理那樣消耗都在第一階段,而是把消耗時間落在了真正要拿那些數(shù)據(jù)處理的第二階段,同時可以看到apache有滿cache和非滿cache的數(shù)據(jù)后傳,同時由于是變積累邊傳遞,每次后傳所消耗的時間都要遠大于nginx,因此對于jetty的保護較弱。(所以如果你不是用mod_jk去直接反向代理到后段的應用容器(jboss,tomcat,jetty)都會使得應用服務器load比較高,線程生命周期長了,線程切換頻繁)

            

    (3)     直接訪問jetty

    Jetty日志:

    start test : uselazy

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1217

    phase 1 use :1

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:294,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:309,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:46 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:287,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:4,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:3,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:273,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:16,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:2,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:246,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:23,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:1,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 1440

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: 882

    Jun 20, 2011 11:22:47 AM com.taobao.top.xbox.framework.http.LazyParser readBytes

    SEVERE: timconsume:0,count: -1

    phase 2 use :1532

    end total use:1533

       上面的輸出大家會看到雖然我給了8klazy解析緩沖區(qū),但是每次過來的數(shù)據(jù)都是1440,這個數(shù)字的含義大家可以去查一下TCP傳輸?shù)臄?shù)據(jù)包大小定義。可以看到,其實如果網(wǎng)絡(luò)速度不佳,我們就會一個一個的得到數(shù)據(jù)包,Java IO次數(shù)及每次消耗的時間都會較長,同時這也是直接把Java應用服務器對外接收請求在高并發(fā),慢請求的狀況下,系統(tǒng)壓力會遠高于前端假設(shè)反向代理http服務器。

     

            

             總結(jié):

             測試很簡單,但說明了幾個問題:

    1.       互聯(lián)網(wǎng)上的請求和內(nèi)網(wǎng)測試環(huán)境完全是兩碼事情(如果你還打算支持mobile)。

    2.       Nginxapache作為反向代理,對于后端的web容器的處理是有一定幫助的,特別是nginx,作為數(shù)據(jù)堆積和海量連接的并發(fā)支持能夠很好的充分利用后端應用服務器的線程資源。

    3.       不論哪一種模式,總體請求時間都是差不多的,因此RT在后端資源不是瓶頸的時候,不會由于你架設(shè)了反向代理而得到優(yōu)化,反而會有所增長(畢竟多了一層中轉(zhuǎn))

    4.       Lazy處理可以極大提高串行化分階段處理的性能(特別是在沒有數(shù)據(jù)堆積的情況下或者是apache這樣的半數(shù)據(jù)堆積的情況下,在nginx模式下失效)。比如一個很大的請求,如果在第一階段就被判斷系統(tǒng)參數(shù)校驗錯誤,那么后續(xù)的請求數(shù)據(jù)將直接拒絕(或者類似于有圖片大小限制或者是圖片個數(shù)限制的判斷)。

    5.       應用服務器(jetty,tomcat,jboss等等)不論使用nio或者bio模式,在慢連接的情況下都會有不小的性能消耗。

     

    對于開放平臺來說,每天處理幾十億的api call,和普通的web應用不同,每一次請求的時間就貫穿于容器對于數(shù)據(jù)流的載入,處理,一點優(yōu)化都可以極大地提高整體的處理能力和資源使用效率,當前開放平臺采用nginx+jetty,雖然可以保護到jetty對于高并發(fā)的慢連接支持,但是整體的響應時間及資源消耗狀況都沒有被充分利用到(雖然Lazy解析已經(jīng)被裝配上,apache+jboss時代比較有效果),因此后續(xù)考慮要做三種改進:1.nginx支持部分數(shù)據(jù)堆積模式。2.優(yōu)化jettybio模式的nio3.替換掉jettynio模塊(netty)。最終不是讓前端采用部分堆積,就是直接暴露應用容器到外部,再加上lazyparser,來完成對于慢連接的優(yōu)化。

    posted on 2011-06-20 23:47 岑文初 閱讀(5357) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導航:
     
    主站蜘蛛池模板: 亚洲午夜成人精品电影在线观看| 亚洲春色另类小说| 成在线人视频免费视频| 亚洲av永久无码制服河南实里 | 国产亚洲日韩在线a不卡| 免费v片在线观看无遮挡| 中国一级特黄的片子免费 | 亚洲精品午夜在线观看| 在线观看免费成人| 两个人看的www高清免费观看| 亚洲人成电影在线观看网| 国产又长又粗又爽免费视频| 成人久久免费网站| 国产精品亚洲综合久久| 亚洲国产精品无码久久一线| 四虎www免费人成| 中文无码成人免费视频在线观看| 一本色道久久88—综合亚洲精品 | 亚洲AV永久无码精品| 99热在线精品免费全部my| 四虎一区二区成人免费影院网址 | 国内精品免费视频精选在线观看| 亚洲中文字幕久久久一区| 亚洲乱码一区二区三区在线观看| 最近最新中文字幕完整版免费高清| 香蕉免费在线视频| 亚洲看片无码在线视频| 亚洲日韩精品一区二区三区无码 | 牛牛在线精品观看免费正| 亚洲天天在线日亚洲洲精| 国产一区二区三区在线观看免费| 1000部羞羞禁止免费观看视频| 九九免费久久这里有精品23 | 香蕉免费一区二区三区| 日韩成人毛片高清视频免费看| 亚洲av永久无码精品三区在线4| 亚洲中文久久精品无码| 国产精品冒白浆免费视频| 一色屋成人免费精品网站 | 国产免费无遮挡精品视频| 97视频免费在线|