Change Heap Size for Elastic Search


Change Heap Size for Elastic Search

The default installation of Elasticsearch is configured with a 1 GB heap. For just about every deployment, this number is usually too small. If you are using the default heap values, your cluster is probably configured incorrectly.

There are two ways to change the heap size in Elasticsearch. The easiest is to set an environment variable called ES_HEAP_SIZE. When the server process starts, it will read this environment variable and set the heap accordingly. As an example, you can set it via the command line as follows:

export ES_HEAP_SIZE=10g

Alternatively, you can pass in the heap size via JVM flags when starting the process, if that is easier for your setup:

ES_JAVA_OPTS="-Xms10g -Xmx10g" ./bin/elasticsearch 

Ensure that the min (Xms) and max (Xmx) sizes are the same to prevent the heap from resizing at runtime, a very costly process.

sudo vi /etc/elasticsearch/jvm.options

Generally, setting the ES_HEAP_SIZE environment variable is preferred over setting explicit -Xmx and -Xms values.

Source: https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html See also Setting JVM options. There are two ways to change the heap size in Elasticsearch. The easiest is to set an environment variable called ES_HEAP_SIZE.

Full disk space problems

  1. You could try to remove indexes
$ curl -XDELETE http://localhost:9200/PATTERN_OR_PATH

Replace PATTERN_OR_PATH with the pattern or index that you want to remove.

To remove all indexes:

$ curl -XDELETE http://localhost:9200/*
  1. Remove .hprof files

# got to cd /var/lib/elasticsearch/
$ cd cd /var/lib/elasticsearch/

# show all files

root@ip:/var/lib/elasticsearch# ls -lh
total 29138560
-rw------- 1 elasticsearch elasticsearch 1175937553 Mar  7 12:01 java_pid19447.hprof
-rw------- 1 elasticsearch elasticsearch 1459518773 Apr  1 07:10 java_pid20206.hprof
drwxr-sr-x 3 elasticsearch elasticsearch       4096 Oct 29  2019 nodes


# remove unwanted files

$ rm java_pid19447.hprof

Newsletter


Related Posts

A Week in the Life of an Invoice Wrangler: Navigating Ridesharing and Food Delivery Chaos

As an app founder in the ridesharing and food delivery industry, I found myself knee-deep in invoice reports from companies like Bolt, Uber, Glovo, and Bolt Food

Free HTML templates list for Startups

Free HTML templates list for startup. A complete list with free resources to build your next startup's website and gain the traction to the sky.

Deal with client requests in SaaS

How to deal with client requests in Saas which are seeing only their interests, not the product interest.

The first client of LoyalXpert is not answering anymore

Trying to implement LoyalXpert app, I lost my first customer, he's not answering anymore

Experiments with Tiktok Ads

Recently tried out TikTok ads for the first time and here are some of my learnings and challenges

People don’t care about you, until they know you care about them.

People don’t care about you, until they know you care about them. The same happens in business, you need to take care of your clients.

The One Word That Can Ruin Your SaaS Business Anyone

As a SaaS founder, you probably know how important it is to have a clear and specific target market for your product.

How I got my digital certificate connected it with ANAF

How I got my digital certificate from certSIGN and connected it with ANAF

The Ultimate List of Company Directories to Boost Your Networking

Discover a wide range of company directories to boost your business's visibility and connect with potential clients.

Discover the Best Free AI Art Tools for Your Next Masterpiece

Explore a curated collection of the finest free AI art tools, designed to help you bring your artistic vision to life.