-
Notifications
You must be signed in to change notification settings - Fork 562
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
ConnOpenStrategy should trigger on every query and between life connections, to implement load balance #1208
Comments
Hi @mhlywxl, In the first for-loop, you reuse the same connection. The first iteration of the second loop also reuses the same connection. Do I understand correctly you would like to execute each query on the different server? |
@jkaflik hi Yes, I would like to execute each query on the different server, but the max connections and maxLifeTime config should not affect the result, I wish first-loop log shoud be like the second-loop. In the first for-loop, I know it reuse, reuse is no problem, the problem is I wish it can loop reuse the different connections,not the same connection,because i wish to load balance between different ip host. On the other hand, I config the roundRobin strategy, so first-loop log shoud be like the second-loop. By the way, connections in the connection pool is useful, I sugguest to implement load balance base on this. for example: scene1Config then the pool can be: connection1(ip1),connection2(ip2),connection3(ip3),connection4(ip1) when client call: scene2Config: then the pool can be: connection1(ip1),connection2(ip2),connection3(ip3),connection4(ip1),connection5(ip2),connection6(ip3) when client call: this can implement both availability of connections in the connection pool and load balance on different hosts |
@mhlywxl would you like to contribute? |
Describe the bug
ConnOpenStrategy should trigger on every query and between life connections,this my expect,but now i can only set the ConnMaxLifetime in a smaller interval,such as 3 seconds,and after 3 seconds,the connection idle,and trigger dialStrategy. i wish clickhouse-go should choose connections between the life and good connections. by th way, it should classify the connections by the Addr array. for example, my Addr= [127.0.0.1:29100,127.0.0.2:29100], when ConnOpenStrategy=ConnOpenRoundRobin and 127.0.0.1 and 127.0.0.2 is all good, every time i call connection to exec sql, it should round between 127.0.0.1 and 127.0.0.2.
maybe in the clickhouse-go inside, 127.0.0.1 and 127.0.0.2 has one more connection instance because of MaxOpenConns, but to the caller, he also can round between 127.0.0.1 and 127.0.0.2.
on the whole,i wish clickhouse-go can matain good addrs and good connections pool inside, it shoud clean bad or idle connections inside periodly. ConnOpenStrategy trigger on every query instead of dia.
Code example
log
Expected behaviour
every time call conn.ServerVersion()
it should print different ip from last time
The text was updated successfully, but these errors were encountered: