0

I'm trying to optimize Docker-Swarm load-balancing in a way that it will first route requests to services by the following priority

  1. Same machine
  2. Same DC
  3. Anywhere else.

Given the following setup:

  • DataCenter-I
    • Server-I
      • Nginx:80
    • Server-II
      • Nginx:80
      • Worker
  • DataCenter-II
    • Server-I
      • Nginx:80
      • Worker

In case and DataCenter-I::Server-II::Worker will issue an API request over port 80, The desired behavior is:

  • Check if there are any tasks (containers) mapped to port:80 on local server (DataCenter-I::Server-II)
  • Fallback and check in local DataCenter (i.e DataCenter-I::Server-I)
  • Fallback and check in all clusters (i.e DataCenter-II::Server-I)

This case is very useful when using workers and response time doesn't matter while bandwidth does.

Please advise, Thanks!

eldad87
  • 195
  • 1
  • 13

1 Answers1

0

According to this question I asked before, docker swarm is currently only using round-robin and no indication to be pluginable yet.

However, Nginx Plus support least_time load balancing method, which I think there will be an similar open-source module, and it is similar to what you need, with perhaps the least effort.

ps: Don't run Nginx with the docker swarm. Instead, run Nginx with regular docker or docker-compose in the same docker network of your app. You don't want docker swarm to load balancing your load balancer.

benjah1
  • 1,440
  • 1
  • 13
  • 17