因為一體化后管理資源數(shù)量可能超過10w臺,后臺準(zhǔn)備使用etcd作為配置和服務(wù)管理中心,和小爽一起做了目錄層級和深度以及集群性能的初測。
單機測試:8核8G
單節(jié)點路徑長度測試,路徑長度為100+是否正常set,生成100層目錄,正常。
curl http://127.0.0.1:2379/v2/keys/test/0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42/43/44/45/46/47/48/49/50/51/52/53/54/55/56/57/58/59/60/61/62/63/64/65/66/67/68/69/70/71/72/73/74/75/76/77/78/79/80/81/82/83/84/85/86/87/88/89/90/91/92/93/94/95/96/97/98/99/100
{"action":"get","node":{"key":"/test/0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42/43/44/45/46/47/48/49/50/51/52/53/54/55/56/57/58/59/60/61/62/63/64/65/66/67/68/69/70/71/72/73/74/75/76/77/78/79/80/81/82/83/84/85/86/87/88/89/90/91/92/93/94/95/96/97/98/99/100","value":"hello etcd","modifiedIndex":502079,"createdIndex":502079}}
單節(jié)點路徑深度測試,程序創(chuàng)建50萬層目錄深度,查看是否正常set和get,50w層正常
-bash-4.1# curl http://127.0.0.1:2379/v2/keys/foo/0
{"action":"get","node":{"key":"/foo/0","value":"Hello world","modifiedIndex":10024,"createdIndex":10024}}
-bash-4.1# curl http://127.0.0.1:2379/v2/keys/foo/500000
{"action":"get","node":{"key":"/foo/500000","value":"Hello 500000","modifiedIndex":510028,"createdIndex":510028}}
單節(jié)點set效率測試,使用Apache ab測試-n 10萬 -c 100并發(fā),1666/s,set foo/0 10w次,index修改正常
more p.txt
value='hello aaa'
Concurrency Level: 100
Time taken for tests: 60.003 seconds
Complete requests: 100000
Failed requests: 0
Write errors: 0
Total transferred: 41315281 bytes
Total PUT: 18211284
HTML transferred: 20707659 bytes
Requests per second: 1666.58 [#/sec] (mean)
Time per request: 60.003 [ms] (mean)
Time per request: 0.600 [ms] (mean, across all concurrent requests)
Transfer rate: 672.41 [Kbytes/sec] received
296.39 kb/s sent
968.81 kb/s total
查看set正常:
curl http://127.0.0.1:2379/v2/keys/foo/0
curl: /usr/local/lib/libidn.so.11: no version information available (required by /usr/local/lib/libcurl.so.4)
{"action":"get","node":{"key":"/foo/0","value":"'hello aaa'\n","modifiedIndex":625767,"createdIndex":625767}}
集群測試,使用三臺機器,編寫monitor,26是leader。3臺機器做ab測試set,效率為1500/s沒有明顯下降,shutdown一臺集群get、set、存儲均不受影響。
Paste_Image.png
ps:常用功能
TTL,五秒key自動消失,常用作服務(wù)注冊
-bash-4.1# curl http://127.0.0.1:2379/v2/keys/test/0/1/2/3/4/5/6/7/8/9/10 -XPUT -d value='hello etcd' -d ttl=5
{"action":"set","node":{"key":"/test/0/1/2/3/4/5/6/7/8/9/10","value":"hello etcd","expiration":"2017-06-01T09:46:52.232946216Z","ttl":5,"modifiedIndex":471890,"createdIndex":471890}}
watch功能,服務(wù)管理
當(dāng)前key watch
curl http://192.168.6.26:2379/v2/keys/foo/test?wait=true
{"action":"set","node":{"key":"/foo/test","value":"Hello world","modifiedIndex":11,"createdIndex":11},"prevNode":{"key":"/foo/test","value":"Hello world","modifiedIndex":10,"createdIndex":10}}
子目錄watch
curl 'http://192.168.6.26:2379/v2/keys/foo?wait=true&recursive=true'
{"action":"set","node":{"key":"/foo/qqq","value":"Hello","modifiedIndex":21,"createdIndex":21},"prevNode":{"key":"/foo/qqq","value":"Hello","modifiedIndex":20,"createdIndex":20}}
事件查詢
curl 'http://192.168.6.26:2379/v2/keys/foo?wait=true&recursive=true&waitIndex=21'
{"action":"set","node":{"key":"/foo/qqq","value":"Hello","modifiedIndex":21,"createdIndex":21},"prevNode":{"key":"/foo/qqq","value":"Hello","modifiedIndex":20,"createdIndex":20}}
遍歷某key
-bash-4.1# curl -s http://192.168.6.151:2379/v2/keys/?recursive=true| jq .
{
"node": {
"dir": true
},
"action": "get"
}