I
I
Ilya Rodionov2019-05-25 12:08:31
Nginx
Ilya Rodionov, 2019-05-25 12:08:31

Balancing on docker swarm instances?

Colleagues, hello.
I am slowly "pollinated" by training docker clusters, how it all works, etc., etc.
Now in my clusterer there are 2 managers, 2 wokreers. A swarm has a dozen instances that look at the web.
Behind the cluster is a proxypass web server that proxies requests from the world to instances within the cluster. Now it works like this, but there are several questions:
1. how is it correct / better to implement such a scheme *?
2. there are some traefic and similar systems. or the usual good nginx for balancing is the easiest?
3. how best to "distribute" requests.
and now more about the scheme *
by-design now everything works for me like this:
user -> proxypass server that sends requests to the manager's ip:port -> manager -> backend (instance)
If you show on your fingers, then, let's assume:
proxypass ip 10.0.0.1
ip-manager1 10.0.0.2
ip-manager2 10.0.0.3
ip -worker1 10.0.0.4
ip-worker2 10.0.0.5
Regardless of where the instance is located (on worker1, 2 or manager), all requests from 10-0-0-1 go to 10.0.0.2, and then the "manager" will figure it out , where to send requests to, since instances in the local network are open on ports 10000-10100.
That is, for example, the nginx instance works in such a way that it is written in docker-compose:
ports:
- 10001:80
and, accordingly, in the proxy pass I will write 10.0.0.2:10001.
There are several questions at once, as I wrote above. First, how "correctly" am I doing this? Since, as I understand it, if manager1 stops standing for a while, then all requests will spill, since there will be nowhere to send them.
How to deal with cookies? Because if some wordpress works on three instances, then by round-robin I will hit three different instances three times, go through authorization three times ( in fact , because of this, the question arises, is it necessary to use LB in docker-stack cluster so that it stores cookies(?) ).
In fact, there are many questions, interest, to be honest, no less - something new and cool.
It will be cool if we can discuss and chat about this topic in the comments, thanks.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question