跳到主要內容

Mac上的Benchmark

Mac上有各指令模式的效能測試工具:ApacheBench(ab)
挺方便的喔

simonsuteki-MacBook-Pro:~ simonsu$ ab -n 10000 -c 50  http://localhost:3000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            3000

Document Path:          /
Document Length:        277 bytes

Concurrency Level:      50
Time taken for tests:   20.230 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      3990000 bytes
HTML transferred:       2770000 bytes
Requests per second:    494.32 [#/sec] (mean)
Time per request:       101.150 [ms] (mean)
Time per request:       2.023 [ms] (mean, across all concurrent requests)
Transfer rate:          192.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       7
Processing:     2  101  57.3    101     230
Waiting:        2  101  57.3    101     230
Total:          3  101  57.3    101     230

Percentage of the requests served within a certain time (ms)
  50%    101
  66%    131
  75%    149
  80%    159
  90%    179
  95%    192
  98%    202
  99%    208
 100%    230 (longest request)
simonsuteki-MacBook-Pro:~ simonsu$ 

這個網誌中的熱門文章

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…