Cjen1
Cjen1

Reputation: 1746

Consul Go Client redundant server connection

I'm testing a consul server cluster. I am using the go client for this.

How do I enter multiple servers for the client to connect to?

Optimally it would be something like:

client, err := api.NewClient(api.DefaultConfig())
client.remotes = host_array

Is this a wrong-headed approach to using consul and the expected way for a user is to start a client node and then read the locally replicated state?

Upvotes: 0

Views: 414

Answers (1)

abtreece
abtreece

Reputation: 11

The Consul API client defaults to 127.0.0.1:8500 because there is an expectation that it will connect to a local Consul Agent running in client mode. The Consul Agent should be your "proxy" to the Consul Servers and maintain the connections with active servers so you don't have to.

https://www.consul.io/docs/internals/architecture.html https://github.com/hashicorp/consul/issues/3689

An alternate approach could be to utilize a load balancer for a cluster of Consul Servers. Strategies for that are documented here... https://www.hashicorp.com/blog/load-balancing-strategies-for-consul

Upvotes: 1

Related Questions