etcd目錄層級和深度及性能等測試

因為一體化后管理資源數(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"
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 134,837評論 18 139
  • 個人學(xué)習(xí)批處理的初衷來源于實際工作;在某個迭代版本有個BS(安卓手游模擬器)大需求,從而在測試過程中就重復(fù)涉及到...
    Luckykailiu閱讀 4,760評論 0 11
  • from http://www.infoq.com/cn/articles/etcd-interpretation...
    小樹苗苗閱讀 13,983評論 3 38
  • Ubuntu的發(fā)音 Ubuntu,源于非洲祖魯人和科薩人的語言,發(fā)作 oo-boon-too 的音。了解發(fā)音是有意...
    螢火蟲de夢閱讀 99,467評論 9 467
  • 最近看《三生三世》,感觸頗多 三生三世看了將近有三遍,看第一遍時,覺得這是一個過程凄美但結(jié)局美好的故事,況且劇中人...
    03f唐唐閱讀 350評論 0 2