Unsure on how to Orchestrate docker containers

3/30/2020

Im new to docker and am wanting to accomplish something but I am unsure on how to Orchestrate my docker containers to do this.

What I want to do:

I have an API that in simple does a calculation from a requested file. It loads the file (around 80mb) from disk to memory then keep it in memory for 2 hours (caching).

Im wanting to have an architecture where for example when the container gets overwhelmed with requests a new one fires up, and when the original container frees its memory and the requests slow down then the container shuts down.

Is Memory and CPU Container Orchestration possible?

Thank You,

/Jeremy

-- Jeremy Ruffell
architecture
docker
docker-swarm
kubernetes

2 Answers

4/7/2020

For sure, container orchestration system is what you want to be able efficiently manage your docker containers.

You can find current complete list of solutions for production environment in this spreadsheet

Tools, like kubernetes will give you reach set of benefits eg

  • Provisioning and deployment of containers
  • Redundancy and availability of containers
  • Scaling up or removing containers to spread application load evenly across host infrastructure
  • Allocation of resources between containers
  • Load balancing of service discovery between containers
  • Health monitoring of containers and hosts

In Kubernetes there is a Horizontal Pod Autoscaler, that

automatically scales the number of pods in a replication controller, deployment, replica set or stateful set based on observed CPU utilization (or, with custom metrics support, on some other application-provided metrics). Note that Horizontal Pod Autoscaling does not apply to objects that can’t be scaled, for example, DaemonSets.

As for beginning I would recommend you start with minikube.

More advanced ways are setup manually cluster using kubeadm either look into the cloud providers

Please be aware that you will not have option to modify cloud based control plane. More info in my related answer

-- VKR
Source: StackOverflow

3/31/2020

Docker itself is not dedicated to the orchestration multiple containers. You need to use some container orchestration environment. The most popular are Kubernetes, Docker Swarm, and Apache Mesos. Or if you want to run in the Cloud, then some vendor-specific, like AWS ECS.

Here's a good list of container clustering toolkit.

In all these environments it's possible to configure what you described. If you're completely new to the topic, then I recommend installing Docker-for-Desktop which comes with built-in Kubernetes and play with that in your local.

-- Rafał Leszko
Source: StackOverflow