Linux links

0

SLAX

gcin 同好會

KNOPPIX中文交流網

自由軟體技術交流網

開放原始碼新聞網

自由軟體鑄造場

Mozilla Taiwan

鳥哥的 Linux 私房菜

酷!學園討論區

kaise

httperf and autobench in Slax

0

源起

下面內容可能出現之前做過而省略或是疏漏現象,如有問題請告訴我或是參考之前本站的 Native Tomcat in Slax 一文,也許可以找到相關提示。

my_7_crash.svg

網站要掛了嗎 ?

網站的效能往往需要測試才知道可以跑到哪種程度,平常就應該要測看看,在掛掉之前趕快解決。

關於測試工具 httperf 與 autobench 的部份,請閱讀 HTTP performance testing 一文,有非常詳細的內容可以參考,這裡是要轉化為 slax 可以用的 mo,方便在 vmplayer 之中運行。

一開始要做的是取得檔案後開始安裝 httperf 與 autobench 。

checkinstall httperf

  1. cd /mnt/hda1
  2. wget httperf-0.8.tar.gz
  3. uselivemod Official_Development_module_5_1_4.mo
  4. tar zxvf httperf-0.8.tar.gz
  5. cd httperf-0.8
  6. ./configure
  7. make
  8. checkinstall
  9. mv httperf-0.8-i386-1.tgz /mnt/hda1

checkinstall autobench

  1. cd /mnt/hda1
  2. wget autobench-2.1.2.tar.gz
  3. tar zxvf autobench-2.1.2.tar.gz
  4. cd autobench-2.1.2
  5. ./configure
  6. make
  7. checkinstall
  8. mv autobench-2.1.2-i386-1.tgz /mnt/hda1/

開始測試之前需要網站,這裡用本機的 Tomcat 來測。

start tomcat

  1. uselivemod jre-1_5_0_08-linux.mo
  2. uselivemod apache-tomcat-5.5.15.mo
  3. /usr/local/tomcat/bin/startup.sh
  4. netstat -at

httperf first run

第一次跑用比較少的人數,只用 10 個。

httperf—server=192.168.213.131—port=8080—rate=10—num-conns=500

httperf --client=0/1 --server=192.168.213.131 --port=8080 
--uri=/ --rate=10 --send-buffer=4096 --recv-buffer=16384 
--num-conns=500 --num-calls=1

Maximum connect burst length: 1

Total: connections 500 requests 500 replies 500 test-duration 49.909 s

Connection rate: 10.0 conn/s (99.8 ms/conn, <=2 concurrent connections)
Connection time [ms]: min 1.0 avg 2.0 max 184.5 median 1.5 stddev 8.3
Connection time [ms]: connect 0.0
Connection length [replies/conn]: 1.000

Request rate: 10.0 req/s (99.8 ms/req)
Request size [B]: 66.0

Reply rate [replies/s]: min 10.0 avg 10.0 max 10.0 stddev 0.0 (9 samples)
Reply time [ms]: response 2.0 transfer 0.0
Reply size [B]: header 149.0 content 8132.0 footer 0.0 (total 8281.0)
Reply status: 1xx=0 2xx=500 3xx=0 4xx=0 5xx=0

CPU time [s]: user 0.55 system 48.17 (user 1.1% system 96.5% total 97.6%)
Net I/O: 81.7 KB/s (0.7*10^6 bps)

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

換個動態 JSP 試看看,加上—uri=/jsp-examples/jsp2/el/basic-arithmetic.jsp 跑起來,沒太大差異,都還沒到瓶頸。

問題在於要找到極限需要不斷加大設定值來測試,手動當然可以,不過這工具已經有人寫好了。

autobench first test

轉用 autobench 來跑多次的結果方便找出掛掉的地方。

autobench --single_host --host1 192.168.213.131 --port1 8080 --uri1 / --quiet \
--low_rate 10 --high_rate 50 --rate_step 10 --num_call 1 \
--num_conn 1000 --timeout 5 --file results.tsv 

結果如下,大致還是可以看出 req_rate 都可以跟上。

