Colleagues, hello everyone!
I have a large web application on a microservice architecture. The entire infrastructure works in Docker Swarm.
All microservices are worked to Python and run on a uvicorn server.
Uwsgi has its own workers which can be scaled.
In Docker Swarm, you can also scale the application by increasing the replicas of the service.
The question is how to scale the service better:
1) 1 docker swarm replicator - 100 (any other number) uvicorn workers
2) 100 (any other number) replicas of docker swarm - 1 uvicorn worker
3) 10 replicas of docker swarm - 10 uvicorn workers
It depends on your application and your requirements/capabilities, so it's hard to say exact answer. The Docker replicas and Uvicorn workers are on different levels in the micro-service architecture.
The Docker handles the traffic (load) between the replicas and inside the replicas (containers) the Uvicorn handles the processes/requests between the workers.
Replica and Unicorn architecture (very high level):
10 replicas * 10 Unicorn = 100 parallel request
, so it's a quite good number for parallel request processing. This approach could be suitable for applications that benefit from a mix of parallel processing and independent instances.