Cloudfoundry plans to add support for DNS A records that maps to multiple IPs (one per app container instance), see docs-proposal. I wonder whether spring-cloud discovery coupled with ribbon can support DNS-based client load balancing.
The spring-cloud DiscoveryClient does not seem to do DNS resolutions, it manages host names
The ribbon load balancing library supports a list of FQDNs through the ListOfServers property.
But I could not spot documentation related to DNS lookup of the specified servers: i.e. would Ribbon load balance across IP address if a DNS A/AAA record (fetched from the ListOfServers ) returns multiple ip addresses ?
Where would I need to configure DNS caching directives ? Would this is JVM-wide in the java.security support or can I manage this as client-slide load balancing options (from ribbon) ?
Ribbon does not perform any DNS lookups, it returns an entry from the ServerList as-is (either an IP or a name).
You don't need Ribbon for DNS-based load balancing; the OS resolver will rotate between the available IP addresses for each lookup. Just make sure not to cache DNS.
For a more complex load balancing you'll need to resolve DNS into a list of IPs and then pass that to Ribbon.
If you are using spring cloud eureka service, every service instance registers at eureka. This means you can host multipe instances of the same service at the same host and eureka knows every single service.
If you use ribbon for client based loadbalancing so ribbon queries eureka for all instances of a services and knows every single instance of a service.
This way ribbon can choose to connect to every single instance.
Because of this there is no need for multiple DNS A records. It's counterproductive to use multiple DNS A records because ribbon can't distinguish mutliple instances of a service by DNS any more. In this case I would suggest to set eureka.instance.preferIpAddress
to true, to distinguish mutliple instances.
As far as I know ribbon supports 2 working modes, RoundRobinRule and AvailabilityFilteringRule.
A good introtuction you can find in the book "Spring microservices".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With