dem_req_rate    req_rate_192.168.213.131        con_rate_192.168.213.131       
min_rep_rate_192.168.213.131     avg_rep_rate_192.168.213.131    
max_rep_rate_192.168.213.131    stddev_rep_rate_192.168.213.131 
resp_time_192.168.213.131      net_io_192.168.213.131   errors_192.168.213.131
10      10.0    10.0    10.0    10.0    10.0    0.0     1.1     81.6    0
20      20.0    20.0    20.0    20.0    20.0    0.0     1.1     163.2   0
30      30.0    30.0    30.0    30.0    30.0    0.0     1.0     244.8   0
40      40.0    40.0    40.0    40.0    40.0    0.0     1.1     326.4   0
50      50.0    50.0    50.0    50.0    50.0    0.0     1.0     408.0   0

文字檔很難看出正確的趨勢,還是轉圖出來看比較方便找出關鍵。

download gnuplot

輸出圖案來判讀簡單了解,不過需要先下載 gnuplot mo 來裝。

  1. cd /mnt/hda1
  2. wget gnuplot_4_0.mo
  3. uselivemod gnuplot_4_0.mo

裝好就可以用 bench2graph 跑看看。

bench2png

autobench 附的 bench2graph 會輸出 postscript 格式,這裡換成 PNG 格式。改成 echo set terminal png small color 的命令。

  1. cd /usr/local/bin
  2. cp bench2graph bench2png
  3. vi bench2png
  4. cd to autobench results dir
  5. bench2png results.tsv result.png

上圖可以看到整個線性上升,尚未到底,再加點負荷,跑一次看看,同時為了避免流量飆高,整個 Y 軸都是流量,會導致其他數值看起來躺在 X 軸上,所以採用指定欄位的做法,避掉 net_io 這一欄。

# autobench --single_host --host1 192.168.213.131 --port1 8080 --uri1 / --quiet \
--low_rate 10 --high_rate 100 --rate_step 10 --num_call 10 \
--num_conn 1000 --timeout 5 --file results2.tsv
bench2png results2.tsv results2.png 4 5 6 7 8

圖中可以看到卡在800-900 請求/秒 (80-90 連線/秒) 的時候,急速墜落。

道這裡完成基本安裝與測試,接下來可以包個 mo 出來用了,免得關機完要再來一次。

dir2mo autobench mo

為求以後測試方便,將 httperf 與 autobench 包成一個 mo,同時加上改的 bench2png。

  1. cd /mnt/hda1/work
  2. mkdir autobench
  3. installpkg -root autobench ../autobench-2.1.2-i386-1.tgz
  4. installpkg -root autobench ../httperf-0.8-i386-1.tgz
  5. cp /usr/local/bin/bench2png autobench/usr/local/bin/
  6. dir2mo autobench autobench-2.1.2.mo
  7. reboot for test.

包完後開機一次做完整測試。

uselivemod autobench-2.1.2.mo

  1. cd /mnt/hda1/work
  2. uselivemod jre-1_5_0_08-linux.mo
  3. uselivemod apache-tomcat-5.5.15.mo
  4. uselivemod gnuplot_4_0.mo
  5. uselivemod autobench-2.1.2.mo
  6. /usr/local/tomcat/bin/startup.sh
  7. cd /tmp
  8. autobench again
  9. bench2png results.tsv results.png 4 5 6 7 8

這裡可以用更細的方式試看看,改取每次加五個方式。

autobench --single_host --host1 192.168.213.131 --port1 8080 --uri1 / --quiet \
--low_rate 50 --high_rate 100 --rate_step 5 --num_call 10 \
--num_conn 1000 --timeout 5 --file results.tsv 

看起來 750需求 (75連線) 左右就開始不穩。奇怪的是後來又線性上揚,不清楚是不是 JVM 的 GC 運作導致 Tomcat 一口氣喘不過來,有機會再多做些測試。

download autobench-2.1.2.mo

autobench-2.1.2.mo

links

The Linux HTTP Benchmarking HOWTO

httperf—-A Tool for Measuring Web Server Performance

Inkscape in practice

0

小小建議

IE 本身不支援 SVG,同時不支援 PNG alpha transparency 功能,因為這只是練習,所以不打算針對 IE 做些專門修改,強烈推薦 firefox 瀏覽。

練習練習練習

