0

We have a 6 node docker swarm running and we often see bad scheduling (clean inbalance) happening.

I've researched this subject, and it seems docker swarm as standalone used to allow a way to choose different strategies to its scheduler, but since swarm was integrated into docker it only supports the spread strategy. In our case, since we are very memory intensive, we would benefit from only considering memory and not CPU/#containers as a metric.

How could we achieve this?

1

The scheduler itself is not swappable. However, you can set memory constraints and reservations on containers in your service:

version: '3'
services:
  redis:
    image: redis:alpine
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 50M
        reservations:
          cpus: '0.25'
          memory: 20M

The constraint will kill the container if it exceeds the limit even if the host has more memory available. The reservation will ensure that amount of memory on the host is available for the container.

| improve this answer | |
  • Although your comment is insightful, it doesn't directly answer the issue. Because it won't help/change how docker will distribute work. If you have 4 nodes, there's still the chance docker will choose to place 100% of the containers in the same node, which happens often if we scale them up too fast. – fabiopedrosa May 15 '18 at 14:55
  • The direct answer is that the scheduler itself is not swappable. If you need your own custom built scheduler, then kubernetes may be a better solution. – BMitch May 15 '18 at 15:02
  • thanks, that was my understanding as well, but hoped to be wrong. – fabiopedrosa May 15 '18 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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