Skip to content

Load balancing configuration

yusing edited this page Feb 6, 2025 · 7 revisions

Concept

Routes with same load_balance.link are grouped in the same load-balancer

Currently only support HTTP(s) routes

Properties

Property Description Default Allowed Values / Syntax
link name and subdomain of load-balancer N/A string
mode load-balance mode round_robin
  • round_robin
  • least_conn
  • ip_hash
options mode specific options N/A N/A

IP Hash Mode Options

See RealIP middleware

Examples

Docker compose

Replicas

services:
  whoami:
    image: traefik/whoami
    deploy:
      replicas: 10
    labels:
      proxy.*.load_balance: |
        link: whoami
        mode: round_robin
    ports:
      - 80
    restart: unless-stopped

Multi-nodes

Set the same load_balance.link across all nodes

services:
  whoami:
    image: traefik/whoami
    container_name: whoami
    labels:
      proxy.whoami.load_balance: |
        link: whoami
        mode: round_robin
    ports:
      - 80
    restart: unless-stopped

Route file

whoami-1:
  host: 10.0.2.1
  load_balance:
    link: whoami
    mode: round_robin
whoami-2:
  host: 10.0.2.2
  load_balance:
    link: whoami
whoami-3:
  host: 10.0.2.3
  load_balance:
    link: whoami