<p>We have big problems with setting limits/requests in our web django servers/python processors/celery workers. Our current strategy is to look at the usage of the graphs in the last 7 days:</p>

<p>1) get raw average excluding peak</p>

<p>2) add 30% buffer</p>

<p>3) set limits 2 time requests</p>

<p>It works more or less, but then service's code is changed and limits which were set before are not valid anymore. What are the other strategies?</p>

<p>How would you set up limits/requests for those graphs:</p>

<p>1) Processors:</p>

<p><a href="https://i.stack.imgur.com/si4CG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/si4CG.png" alt="enter image description here"></a></p>

<p>2) Celery-beat</p>

<p><a href="https://i.stack.imgur.com/ny7BE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ny7BE.png" alt="enter image description here"></a></p>

<p>3) Django (artifacts probably connected somehow to rollouts)</p>

<p><a href="https://i.stack.imgur.com/KDmmB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KDmmB.png" alt="enter image description here"></a></p>

<p>I would suggest you to start with the average CPU and memory value that the application takes and then enable <strong>auto scaling</strong>. Kunernetes has multiple kinds of autoscaling.</p>

<ul>
<li>Horizontal pod autoscaler</li>
<li>Vertical pod autoscaler</li>
</ul>

<p><a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">Horizontal pod autoscaling</a> is commonly used these days. HPA will automatically create new pods if the pods CPU or memory exceeds the percentage or volume of CPU or memory set as threshold.</p>

<p>Monitor the new releases before deployment and see why exactly the new release needs more memory. Troubleshoot and try to reduce the resource consumption limit. If that is not update the resource request with new CPU and memory value.</p>
