# Containers distribution via Cattle

**URL:** <https://forums.suse.com/t/containers-distribution-via-cattle/5129>\
**Category:** General\
**Created:** [January 9, 2017, 11:07am UTC](https://forums.suse.com/t/containers-distribution-via-cattle/5129 "2017-01-09T11:07:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cabrinoob](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/cabrinoob/32/1343_2.png) [@cabrinoob](https://forums.suse.com/u/cabrinoob)\
**Post date:** [January 9, 2017, 11:07am UTC](https://forums.suse.com/t/containers-distribution-via-cattle/5129/1 "2017-01-09T11:07:45Z")

</div>

Hello,  
I’am using rancher 1.1.4 and I’d like to know if there is a way to change the way cattle distributes the containers on different hosts.

Today I have 4 hosts (A,B,C and D) and when I scale up a logstash (or whatever) container from 2 to 8 instances, I ended up with :  
A =\> 1 instance  
B =\> 1 instance  
C =\> 2 instances  
D =\> 4 instances

I expected to have something much more like :

A =\> 2 instances  
B =\> 2 instances  
C =\> 2 instances  
D =\> 2 instances

When using swarm I can choose between 3 strategies : binpack, spread or round robin. Does something similar exists in Cattle?

Thank you

---

<div class="post-metadata">

**Author:** ![stieler-it](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/stieler-it/32/2204_2.png) [@stieler-it](https://forums.suse.com/u/stieler-it)\
**Post date:** [February 28, 2017, 11:36pm UTC](https://forums.suse.com/t/containers-distribution-via-cattle/5129/2 "2017-02-28T23:36:29Z")

</div>

We had the same problem today. An equal distribution is critical for our infrastructure, so I scaled down and up until this state was reached. Strange is that it “just worked” the last time I setup the environment.

---

<div class="post-metadata">

**Author:** ![cabrinoob](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/cabrinoob/32/1343_2.png) [@cabrinoob](https://forums.suse.com/u/cabrinoob)\
**Post date:** [March 1, 2017, 7:26am UTC](https://forums.suse.com/t/containers-distribution-via-cattle/5129/3 "2017-03-01T07:26:42Z")

</div>

I think I’ve found an answer to this phenomenon : Cattle does not distribute containers equaly across the stack, but across hosts.

Suppose you have 2 hosts (A and B). You also have one stack called firstStack with 3 containers on hosts “A”:

`A => (firstStack)( [x] [x] [x] ) B => (firstStack)( )`

Now, suppose that you create a new stack called “secondStack” and you start deploying one container inside, then you scale up to 3 instances. You will have something like this :

`A => (firstStack)( [x] [x] [x] ) - (secondStack)( ) B => (firstStack)( ) - (secondStack)( [x] [x] [x] )`

Because Cattle considers all containers across hosts, it begins to pack them on the host B because A already had 3 containers.

Then, if you continue to scale up to 6, I think you may have something like this :

`A => (firstStack)( [x] [x] [x] ) - (secondStack)( [x] [x]) B => (firstStack)( ) - (secondStack)( [x] [x] [x] [x] )`

It’s true that if you focuse on your secondStack, you will see a disorder in the distribution of its containers (4 on B and 2 on A), but if you consider firstStack AND secondStack, this distribution seems to be more balanced (5 on A, 4 on B).
