Test Elasticsearch Query Performance
I am using two tool to benchmark query performance of an Elasticsearch server. Initially I faced problem to test elasticsearch query performance for large elasticsearch query as it’s very hard to put large query in command line. Then I found these two tool, having support to pass json as a POST parameter.
Tools are :
1) Siege
2) AB(Apache Bench)
1) Siege:
To setup siege in your linux system please follow the step by step guideline provide in this post. Write down you elasticsearch query in url.txt in POST parameter like below:
$ http://localhost:9200/index/type/_search POST {"query":{"filtered":{"query":{"match_all":{}},"filter":{"bool":{"must":[{"term":{"post_author":"1007"}},{"term":{"country":"USA"}},{"range":{"post_id":{"from":10,"to":20}}},{}]}}}}}
You can pass POST parameter in command line argument as well. I will prefer this way when my elasticsearch query is small.
$ siege -u 'http://localhost:9200/index/type/_search POST {"query":{"filtered":{"query":{"match_all":{}},"filter":{"bool":{"must":[{"term":{"post_author":"1007"}}]}}}}}' -r2 -c2 -v
2) AB(Apache Bench):
Please follow the instruction which is given in my earlier post to setup AB tool.
To test Elasticsearch query in AB tool write down you query in a json file and pass that json file in -p post parameter. Pass content-type parameter in ab command in case you are passing elasticsearch query in some other format file( may be query.txt).
ab -n 10 -c 10 -p /path/to/json/query.json http://localhost:9200/index/type/_search/
or
ab -n 10 -c 10 -p /path/to/json/query.json -T "application/json; charset=utf-8" http://localhost:9200/index/type/_search/
Hope this will help you. In case of any query feel free to email me at info@techieroop.com.