為了保持熟練,這裡將會不斷留下練習的結果。

道繁客

基本的中文字排列。

my_1_exp.svg

肥源力

Fource = Fat + Source

my_2_fource.svg

速度感

距離除以時間,每個人感受不同,速限在哪裡 ?

my_3_maxspeed.svg

安心感

距離除以時間,沒有一定的速度,哪裡都去不了。

my_4_minspeed.svg

需要幫助

幫忙找書 的事一直在心上,所以做個圖增加印象,同時也是練習,為求輸出 PNG 可以不輸出下面的方形白色區,採用物件 Difference 做法,切掉下面的方形。

my_5_needhelp.svg

善惡兩極,盡歸於天,參閱 祆教 說明。

my_6_zoroast.svg

Inkscape and SVG

0

小小建議

IE 本身不支援 SVG,同時不支援 PNG alpha transparency 功能,因為這只是練習,所以不打算針對 IE 做些專門修改,強烈推薦 firefox 瀏覽。

緣起

Inkscape 是個開放的 SVG 編輯軟體,雖然目前功能不及商業版本,不過免費的特性,讓大家可以自由下載享受動手作 SVG 的樂趣。

紅十字加點

基本設定與劃出十字的圖案,下為匯出的PNG檔。

運行的過程請參考 ink_1_redcrossdot screencast

  1. 開啟 Inkscape
  2. 改大小
  3. 取 320×180
  4. 放大符合視窗
  5. 秀格線
  6. 改格線大小
  7. 畫底方形
  8. 變更底色與邊框
  9. 調整方形圓角
  10. 加十字橫
  11. 加十字豎
  12. shift 將兩個方形一起選後合併成單一路徑
  13. 加個小點
  14. 採用漸層
  15. 設定文件 metadata
  16. 存檔
  17. 匯出成 PNG

ink_1_redcrossdot.svg

原點

畫圖如果需要比較精確的定位,就需要自訂參考線 Guide Line。準備 320×180 開畫,下為匯出的PNG檔。

運行的過程請參考 ink_2_origin screencast

  1. 要拉參考線需要從尺規處開始拉
  2. 拉完可以看到參考線
  3. 可以編輯到精確位置
  4. 換拉水平參考
  5. 改中間 90
  6. 畫三角形
  7. 做副件
  8. 變形
  9. 先倒過來
  10. 先左移 50 看看
  11. 再加碼 10
  12. 換邊做一次
  13. 換個顏色會所以副件一起改
  14. 再下拉 10

ink_2_origin.svg

links

Inkscape 官方網站

A Guide to Inkscape 一定要看

Open Clip Art Library 必去之處

Plant Inkscape 網站匯集

TedPage blog

Inkscape 基本功能簡報

TODO

尼伯龍根的指環

女武神 Valkyrie Warrior

Native Tomcat in SLAX

0

緣起

年初做了個簡易測試 Tomcat 的 APR 連接器簡易測試 發布在 javaworld@TW 網站,現在想在 SLAX popcorn 上面跑看看,這裡將先作編譯與環境準備工作,也就是產出相對的 mo 檔。

下圖為本文產出的 mo 安裝之後,用 firefox 跑出來的部份畫面。

更新紀錄 Changelog

  1. 2006-09-26 APR 本身編譯時可能以為系統有 sendfile 支援,但是執行時候卻發現沒有這樣支援,可能是檔案系統的支援問題 ? 待查,這個現象在 Apache in Slax 一文 中有遇到,可以在設定檔關掉這個行為,Tomcat 也可以設定 useSendfile 參數來關掉,預設是有開啟的。所以說下面做法如果沒有做到修正檔案系統或是關掉設定的輔助,很可能會導致更慘的效率,白忙一場。但是這在一般 ext2/ext3 應該都沒問題,不過這裡畢竟是談 SLAX 環境,特此加上說明。

準備

有些步驟可能之前做過而出現省略或是疏漏現象,請告訴我或是請參考之前本站的 gcin in slax popcorn 一文,也許可以找到相關提示。

編譯需要準備一些工具,當然要跑 tomcat 之前須先有 JRE。一開始先到 Apache Tomcat 5.5.17 下載,然後主要參考 Apache Portable Runtime and Tomcat 的說明來進行。

