# Scheduling help

**URL:** <https://forums.suse.com/t/scheduling-help/1894>\
**Category:** Rancher 1.x\
**Created:** [February 29, 2016, 2:25pm UTC](https://forums.suse.com/t/scheduling-help/1894 "2016-02-29T14:25:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![olds463](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/olds463/32/7318_2.png) [@olds463](https://forums.suse.com/u/olds463)\
**Post date:** [February 29, 2016, 2:25pm UTC](https://forums.suse.com/t/scheduling-help/1894/1 "2016-02-29T14:25:59Z")

</div>

I need some help with scheduling rules. I’m trying to get the scheduler to balance 2 instances per host, however so far no love.

Any experts that can chime in?

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [February 29, 2016, 8:05pm UTC](https://forums.suse.com/t/scheduling-help/1894/2 "2016-02-29T20:05:40Z")

</div>

This doesn’t exist today. I just edited the title in Github to make it slightly more generic.

> <https://github.com/rancher/rancher/issues/2247>

---

<div class="post-metadata">

**Author:** ![demarant](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/demarant/32/497_2.png) [@demarant](https://forums.suse.com/u/demarant)\
**Post date:** [February 29, 2016, 11:34pm UTC](https://forums.suse.com/t/scheduling-help/1894/3 "2016-02-29T23:34:37Z")

</div>

We also have same need in order to have a proper HA setup of our applications and we haven’t been able to achieve this nicely with current scheduling rules.

## Temporary solution

Below I show you how to achieve the “2 instances per host” by creating two identical services that can be scaled independently:

For example, imagine we have a stack “mystack”:

**docker-compose.yml** :

```
myapp1:
  image: myorg/myapp:mytag
  label:
    io.rancher.scheduler.affinity:container_label_soft_ne: io.rancher.stack_service.name=mystack/myapp1
    io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=mystack/myapp2

myapp2:
  image: myorg/myapp:mytag
  label:
    io.rancher.scheduler.affinity:container_label_soft_ne: io.rancher.stack_service.name=mystack/myapp2
    io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=mystack/myapp1

```

**rancher-compose.yml** :

```
myapp1:
  scale: 1
  health_check:
    port: 3000
    interval: 2000
    unhealthy_threshold: 3
    response_timeout: 2000
    healthy_threshold: 2

myapp2:
  scale: 1
  health_check:
    port: 3000
    interval: 2000
    unhealthy_threshold: 3
    response_timeout: 2000
    healthy_threshold: 2

```

The above will give you the idea. It assures that we have at least 2 containers of the same application (i use same image on app1 and app2) are not running on the same host. Being separated services I can scale them independently and having soft anti-affinity rules will still allow them to be on same host if the other are “too packed”. Changing the scale to 2 will make you do at least 2 containers per host, or at least 3 per host and so on.

It is a kind of dirty-trick since rancher scheduling does not provide this functionality yet.

## Related issues

There are two other github issues that are very much related [https://github.com/rancher/rancher/issues/2590](https://github.com/rancher/rancher/issues/2590) and this [https://github.com/rancher/rancher/issues/2558](https://github.com/rancher/rancher/issues/2558)

Unfortunately from the labels on github it seems that Rancher is not prioritizing this use cases, they are not part of near release … I really hope they prioritize these issues for letting us do better HA-deployments.
