Elasticsearch Memory consumption is 11 gb, but docker shows 5gb

Viewed 398

i am running two services in docker - one for elasticsearch and one for my app I have set heap size for elasticsearch as 2gb when i check index memory using this command -

localhost:9200/_cat/indices

i get this data

yellow open forus-elastic 3AAKxCQfQ9yzdSYz1r7DNw 1 1 1000015 0    11gb    11gb

but when i check my docker memory consumption before and after docker-compose, it shows 5-6 gb consumption, but elasticsearch index consumption is 11 gb, How can this be understood, which data is proper

1 Answers

Simple answer: Both is correct.

I strongly assume that you are using the default index settings regarding sharding. Since version 7 an index is made up of 1 primary shard and 1 replica shard by default.

The cat API shows you the size of both the primary and replica shard. The replica shard is a copy of the primary shard. This is why Elasticsearch shows you double the amount of potential disk memory usage compared to the info docker shows you.

Your index is in yellow state. This means that replica shards could not get allocated. Elasticsearch will never allocate both the primary and the replica shard on the same node due to high availability reasons. So the 5-6 GB of the replica shard does not get into account because the shard is not allocated to your single node. Only the primary shard is.

I hope I could help you.

Related