-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support elastic connection holder like connection pool of datasource. #56
Comments
我新建一个继承与AllConnectConnectionHolder的子类MinConnectConnectionHolder 然后重写addNode方法,这样的做法可不可行,初始化连接20(比如,可配置),其他80个新开一个线程并行的去建立连接 before
after
consumerConfig.getMinSynConnectNum() 这个是初始化连接数,其他的异步并行建立连接 |
我这样的一个思路是否可行 |
Sorry, 之前忘记回复了。 你上面的 before 和 after 是反了是吧? 连接数配置项加一个百分比(例如建立50%)和最小数(至少5个)。 |
确实是,统一使用一个配置,而不是单独某个服务 |
经过修改,目前逻辑是这样, 创建一个MinConnectConnectionHolder并继承AllConnectConnectionHolder, 将AllConnectConnectionHolder类中一些原本是私有变量修改protected以提供给子类 MinConnectConnectionHolder使用,例如:uninitializedConnections、aliveConnections、subHealthConnections、retryConnections、providerLock 同时重写addNode方法,与父类中addNode方法不同的是根据设置初始化连接数,将服务者总数量-初始化连接数(需要异步并行的连接数)数量的服务提供者异步与消费者进行连接 其中,新增的两个设置参数有
这两个参数保存在rpc-config-default.json中Consumer相关配置这一块作为默认配置
对于这一个功能扩展,我这样的一个思路是否可行呢? |
实在抱歉,之前漏掉了这个 issue.这个思路可行的. 麻烦帮忙提个 pr. @liangyuanpeng |
好的,非常感谢 |
@ujjboy @leizhiyuan 关于弹性长连接我这边有个思路不知道你俩是否赞成,参考Netty4的源码ChannelPool接口实现类SimpleChannelPool的acquireHealthyFromPoolOrNew()方法:
这样的话不用做初始化那么多连接的操作,通过增加监听器懒加载的方式去添加新连接,一方面减少初始化连接的配置,一方面更加弹性,这思路是否可行? |
@SteNicholas Netty 这里的长连接是对同一个 provider 建立多个长连接, 你做的这个 feature 做的是对一个服务的多个 provider 里的长连接管理。 维度不一样。 |
@ujjboy 集成Netty的SimpleChannelPool,实现多个provider的长连接管理,如下代码所示,初始情况下池子里没有连接,每次获取的时候,如果池子里没有空闲的,就创建一根,用完自行释放,这样可以嚒?
|
你这就跳过了 Router 和 LoadBalancer 的阶段了。 |
The default connection holder of SOFARPC is
AllConnectConnectionHolder
. It means the service consumer will connect to all service provider.If the service provider has a lot of nodes, it will take a long time to establish all connections.
We hope to implement a
ConnectionHolder
like connection pool of data source. For example, if there are 100 providers, we can start to invoke after initial connections (such as 20 providers) have been established, and build the other 80 connections asynchronously and parallelly.The text was updated successfully, but these errors were encountered: