# Scale by Environment

**URL:** <https://forums.suse.com/t/scale-by-environment/5388>\
**Category:** Rancher 1.x\
**Created:** [February 1, 2017, 10:13pm UTC](https://forums.suse.com/t/scale-by-environment/5388 "2017-02-01T22:13:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis\_LaFreniere](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/dennis_lafreniere/32/2111_2.png) [@Dennis\_LaFreniere](https://forums.suse.com/u/Dennis_LaFreniere)\
**Post date:** [February 1, 2017, 10:13pm UTC](https://forums.suse.com/t/scale-by-environment/5388/1 "2017-02-01T22:13:13Z")

</div>

We have several Rancher “environments” in Dev, Prod, and DR. Apps in these environments may need more or less scale based on their load, which varies by environment. Is there a way to specify a scale for apps by environment? So let’s say 1 in Dev, 2 in DR, and 3 in Prod? Is this something we can add to the rancher-compose or docker-compose?

---

<div class="post-metadata">

**Author:** ![zicklag](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/zicklag/32/2095_2.png) [@zicklag](https://forums.suse.com/u/zicklag)\
**Post date:** [February 4, 2017, 3:40am UTC](https://forums.suse.com/t/scale-by-environment/5388/2 "2017-02-04T03:40:04Z")

</div>

@Dennis_LaFreniere, you can set the scale for an application inside of the rancher-compose.yml, but, as far as I know, there is no way to put a specific scale per environment, without having different yaml’s for different environments.

Here is an example for setting the scale of `my-container` in a yaml.

**rancher-compose.yml**

```
version: '2'
services: 
    my-container:
        scale: 1
```

---

<div class="post-metadata">

**Author:** ![Dennis\_LaFreniere](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/dennis_lafreniere/32/2111_2.png) [@Dennis\_LaFreniere](https://forums.suse.com/u/Dennis_LaFreniere)\
**Post date:** [May 8, 2017, 5:06pm UTC](https://forums.suse.com/t/scale-by-environment/5388/3 "2017-05-08T17:06:22Z")

</div>

Hmm. I’m used to Puppet where we can specify a configuration by instance. It would be nice if we could add a question to the rancher-compose for scale that is required, but the scale is coded into the rancher-compose so that won’t work. Is there an external service that would be able to monitor the scale of apps and adjust them accordingly? I saw a reference to Prometheus here: [https://docs.rancher.com/rancher/v1.5/en/cattle/webhook-service/#scaling-a-service](https://docs.rancher.com/rancher/v1.5/en/cattle/webhook-service/#scaling-a-service)

---

<div class="post-metadata">

**Author:** ![zicklag](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/zicklag/32/2095_2.png) [@zicklag](https://forums.suse.com/u/zicklag)\
**Post date:** [May 25, 2017, 8:13pm UTC](https://forums.suse.com/t/scale-by-environment/5388/4 "2017-05-25T20:13:04Z")

</div>

If you set up a [private Catalog](https://docs.rancher.com/rancher/v1.6/en/catalog/private-catalog/#creating-private-catalogs) and add a Template for your application you can [put in a question for the scale in the template](https://docs.rancher.com/rancher/v1.6/en/catalog/private-catalog/#questions-in-the-rancher-composeyml). Then you use the `${variable_name}` type syntax in the rancher-compose file and it will evaluate to the answer of the question. Then you just have to spin up the template in your different environments with a different value for scale.

---

<div class="post-metadata">

**Author:** ![Dennis\_LaFreniere](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/dennis_lafreniere/32/2111_2.png) [@Dennis\_LaFreniere](https://forums.suse.com/u/Dennis_LaFreniere)\
**Post date:** [July 6, 2017, 9:47pm UTC](https://forums.suse.com/t/scale-by-environment/5388/5 "2017-07-06T21:47:59Z")

</div>

I’ve used the configuration you suggested. But this only works when I  
initially spin up the app. When I upgrade the stack using the “upgrade  
available” button, the questions show up for scale but the numbers used  
have no effect on the scale during upgrade, only when the app is initially  
spun up. This is a problem.

---

<div class="post-metadata">

**Author:** ![zicklag](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/zicklag/32/2095_2.png) [@zicklag](https://forums.suse.com/u/zicklag)\
**Post date:** [July 6, 2017, 11:28pm UTC](https://forums.suse.com/t/scale-by-environment/5388/6 "2017-07-06T23:28:57Z")

</div>

That’s unfortunate. It must be that Rancher figures that it shouldn’t override the scale of a service when upgrading just in case something else, like a webhook, changed it on purpose. I can’t think of any solution other than setting the scale manually, which is lame. ☹
