etcd目录层级和深度及性能等测试

因为一体化后管理资源数量可能超过10w台,后台准备使用etcd作为配置和服务管理中心,和小爽一起做了目录层级和深度以及集群性能的初测。

单机测试:8核8G

单节点路径长度测试,路径长度为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}}

单节点路径深度测试,程序创建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}}

单节点set效率测试,使用Apache ab测试-n 10万 -c 100并发,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自动消失,常用作服务注册

-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功能,服务管理

当前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"
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,026评论 19 139
  • 个人学习批处理的初衷来源于实际工作;在某个迭代版本有个BS(安卓手游模拟器)大需求,从而在测试过程中就重复涉及到...
    Luckykailiu阅读 4,792评论 0 11
  • from http://www.infoq.com/cn/articles/etcd-interpretation...
    小树苗苗阅读 13,999评论 3 38
  • Ubuntu的发音 Ubuntu,源于非洲祖鲁人和科萨人的语言,发作 oo-boon-too 的音。了解发音是有意...
    萤火虫de梦阅读 99,628评论 9 467
  • 最近看《三生三世》,感触颇多 三生三世看了将近有三遍,看第一遍时,觉得这是一个过程凄美但结局美好的故事,况且剧中人...
    03f唐唐阅读 352评论 0 2