Estou tentando fazer haproxy
solicitações de proxy para várias réplicas:
docker-compose.yml
:
services:
haproxy:
image: haproxy:2.3-alpine
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
ports:
- 8888:80
app:
build: .
command: perl app.pl
init: true
deploy:
replicas: 10
haproxy.cfg
:
global
maxconn 1024
listen in
bind :80
server-template srv 10 app:8080 check
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
Mas parece ver apenas algumas das réplicas:
$ docker compose up
...
app-3 | MyWebServer: You can connect to your server at http://localhost:8080/
haproxy-1 | [NOTICE] 094/155107 (1) : New worker #1 (8) forked
app-4 | MyWebServer: You can connect to your server at http://localhost:8080/
app-2 | MyWebServer: You can connect to your server at http://localhost:8080/
app-5 | MyWebServer: You can connect to your server at http://localhost:8080/
app-9 | MyWebServer: You can connect to your server at http://localhost:8080/
app-7 | MyWebServer: You can connect to your server at http://localhost:8080/
app-6 | MyWebServer: You can connect to your server at http://localhost:8080/
app-1 | MyWebServer: You can connect to your server at http://localhost:8080/
app-10 | MyWebServer: You can connect to your server at http://localhost:8080/
app-8 | MyWebServer: You can connect to your server at http://localhost:8080/
app-3 | d3757cd065b4
app-3 | d3757cd065b4
app-3 | d3757cd065b4
app-4 | 226419df4354
app-4 | 226419df4354
app-4 | 226419df4354
...
Mais detalhes aqui .
o que estou perdendo?
Não tenho certeza se entendi o motivo, mas
depends_on
supostamente resolve o problema (haproxy
depende doapp
s). Meu palpite é quehaproxy
armazena em cache o queapp
é resolvido quando é iniciado. Se nem todos osapp
programas estiverem em execução naquele momento, ele armazena em cache apenas os IPs em execução.