alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.39k stars 8.02k forks source link

too many connection of zookeeper datasource #612

Open yuweibo opened 5 years ago

yuweibo commented 5 years ago

Issue Description

Type: bug report

Describe what happened (or what feature you want)

zookeeper server connections has increased five-fold

Describe what you expected to happen

4 rules one connection enough

How to reproduce it (as minimally and precisely as possible)

  1. 4 rules enabled
  2. telnet zookeeper.host 2181
  3. stat
sczyh30 commented 5 years ago

Hi, thanks for your suggestion. We might need to redesign the push-based data source to use one connection for all kinds of rules. Discussions and contributions are welcomed :)

zhousiliang163 commented 5 years ago

after change,it's compatible with older versions.

linlinisme commented 5 years ago

I have an idea to return multiple data sources in one connection. The key to having multiple data sources on the same link is that their zkClient is the same object. ZookeeperDataSource has defined the zkClient property if you add a constructor ZookeeperDataSource(final CuratorFramework zkClient, final String path, Converter<String, T> parser) zkClient can be passed in externally so that function extensions can be implemented. This change point is very small, I have already implemented it locally. In order to facilitate the upgrade and maintenance in the future, I suggest that it is best not to use the new ZookeeperDataSource method to create a data source, instead use the factory mode method to create, for example com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSourceFactory#createDataSource(java.lang.String, java.lang.String[], com.alibaba.csp.sentinel.datasource.Converter<java.lang.String,T> ) This way we can seamlessly upgrade when we switch the creation method.

linlinisme commented 5 years ago

hi, i find a way to fix this problem and i will offer a PR latter

sczyh30 commented 5 years ago

This has been resolved via a temporary solution: #788

But we need further discussion for the design of data-source (see #649)