<p>If you use a hpa to increase the deployment from zero to e.g. 3 replicas, you can set the scaling <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#scaling-policies" rel="nofollow noreferrer">behaviour</a> to limit it to say one new pod per 60 seconds. However, this won’t affect how quickly pods or containers are restarted if they crash at the same time.</p>
<p>Would definitely consider implementing some form of semaphore inside your image, to wrap the problematic process.</p>

CC BY-SA 4.0
2022-12-25T15:09:31.997Z
2022-12-25T18:57:22.747Z
2022-12-25T18:57:22.747Z
benjimin
<p>I maintain an application that has occasional problems caused by races during start up but need multiple instances running. Is it possible to limit the number of pods kubernettes brings up at the same time?</p>
<p>e.g. if it's configured to have 3 replicas and 2 of them are down, can I make sure it doesn't start two pods at the same time and instead wait for liveliness check to pass on the first new pod before starting the second one?</p>

CC BY-SA 4.0
2022-12-21T16:21:02.310Z
I guess the best bet would be using an init-container checking the state of the deployment. But the best case would be to fix the application itself.
Tensibai
<kubernetes>
Limit the number of pods bought up at the same time in Kubernetes
user17492388
# Limit the number of pods bought up at the same time in Kubernetes

(Asked by: username_0 on 2022-12-21)

I maintain an application that has occasional problems caused by races during start up but need multiple instances running. Is it possible to limit the number of pods kubernettes brings up at the same time?

e.g. if it's configured to have 3 replicas and 2 of them are down, can I make sure it doesn't start two pods at the same time and instead wait for liveliness check to pass on the first new pod before starting the second one?

**Tags:** kubernetes

> **Comments:**
> **username_1**: I guess the best bet would be using an init-container checking the state of the deployment. But the best case would be to fix the application itself.  

---

## 1 answers

### Answer by username_2 on 2022-12-25. Score: 0

If you use a hpa to increase the deployment from zero to e.g. 3 replicas, you can set the scaling [behaviour](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#scaling-policies) to limit it to say one new pod per 60 seconds. However, this won’t affect how quickly pods or containers are restarted if they crash at the same time.

Would definitely consider implementing some form of semaphore inside your image, to wrap the problematic process.


---