Create jre mo

先裝安裝檔,再加連結到 /usr/local/bin/java 執行檔與 /usr/local/java 目錄,接著用 dir2mo 包成 mo 檔,並裝上去測看看。

  1. cd /mnt/hda1
  2. wget jre-1_5_0_08-linux-i586.bin
  3. chmod +x jre-1_5_0_08-linux-i586.bin
  4. cd /mnt/hda1/work
  5. mkdir -p java/usr/local
  6. cd java/usr/local/
  7. /mnt/hda1/jre-1_5_0_08-linux-i586.bin
  8. yes
  9. ls
  10. jre1.5.0_08/bin/java -version
  11. mkdir bin
  12. cd bin
  13. ln -s ../jre1.5.0_08/bin/java java
  14. ./java -version
  15. cd /mnt/hda1/work/java/usr/local
  16. ln -s jre1.5.0_08 java
  17. java/bin/java -version
  18. cd /mnt/hda1/work
  19. dir2mo java jre-1_5_0_08-linux.mo
  20. uselivemod jre-1_5_0_08-linux.mo
  21. java -version

Tomcat test run

tomcat 後來預設用 eclipse 的編譯器,所以目前只要裝 JRE 1.5 版,並不需要裝到 JDK 版本,但是編譯 tcnative 需要 JDK,等一下會談到。

  1. cd /mnt/hda1
  2. wget apache-tomcat-5.5.17.tar.gz
  3. tar zxvf apache-tomcat-5.5.17.tar.gz
  4. export JAVA_HOME=/usr/local/java
  5. apache-tomcat-5.5.17/bin/startup.sh
  6. netstat -at | grep 8080
  7. more apache-tomcat-5.5.17/logs/catalina.out

一開頭部份可以看到 APR 沒有載入。

INFO: The Apache Tomcat Native library which allows optimal performance 
in production environments was not found on the java.library.path:....

Create the jdk mo

編譯 tomcat-native-1.1.3 需要 JDK 的一些檔案,所以建立需要的 jdk mo 檔,這個檔約需要 130M 的空間來解開,所以要注意一下空間。

  1. cd /mnt/hda1
  2. wget jdk-1_5_0_08-linux-i586.bin
  3. chmod +x jdk-1_5_0_08-linux-i586.bin
  4. cd /mnt/hda1/work
  5. mkdir -p jdk/usr/local
  6. cd jdk/usr/local/
  7. /mnt/hda1/jdk-1_5_0_08-linux-i586.bin
  8. jdk1.5.0_08/bin/java -version
  9. cd /mnt/hda1/work
  10. dir2mo jdk jdk-1_5_0_08-linux.mo
  11. uselivemod jdk-1_5_0_08-linux.mo
  12. /usr/local/jdk1.5.0_08/bin/java -version

Create the openssl mo

另外也需要 openssl,爆米花只有裝精簡版,換上完整版。

  1. search openssl in http://slackware.it/en/pb/
  2. wget openssl-0.9.8b-i486-1.tgz
  3. cd /mnt/hda1/work
  4. mkdir openssl
  5. installpkg -root openssl /mnt/hda1/openssl-0.9.8b-i486-1.tgz
  6. dir2mo openssl openssl-0.9.8b.mo
  7. uselivemod openssl-0.9.8b.mo

install Apache Portable Runtime

編譯之前需要 Apache Portable Runtime

  1. apache-tomcat-5.5.17/bin/shutdown.sh
  2. uselivemod /mnt/hda1/Official_Development_module_5_1_4.mo
  3. cd /mnt/hda1
  4. wget apr-1.2.7.tar.bz2
  5. tar jxvf apr-1.2.7.tar.bz2
  6. cd apr-1.2.7
  7. ./configure
  8. make
  9. make install

預設會裝到 /usr/local/apr/

install tomcat native

  1. cd apache-tomcat-5.5.17/bin/
  2. tar zxvf tomcat-native.tar.gz
  3. cd tomcat-native-1.1.3/jni/native
  4. ./configure—with-apr=/usr/local/apr—with-java-home=/usr/local/jdk1.5.0_08
  5. make
  6. make install
  7. ls /usr/local/apr/lib

