Docker Community Forums

Share and learn in the Docker community.

How to scale dockerized flask app


#1

We have a dockerized flask app which takes an image, process it and sends back the results in JSON format. The input image is sent using a POST request to the docker container.

Let’s say we have huge traffic incoming then how can we scale this app. I’m new to docker, any advice would be of great help.


#2

If your application is stateless (as in the state just exists in a request/response cycle), you can run your image as swarm service with one of more replicas. You can either set them during creation, or later using commands. Though, they are not dynamic in any way. Thus, if you want to scale automaticly, you will need an external monitoring that is able to execute commands if treshholds are violoated. If you already know the timeframe, you could easily create cronjobs that scale up and down depending on your needs.

Usage: docker service scale SERVICE=REPLICAS [SERVICE=REPLICAS…]

First you need need to create your service (docker service create …) from the cli or by deploying a stack (docker stack deploy …).