Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于启动时往zookeeper注册的优化 #692

Closed
kevin82008 opened this issue Sep 26, 2017 · 5 comments
Closed

关于启动时往zookeeper注册的优化 #692

kevin82008 opened this issue Sep 26, 2017 · 5 comments
Milestone

Comments

@kevin82008
Copy link

kevin82008 commented Sep 26, 2017

目前在启动consumer注册时,每一个暴露的服务需要调用十多次请求往 zookeeper创建节点用于存储 consumer/router/config 等信息,而这十多次调用基本上每次都是无效的(除了第一次调用会真正创建,后面都是不需要的)
可以优化下,启动时应该速度能提升比较多

  1. 请求次数可以少至少一半
  2. 由于判断节点存在的速度比创建节点快太多,而且节点大部分情况下是已经创建好的,可以先判断下,节点不存在才真的创建
    代码
    里面的 create(String path, boolean ephemeral) 递归调用,createPersistent 的时候可以加判断
@chickenlj chickenlj added type/need-triage Need maintainers to triage status/waiting-for-feedback Need reporters to triage type/enhancement and removed type/need-triage Need maintainers to triage labels Oct 9, 2017
@chickenlj
Copy link
Contributor

由于判断节点存在的速度比创建节点快太多
请问你在这里有做过实际性能测试吗?如果有的话烦请提供一些对比数据,我不清楚create自身有没有什么优化措施,需要实际测一下

@kevin82008
Copy link
Author

直接简单代码连接zookeeper测试,当节点存在时,创建单个节点(不抛异常的方式)大概40ms,而判断存在只需要3ms。
在性能比较差的虚拟机上测试,跨机器,内网。

@chickenlj chickenlj added this to the 2.5.7 milestone Oct 17, 2017
@chickenlj chickenlj added priority/normal and removed status/waiting-for-feedback Need reporters to triage labels Oct 17, 2017
@chickenlj
Copy link
Contributor

kevin82008
每一次创建时的服务都是不同的,节点结构:
/dubbo/com.alibaba.dubbo.demo.DemoService/consumers
/dubbo/com.alibaba.dubbo.demo.AnotherService/consumers
正常使用场景下,应该是不存在大量重复create的

@chickenlj
Copy link
Contributor

每个服务分别创建以下节点各一次

/dubbo/com.alibaba.dubbo.demo.DemoService/consumers
/dubbo/com.alibaba.dubbo.demo.DemoService/providers
/dubbo/com.alibaba.dubbo.demo.DemoService/configurators
/dubbo/com.alibaba.dubbo.demo.DemoService/routers

每个服务能减少3次create重复操作,当服务数量多时还是能缩短一点启动时间

@kevin82008
Copy link
Author

@chickenlj 不是减少3次, /dubbo 这一层整个系统只需要创建一次,所以是从原来的创建 4*3=12次,
变成后面的 5次
之前的代码里,是对每一个节点都会循环创建的
先创建 /dubbo
再是 /dubbo/com.alibaba.dubbo.demo.DemoService/
再是 /dubbo/com.alibaba.dubbo.demo.DemoService/consumers

chickenlj added a commit that referenced this issue Oct 28, 2017
* Optimize(AbstractRegistry) registry cache, one registry file per 'registry & application', avoid reload (#685).

* Fixed #692 optimize zookeeper operation in service export/reference process: check already exists before create
rolandhe pushed a commit to rolandhe/dubbo that referenced this issue Sep 9, 2019
* Optimize(AbstractRegistry) registry cache, one registry file per 'registry & application', avoid reload (apache#685).

* Fixed apache#692 optimize zookeeper operation in service export/reference process: check already exists before create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants