spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

ConsulServerList to support multiple data center #329

Open ezraroi opened 7 years ago

ezraroi commented 7 years ago

Currently, when using consul and ribbon (ZoneAwareLoadBalancer), multiple data centers are not supported so it is not really zone aware.

Looks like a simple change in the getServers method in ConsulServerList to first query for all data centers and after it query each data center for the healthy services.

ezraroi commented 7 years ago

also looks like when using consul, the ZonePreferenceServerListFilter should be used and not the HealthServiceServerListFilter

varnson commented 5 years ago

Consul supports multiple data centers to share data, but is different with eureka. So I don't think it's a good idea to use consul in the eureka way. Consul has it's own query interface(/v1/query/) to get data from another data center.

ezraroi commented 5 years ago

@varnson This is not true. Consul also support service discovery via multiple data center. This is how we use it. We implemented a MultizoneDatacenterServerList.

varnson commented 5 years ago

@ezraroi Yes, consul support service discovery via multiple data center. And consul has a query interface to query services between data centers. https://www.consul.io/api/query.html So I think there is no need to use MultizoneDatacenterServerList.

ezraroi commented 5 years ago

@varnson by having it as a server list filter we create ribbon clients that sends requests to different data center of a service doesn't exists in the current data center