Product Engineer, CTO & a Beer Enthusiast
Experiments, thoughts and scripts documented for posterity.
Sep, 2014
Now that we have Elasticsearch installed and confirmed working, we can start looking into more advanced settings, more of tweaking, to improve Elasticsearch performance. For most use cases, following three area's of Elasticsearch configuration needs to be addressed:$ export ES_HEAP_SIZE=2048m
But providing the heap size is just not enough as the memory can be swapped out by the OS. To prevent this we need to lock the process address space assigned to Elasticsearch. This can be done by adding the following line to elasticsearch.yml file and restarting elasticsearch:
#elasticsearch.yml
bootstrap.mlockall: true
After starting Elasticsearch, you can see whether this setting was applied successfully by checking the value of mlockall in the output from this request:
$curl http://localhost:9200/_nodes/process?pretty
{
"nodes": {
"Oaa7jVWNSeyHlmhyYCr32g": {
"name": "Mister Fear",
"transport_address": "inet[/127.0.0.1:9300]",
"host": "ip-127-0-0-1",
"ip": "127.0.0.1",
"version": "1.3.2",
"build": "dee175d",
"http_address": "inet[/127.0.0.1:9200]",
"attributes": {
"master": "true"
},
"process": {
"refresh_interval_in_millis": 1000,
"id": 3599,
"max_file_descriptors": 100000,
"mlockall": false
}
}
}
}
But the mlockall is false. If you see that mlockall is false, then it means that the the mlockall request has failed. The most probable reason is that the user running Elasticsearch doesn't have permission to lock memory. This can be granted by running ulimit -l unlimited as root before starting Elasticsearch.
#elasticsearch.yml
#for search operation
threadpool.search.type: fixed
threadpool.search.size: 50
threadpool.search.queue_size: 200
#for bulk operations
threadpool.bulk.type: fixed
threadpool.bulk.size: 10
threadpool.bulk.queue_size: 100
#for indexing operations
threadpool.index.type: fixed
threadpool.index.size: 60
threadpool.index.queue_size: 1000
So if the use cases if primarily for searching i.e. more search operations than indexing operations, the threadpool for search can be increased and the threadpool for indexing can be much lower. Though queuing up thousands of messages is probably not a wise decision, so tweak responsibly. More information about threadpool size and configuration can be found at Elasticsearch Threadpool
#elasticsearch.yml
indices.memory.index_buffer_size: 30%
#above settings grants ES 30% of it's heap memory for index buffer purpose
More at
Indices Module
#elasticsearch.yml
index.store.type: mmapfs
More information regarding storage options can be found at
Elasticsearch Store