# Autoscaling based on CPU

**URL:** <https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707>\
**Category:** Elasticsearch\
**Created:** [October 29, 2024, 9:04am UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707 "2024-10-29T09:04:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [October 29, 2024, 9:04am UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/1 "2024-10-29T09:04:41Z")

</div>

I see there is no direct way to autoscale based on CPU and autoscaling is available only for ML and storage.

Is there an alternative way to scale out or scale up my cluster based on cpu? Say, CPU utilisation goes from 50 percent to 80 percent, I want the number of nodes to be increased from 5 to 7.

How is everyone accomplishing autoscaling instead of sizing for peak traffic?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2024, 9:16am UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/2 "2024-10-29T09:16:44Z")

</div>

Is this related to Elastic Cloud?

In my eperience there are relatively few Elasticsearch use cases that are limited by CPU. The examples I can think of is where you have a small data set completely cached in memory and very high query rates and possibly also vector search use cases.

The tricky part with scaling out based on CPU load is that you generally add load to the cluster when you scale out, which may happen exactly when the load is the highest, initially causing additional problems rather than helping.

It might help if you could provide more detail around your use case.

---

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [October 29, 2024, 9:51am UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/3 "2024-10-29T09:51:46Z")

</div>

Say, I have a food delivery app that receives n requests every hour but at at 7 PM when folks get off of work or Friday night 10 PM, the number of requests increase to 10\*n. It doesnt make sense to scale for peak if I know the requests are going to be that high only for an hour or two everyday.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2024, 10:05am UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/4 "2024-10-29T10:05:32Z")

</div>

In a scenario like that where peak hours are known I would scale up before the peak using a script and then back down after. That allows you to add the load related to the scaling at a time where it does not affect search latencies.

---

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [October 29, 2024, 11:34am UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/5 "2024-10-29T11:34:36Z")

</div>

Is there a sample script available?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2024, 11:45am UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/6 "2024-10-29T11:45:51Z")

</div>

No, not that I know of.

---

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [October 29, 2024, 4:56pm UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/7 "2024-10-29T16:56:10Z")

</div>

But this is a valid ask right? There should be an elastic approved script to use so customers can scale out automatically

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2024, 5:08pm UTC](https://discuss.elastic.co/t/autoscaling-based-on-cpu/369707/8 "2024-10-29T17:08:40Z")

</div>

> [@searchwithme](#):
>
> But this is a valid ask right? There should be an elastic approved script to use so customers can scale out automatically

I do not see how that would be possible as everyone likely have different requirements. As far as I know there are relatively few who autoscale Elasticsearch due to the reasons I mentioned earlier. If you want to scale an Elastic Cloud deployment at specific times Elastic Cloud [has an API which allow you to manipulate environments](https://www.elastic.co/guide/en/cloud/current/ec-restful-api.html) so that would likely be a good point to start.
