Skip to content

Instantly share code, notes, and snippets.

@xorpaul
Last active August 11, 2022 12:42
Show Gist options
  • Save xorpaul/c96fdc9d0c1599253bf06f243a60ca60 to your computer and use it in GitHub Desktop.
Save xorpaul/c96fdc9d0c1599253bf06f243a60ca60 to your computer and use it in GitHub Desktop.
Elasticsearch tuning

increase refresh_interval from the default 1s if you don't need it instantaneously available

curl -X PUT  -H 'Content-Type: application/json' -d '{ "index": { "refresh_interval": "30s" } }' http://$(hostname -f):9200/_settings

Whether or not to fsync and commit the translog after every index, delete, update, or bulk request. Increased risk of data loss if elasticsearch crashes

curl -X PUT  -H 'Content-Type: application/json' -d '{ "index": { "translog.durability": "async" } }' http://$(hostname -f):9200/_settings

set number_of_shards according to how many writes cluster nodes you have/want

curl -X PUT "localhost:9200/_template/template_1?pretty" -H 'Content-Type: application/json' -d' { "index_patterns" : ["*"], "settings" : { "number_of_shards" : 4 } } '

increase indices.memory.index_buffer_size from the default 10% of total heap for write intensive elasticsearch clusters

echo "indices.memory.index_buffer_size: 25%" >> /etc/elasticsearch/elasticsearch.yml

temporarily disable replicas for initials ES cluster setup

curl -XPUT -H 'Content-Type: application/json' http://127.0.0.1:9200/_settings -d ' { "index" : { "number_of_replicas" : 0 } } '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment