Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Load balancing based on dns #1298

Answered by bgrainger
carlokok asked this question in Q&A
Discussion options

I have a kubernetes cluster with manticore inside it (which uses mysql as a protocol); I couldn't find from the docs but does mysqlconnector allow me to do something like:

"Server=manticore-manticoresearch-worker-svc, User=manticore, Password=manticore, Database=manticore, LoadBalance=RoundRobin, DnsCheckInterval=5"

Where it would connect to either 10.240.0.38 or 10.240.0.19 (in this case), instead of hardcoding the addresses (not an option since they can change any any moment)

# host manticore-manticoresearch-worker-svc
manticore-manticoresearch-worker-svc.manticorecluster.svc.cluster.local has address 10.240.0.38
manticore-manticoresearch-worker-svc.manticorecluster.svc.cluster.local has address 10.240.0.19
You must be logged in to vote

LoadBalance=RoundRobin currently only applies to comma-delimited entries in the Server connection string option; multiple IP addresses for a single host name are tried in order. (However, if Dns.GetHostAddresses returns the IP addresses in a different order each time it's invoked by MySqlConnector, then MySqlConnector will end up alternating between them.)

DnsCheckInterval=5 will cause the connection pool to be cleared (and new connections to be made) if the host name manticore-manticoresearch-worker-svc ever resolves to a different set of IP addresses.

So it will "connect to either 10.240.0.38 or 10.240.0.19 (in this case)", but it may prefer to make all connections to 10.240.0.38 based ...

Replies: 2 comments

Comment options

LoadBalance=RoundRobin currently only applies to comma-delimited entries in the Server connection string option; multiple IP addresses for a single host name are tried in order. (However, if Dns.GetHostAddresses returns the IP addresses in a different order each time it's invoked by MySqlConnector, then MySqlConnector will end up alternating between them.)

DnsCheckInterval=5 will cause the connection pool to be cleared (and new connections to be made) if the host name manticore-manticoresearch-worker-svc ever resolves to a different set of IP addresses.

So it will "connect to either 10.240.0.38 or 10.240.0.19 (in this case)", but it may prefer to make all connections to 10.240.0.38 based on the behaviour of Dns.GetHostAddresses. (Enabling "Trace" logging will show what's actually happening.)

You must be logged in to vote
0 replies
Answer selected by carlokok
Comment options

Cool. Since ping picks a different instance every connection, i could just let it do that automatically then. I'll play with this, thanks!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /