# Performance difference between Java High Level REST Client vs Low Level REST Client

**URL:** <https://discuss.elastic.co/t/performance-difference-between-java-high-level-rest-client-vs-low-level-rest-client/125775>\
**Category:** Elasticsearch\
**Created:** [March 27, 2018, 2:24pm UTC](https://discuss.elastic.co/t/performance-difference-between-java-high-level-rest-client-vs-low-level-rest-client/125775 "2018-03-27T14:24:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhmtnlr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhmtnlr/32/45665_2.png) [@mhmtnlr](https://discuss.elastic.co/u/mhmtnlr)\
**Post date:** [March 27, 2018, 2:24pm UTC](https://discuss.elastic.co/t/performance-difference-between-java-high-level-rest-client-vs-low-level-rest-client/125775/1 "2018-03-27T14:24:59Z")

</div>

Hello,  
I was doing a performance test on my system. In my test, Java High-Level Client makes ~800 RPS for a simple get request. When I change the implementation and use Java Low-Level Client, it reaches to ~1750 RPS. When I directly send the requests to ES for same get query I easy reach to ~8k RPS.  
I am using 6.0.1

I wonder what I am doing wrong? Or is there performance difference on java client?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 27, 2018, 2:40pm UTC](https://discuss.elastic.co/t/performance-difference-between-java-high-level-rest-client-vs-low-level-rest-client/125775/2 "2018-03-27T14:40:54Z")

</div>

Let's see what @danielmitterdorfer is thinking about this. Please be patient on this as I know that Daniel is not available in the next days.

BTW could you upgrade to latest 6.2 so we are sure that you are using all the recent versions for both server and client?

---

<div class="post-metadata">

**Author:** ![mhmtnlr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhmtnlr/32/45665_2.png) [@mhmtnlr](https://discuss.elastic.co/u/mhmtnlr)\
**Post date:** [March 27, 2018, 6:37pm UTC](https://discuss.elastic.co/t/performance-difference-between-java-high-level-rest-client-vs-low-level-rest-client/125775/3 "2018-03-27T18:37:00Z")

</div>

I upgraded to latest version and repeat the tests. I got the same results ☹

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [April 6, 2018, 12:46pm UTC](https://discuss.elastic.co/t/performance-difference-between-java-high-level-rest-client-vs-low-level-rest-client/125775/4 "2018-04-06T12:46:56Z")

</div>

Quite a while ago I have [benchmarked the low-level REST client against the transport client](https://www.elastic.co/blog/benchmarking-rest-client-transport-client) for a blog post. The [benchmarking code](https://github.com/elastic/elasticsearch/tree/master/client/benchmark) is available in the Elasticsearch repo. You can checkout the blog post for the benchmarking methodology that I have used there and inspect the code of the benchmark.

As far as I understand you have benchmarked three scenarios:

- "Directly" sending requests to Elasticsearch: Not sure what this is, probably curl or just sending a raw string via a HTTP client library?
- Low-level client
- High-level client

W.r.t. to the use case: I am not so sure issuing a get request over and over is such a useful and realistic benchmark to begin with. If you need to retrieve a lot of documents by id, it would make sense to leverage batching and use the mget API instead.

It depends a bit how you setup your benchmark and measure but in general I'd expect that the high-level client is a bit slower because it needs to serialize and deserialize data? In your scenario it is quite a bit slower though. I suggest that you attach a Java profiler to the client application so you can see where the hot spots are (serializing data, sending them, establishing a connection, etc. etc). That might reveal further steps that you need to take.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 4, 2018, 12:47pm UTC](https://discuss.elastic.co/t/performance-difference-between-java-high-level-rest-client-vs-low-level-rest-client/125775/5 "2018-05-04T12:47:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
