跳到主要內容

ab benchmark and chart

apache benchmart又稱ab benchmark
是一套簡單好用的壓測工具
測試的參數網路上眾多說明
或直接執行"ab"指令,也可以看到說明
# ab
ab: wrong number of arguments
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make
    -t timelimit    Seconds to max. wait for responses
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header for POSTing, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)

這邊介紹將ab的結果製圖的工具gnuplot
透過執行gnuplot指令,可以進入互動模式
# gnuplot 
        G N U P L O T
        Version 4.4 patchlevel 3
        last modified March 2011
        System: SunOS 5.11
        Copyright (C) 1986-1993, 1998, 2004, 2007-2010
        Thomas Williams, Colin Kelley and many others
        gnuplot home:     http://www.gnuplot.info
        faq, bugs, etc:   type "help seeking-assistance"
        immediate help:   type "help"
        plot window:      hit 'h'
Terminal type set to 'unknown'
gnuplot>

互動模式下可以輸入製圖的參數:
gnuplot> set terminal png
Terminal type set to 'png'
Could not find/open font when opening font "arial", using internal non-scalable font
Options are 'nocrop medium size 640,480 '
gnuplot> set output "ApacheBenchmarkResults.png" (設定圖片名稱)
gnuplot> set title "Benchmark from Server X"
gnuplot> set size 1,0.5
gnuplot> set key left top
gnuplot> set xlabel 'request'
gnuplot> set ylabel 'ms'
gnuplot> plot "out.dat"  using 10 with lines title 'Benchmark from Server X'  (這句是真正產圖的重點)
gnuplot> exit (離開)
圖形產出如下:


另外修改參數,讓圖形平滑化:
set terminal png
set output "ApacheBenchmarkResults.png"
set title "Benchmark from Server X"
set size 1,0.5
set key left top
set xlabel 'request'
set ylabel 'ms'
plot "out.dat"  using 9 smooth sbezier with lines title "nodejs"
exit
產出圖形如下:

給有需要的人參考...




這個網誌中的熱門文章

Oracle LISTAGG

同事介紹的一個Oracle的好用查詢:LISTAGG
SELECT A.GROUP_ID,A.KEY, LISTAGG(A.VALUE,'; ')WITHINGROUP(ORDERBYA.VALUE)as GG  fromSYS_PROPERTIESaGROUP byA.GROUP_ID,A.KEY
LISTAGG可以將group後的結果會總顯示於一個欄位 上述SQL原本A.VALUE會是一個row一個row的排列 使用LISTAGG之後,可以將A.VALUE顯示在同一個row中 並且可以指定間隔符號(在此設定為';') 針對某一些報表查詢非常有用唷 :D

使用 minikube 輕鬆上手 kubernetes

安裝minikube
macOS只需要透過brew即可快速安裝...
brew cask install minikube
Linux環境可以直接下載執行檔,放到環境變數可以吃到的路徑即可...
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && \ chmod +x minikube && \
sudo mv minikube /usr/local/bin/
Windows的下載網址如下: https://storage.googleapis.com/minikube/releases/latest/minikube-windows-amd64.exe
如果您的kubectl尚未安裝,可以直接使用google cloud sdk來安裝:
curl https://sdk.cloud.google.com | bash
gcloud components install kubectl
安裝完成後,原則上minikube會在本地端加入minikube的k8s context,我們可以透過下面指令來使用該context…
kubectl config use-context minikube
然後,可檢查一下您的minikube node是否正常運作....

新一代LB - Traefik

新一代LB-Traefik Traefik突破以往我們對loadbalancer的觀點,他是一套直接與docker整合的loadbalancer套件...透過Traefik,我們可以使用label的方式將後面啟動的dockerinstance掛載到loadbalancer中,且無需重新啟動Traefik,可直接生效... Traefik基本介紹 Traefik是以動態重載新加入的dockerinstance的方式來替有附加相同domainlabel的dockerinstance建立網路附載平衡的關聯...因此,設定上,與一般我們建立reverseproxy的過程剛好相反(一般我們會先建立服務,再建立reverseproxy將服務串連起來)... Step1-建立Traefik服務 下面我們用官方的composefile來說明... File:docker-compose.yaml version: '2' services: proxy: image: traefik command: --api --docker --docker.domain=docker.localhost --logLevel=DEBUG networks: - webgateway ports: - "80:80" - "8080:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock - /dev/null:/traefik.toml networks: webgateway: driver: bridge 其中traefik啟動時候,我們需要指定docker.domain來告訴taefik要聆聽的domain是哪一個,然後要事先開啟對應的port,讓外部服務可以連到traefik...,另外,我們將dockersocket掛載進來,這是必要的設定,讓traefik可以透過dockersocket來操控一些東西...,最後,traefik.toml檔案,我們保留空的,讓treafik自己建立... 啟動: docker-compose -f docker…