# Higher CPU vs Higher Memory. Which helps in what cases?

**URL:** <https://discuss.elastic.co/t/higher-cpu-vs-higher-memory-which-helps-in-what-cases/272798>\
**Category:** Elasticsearch\
**Created:** [May 12, 2021, 10:52am UTC](https://discuss.elastic.co/t/higher-cpu-vs-higher-memory-which-helps-in-what-cases/272798 "2021-05-12T10:52:54Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![Aurel\_Drejta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aurel_drejta/32/59925_2.png) [@Aurel\_Drejta](https://discuss.elastic.co/u/Aurel_Drejta)\
**Post date:** [June 16, 2021, 8:39am UTC](https://discuss.elastic.co/t/higher-cpu-vs-higher-memory-which-helps-in-what-cases/272798/23 "2021-06-16T08:39:24Z")

</div>

Here is another useful tip when facing these kinds of problems.

For each shard that you have in an index elasticsearch spawns a thread to search in that shard.  
That means that if i have a 4 VCPUs in a node i can only search 4 shards in parallel.  
See [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/size-your-shards.html#single-thread-per-shard)

So if you have a 5 primary shard monster index with much more VCPUs (16-32) you aren't actually using those VCPUs since no more than 5 threads will be spawned to search the shards of that index.

Increasing the number of primary shards will better utilize those VCPUs since for each shard elasticsearch will spawn a thread and will be searched in parallel.

So that is how more VCPUs help.

How faster CPU helps is that the searches in those shards will be faster.

So if a 2.0GHz CPU searches for 800ms in a shard a 3.0GHz CPU will be much faster at searching in that shard (~ 200-300 ms).

How more RAM seems to help is that with every new index and every new shards that is created, elasticsearch takes some RAM space for every new index and new shard (how much space they take i don't really know).

This [guide](https://www.elastic.co/guide/en/elasticsearch/reference/current/size-your-shards.html) on shard size helped me to better manage CPU and RAM requirenments.

---

_[View the full topic](https://discuss.elastic.co/t/higher-cpu-vs-higher-memory-which-helps-in-what-cases/272798)._
