so I have this nice rest API implemented in Flask running in docker and I am thinking about scaling. This is how I progressed:
CMD ["flask", "run", "--host=0.0.0.0"]
and
docker run -d -p 5000:5000 pyrest-alpine
works fine
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "pyrest:app"]
and
docker run -d -p 5000:5000 pyrest-alpine
This also works fine, Gunicorn provided some scaling via prefork worker model in a single container now I want to scale via replication of Docker swarm with healthchecks where both
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "pyrest:app"]
and
CMD ["flask", "run", "--host=0.0.0.0"]
work just fine with
docker service create --name pyrest-swarm --replicas 2 -p 5000:5000 --health-interval=2s --health-timeout=10s --health-retries=3--health-cmd "curl 0.0.0.0:5000/status || exit 1" pyrest-alpine
My question is Do I still use gunicorn when using docker swarm replication?