High availability in traefik

is there a way in free version of traefik with docker swarm that i assign a service to two different traefik in two separate server so load on a server decrease

if there is can you guide me?

You can have different DNS Records for one hostname, so I assume it should work with multiple instances on multiple nodes.

You could add these DNS Records:

A example.com
A example.com

But it's not best practice to use load balancing through DNS.

you can implement some load sharing using multiple DNS records for the same service. However, this is not the best way to implement load sharing especially in case you have all your hosts reside in the same location. A far more efficient approach will be to use a dedicated machine as load balancer. This machine receives all traffic and forwards it to one of the real servers based on several criteria such as:

  1. Concurrent connections.
  2. Server load.
  3. User source IP.
  4. Round robin.
  5. Weighted round robin, etc...

Another important point in load balancers such as haproxy is the ability to check for failing node and exclude it from the servers list and this is not available in DNS-based method.

Also, DNS caching makes things more complicated and difficult to manage. DNS caching can occur in any node from your client to any intermediate DNS server till reaching the authoritative DNS server.

1 Like

If you use the embedded Letsencrypt (LE) Acme feature, it's not possible to run multiple instance of Traefik (replicated mode)
So I'm currently running LE outside of Traefik, and running Traefik in replicated mode (3 instances on my Docker Swarm) and seems to work ok.

My external LE service provides the certificates on a shared volume between the instances of Traefik and my LE service, and with a yml config file I load this certificates in Traefik.

It works well, but we loose the convenience of automatic certificate generation from the docker labels

I also have set a round robin dns name for my cluster, it works well, even if the dedicated load balancer in front of the cluster would be a better solution