How many Docker containers should I run How many Docker containers should I run docker docker

How many Docker containers should I run


There are pros and cons for both cases.

If you are running 1 Pod of your app with lots of resources, you have 1 point of failure. If your pod dies (and at one point it will die); for example during a rolling update, you are going to have a small downtime.

If you have many Pods running a replica of your app, take into consideration that these are containers, so there is a base image and dependencies, besides your app. So every replica is one more base image plus dependencies you are deploying, therefor that's more resource you are spending on your app.

Usually, it is better to have more then one replica, but you shouldn't go crazy with it. Make a research of what's consuming your app, set the right resource requests. Set up a HPA for better resiliency and better management of the cluster resources.


How do I know if I need 1, 5, 10, 100 or 1000 instances of container?

Its totally depend on your use-case or system load. If you have a hundred of the users then 1 container might be enough.

But one can not simply answer this question without proper load test.

So I can have either one container with lots of resources or 10 containers with fewer resources. What's better and why?

One container with fewer resources is recommend with many cloud provider as AWS recommend to have 300 to 500 MB memory so you can run multiple containers on one instance.

define hard and/or soft memory limits in MiB for your container. Hard and soft limits correspond to the memory and memoryReservation parameters, respectively, in task definitions. ECS recommends 300-500 MiB as a starting point for web applications.


In a production environment, you’d want to set up some sort of monitoring system to report error rates and request latency. If requests are starting to get unacceptably slow, you’d stand up more replicas, and more hardware. It’s not usually useful to run more replicas than your hardware supports or than your current load justifies.

The flip side of this is that running 2 replicas is much harder than running 1; running 3, or 10, isn’t much harder than running 2. So I’d suggest:

  • If running just 1 replica works for your traffic load and availability needs, just run 1 replica.
  • If you’re running in an environment like Kubernetes that provides load balancing and zero-downtime upgrades as part of the environment, run 2 or 3 replicas; don’t go overboard, but you gain some resiliency if 1 copy crashes if there’s another one running to fail over to.
  • Run the fewest number of replicas required to meet your response time requirements.