Search code examples
spring-bootspring-cloudmicroservicesconsul

Registering with consul servers vs consul clients


I am creating a spring boot microservices application with 3 microservices. I'm using consul for discovery. I have only a single data centre with 4 hosts. Should I have 3 microservices connecting to 3 consul agents(clients) in their respective localhosts and a consul server running on the remaining one host? It is mentioned that a cluster should have more than one server. Is it applicable in above situation?


Solution

  • Your services should connect to an agent on localhost.

    Consul servers should be run in a cluster. A 3 node cluster can handle 1 node failure, a 5 node cluster can handle 2 nodes failing. See https://www.consul.io/docs/internals/consensus.html#deployment_table