I'm trying to optimize Docker-Swarm load-balancing in a way that it will first route requests to services by the following priority
- Same machine
- Same DC
- Anywhere else.
Given the following setup:
- DataCenter-I
- Server-I
- Nginx:80
- Server-II
- Nginx:80
- Worker
- Server-I
- DataCenter-II
- Server-I
- Nginx:80
- Worker
- Server-I
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!