0

I've been reasearching docker swarms and found out that a swarm is a collection of nodes, nodes are computers that run services, services are schedulers of tasks, and tasks are running containers. Services are made out of a single container image and can be made out of multiple redundant tasks.

My question is: if tasks are instances of container images, how is memory and storage shared between them, assuming your service is running a stateful application like a database (storage) or a website backend (memory)?

  • Are the resource requirements multiplied and sinchronized regularly or in real-time? By that logic shouldn't there be a "master task"?
  • If not, then stateful applications should have at maximum 1 task replica per service, and each redundancy unit should be a new actively mantained service (like databases, for instance)?

The core of my question is that I assume that services are general-purpose, so most types of applications could benefit from this task replication thing. Otherwise, isn't this core feature only suitable for stateless applications like rest apis? I imagine core features of general-purpose tools to also be general-purpose.

1 Answer 1

1

A container is nothing more than a process that has been partitioned from the host system and other processes using some linux process isolation technology.

Docker - even swarm's - role in this is to setup the parameters for this isolation and then hand the execution over to the OS to handle - this is partially what makes containers so lightweight - docker literally adds nothing to the execution of a containerised app.

This does mean, out the box, swarm is very good at orchestrating stateless containers. And anything that's stateful needs to have native support for being run in some kind of clustered/multi node configuration because docker swarm is not implementing anything magical. If you want to run a clustered Postgres db for example, you figure out how to run 3 Postgres instances without docker, and then write a swarm stack that spins up 3 replicas configured that way, solving problems like how each instance is going to persist its data: Swarm assumes tasks are stateless and will assume it can re-start any Postgres instance on any node, so its up to you to use cluster aware volumes, or use constrains to pin specific instances to specific nodes so they always use the same mounted data volumes etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.