關鍵在於環境變數 LD_LIBRARY_PATH,只要設對,tomcat 就會啟動 APR

  1. export LD_LIBRARY_PATH=/usr/local/apr/lib
  2. cd /mnt/hda1/apache-tomcat-5.5.17
  3. bin/startup.sh
  4. tail -100 logs/catalina.out
  5. bin/shutdown.sh

catalina.out 可以看出差異,非 APR 的版本可以找到 Http11BaseProtocol start 字眼,有 APR 的版本可以找出 Http11AprProtocol start。

make apr-tcnative.mo

既然直接編譯可以裝,必須轉成 mo 測看看,這裡將 apr-1.2.7 與 tomcat-native-1.1.3 兩個安裝一起後包成 apr-tcnative-1.1.3.mo 來用。

  1. cd /mnt/hda1/apr-1.2.7
  2. checkinstall
  3. mv apr-1.2.7-i386-1.tgz /mnt/hda1
  4. cd /mnt/hda1/apache-tomcat-5.5.17/
  5. cd bin/tomcat-native-1.1.3/jni/native/
  6. checkinstall
  7. mv native-native-i386-1.tgz /mnt/hda1/tomcat-native-i386-1.tgz
  8. cd /mnt/hda1/work
  9. mkdir apr-tcnative
  10. installpkg -root apr-tcnative ../apr-1.2.7-i386-1.tgz
  11. installpkg -root apr-tcnative ../tomcat-native-i386-1.tgz
  12. dir2mo apr-tcnative apr-tcnative-1.1.3.mo
  13. reboot for test

make tomcat.mo

重開後測試 apr-tcnative-1.1.3.mo 可以的話,就準備改一下 tomcat 來包 apache-tomcat-5.5.15.mo,讓啟動 APR 模式比較簡單。

  1. cd /mnt/hda1/work
  2. mkdir -p tomcat/usr/local
  3. cd tomcat/usr/local
  4. tar zxvf ../apache-tomcat-5.5.17.tar.gz
  5. cd apache-tomcat-5.5.17
  6. vi bin/catalina.sh

這裡有個考量,必須指名 JAVA_HOME 的位置,而這個位置卻是每次裝新的 JRE 都會更換的,所以設到 /usr/local/java,加上下面一行。

export JAVA_HOME=/usr/local/java

  1. uselivemod jre-1_5_0_08-linux.mo
  2. uselivemod apr-tcnative-1.1.3.mo
  3. cd bin
  4. cp startup.sh startapr.sh
  5. vi startapr.sh

主要是把環境變數寫入,不用每次輸入,加上下面一行。

export LD_LIBRARY_PATH=/usr/local/apr/lib

開始測看看。

  1. ./startapr.sh
  2. tail -100 logs/catalina.out
  3. ./shutdown.sh

可以跑就準備包起來,同時做個捷徑 /usr/local/tomcat。

  1. cd /mnt/hda1/work
  2. cd tomcat/usr/local
  3. ln -s apache-tomcat-5.5.17 tomcat
  4. cd /mnt/hda1/work
  5. dir2mo tomcat apache-tomcat-5.5.17.mo
  6. reboot

final tomcat-native mo test run

重開後就可以把需要的 mo 載入跑看看。

  1. cd /mnt/hda1/work
  2. uselivemod jre-1_5_0_08-linux.mo
  3. uselivemod apr-tcnative-1.1.3.mo
  4. uselivemod apache-tomcat-5.5.17.mo
  5. /usr/local/tomcat/bin/startapr.sh
  6. netstat -at
  7. tail -100 /usr/local/tomcat/logs/catalina.out
  8. uselivemod ttf-arphic-uming-0.1.mo
  9. uselivemod firefox-1.5.0.6-zh_TW.mo
  10. uselivemod gcin-1.2.5.mo
  11. ldconfig
  12. startx
  13. firefox to http://127.0.0.1:8080/

Download

下面軟體都是 Apache 改作,所以採 Apache License 釋出,非本站慣用 授權

apr-tcnative-1.1.3.mo [860K]

apache-tomcat-5.5.17.mo [5964K]

Older posts: 1 2 3 4 5