Using consul to remove load balancers

I’ve heard that I can use Consul to remove load balancers for east/west traffic within my datacenter. Is there a pattern for that?

Replacing a load balancer entirely might be a slight stretch but it all depends on your needs. Consul provides service discovery including through DNS.

When you make a DNS query against Consul for web.service.consul, first all the web service instances are looked up. Consul will then randomize the order the A/AAAA records are returned for them. In that way Consul can enable making connections to web.service.consul to be randomized to all the service instances of web.

Consul however doesn’t know about the load on those services and therefore doesn’t have a way to make a more intelligent decision about which instance traffic should be routed towards. If all you need is to spread individual connections to multiple instances without the originators of those connections being aware, then Consul can do that. If you need to spread bandwidth evenly then you probably still need a load balancer.

Even if you do still require a load balancer Consul can be a part of that too. Some load balancers can use SRV DNS records emitted by Consul to populate the targets for a load balancer to use instead of having to have them statically configured.

Hope this helps.

2 Likes

I wrote this example a while ago to create a service mesh with connect:

This would allow you to use envoy as a sidecar proxy and fine tune those connections to the local datacenter but surely you can do the same with consul connect proxy alone.