# Performance difference between REST and Java API

**URL:** <https://discuss.elastic.co/t/performance-difference-between-rest-and-java-api/21320>\
**Category:** Elasticsearch\
**Created:** [December 18, 2014, 6:48pm UTC](https://discuss.elastic.co/t/performance-difference-between-rest-and-java-api/21320 "2014-12-18T18:48:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marie\_Jacob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marie_jacob/32/1038_2.png) [@Marie\_Jacob](https://discuss.elastic.co/u/Marie_Jacob)\
**Post date:** [December 18, 2014, 6:48pm UTC](https://discuss.elastic.co/t/performance-difference-between-rest-and-java-api/21320/1 "2014-12-18T18:48:27Z")

</div>

I'm benchmarking results for an ES cluster, using both the REST api and  
native Java client. We're getting very different response times, between  
each of these (the REST api is doing approximately 50% better in the 95th  
percentile). I was wondering what the cause of this is, since the search  
requests look identical to me (unless I missed something).

Here are the queries:

> <https://gist.github.com/anonymous/509b3db873a30d8961ed>

Our setup: 20 node cluster, 20 shards/2 replicas, and benchmarking from a  
separate machine with JMeter (an HTTP sampler for each of the 20 nodes, and  
a separate test plan with a Java sampler initializing the ES java client,  
and sending queries).

Any help appreciated.

-M

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 18, 2014, 10:32pm UTC](https://discuss.elastic.co/t/performance-difference-between-rest-and-java-api/21320/2 "2014-12-18T22:32:58Z")

</div>

How about this?

> <https://gist.github.com/anonymous/509b3db873a30d8961ed#comment-1359074>

Jörg

On Thu, Dec 18, 2014 at 7:48 PM, Marie Jacob [jacob.marie@gmail.com](mailto:jacob.marie@gmail.com) wrote:

> I'm benchmarking results for an ES cluster, using both the REST api and  
> native Java client. We're getting very different response times, between  
> each of these (the REST api is doing approximately 50% better in the 95th  
> percentile). I was wondering what the cause of this is, since the search  
> requests look identical to me (unless I missed something).
> 
> Here are the queries:
> 
> [gist:509b3db873a30d8961ed · GitHub](https://gist.github.com/anonymous/509b3db873a30d8961ed)
> 
> Our setup: 20 node cluster, 20 shards/2 replicas, and benchmarking from a  
> separate machine with JMeter (an HTTP sampler for each of the 20 nodes, and  
> a separate test plan with a Java sampler initializing the ES java client,  
> and sending queries).
> 
> Any help appreciated.
> 
> -M
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFm1Eo-h6y%3D2NjvZtY7yGa3YRBcLZG%3DjAxAS9oxCKZeyw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFm1Eo-h6y%3D2NjvZtY7yGa3YRBcLZG%3DjAxAS9oxCKZeyw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Marie\_Jacob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marie_jacob/32/1038_2.png) [@Marie\_Jacob](https://discuss.elastic.co/u/Marie_Jacob)\
**Post date:** [December 19, 2014, 12:18am UTC](https://discuss.elastic.co/t/performance-difference-between-rest-and-java-api/21320/3 "2014-12-19T00:18:49Z")

</div>

Thanks Jörg.

I tried that, and it seems to make no difference. All I could gather are  
these graphs (attached) from the bigdesk plugin that are showing  
performance for the query and fetch phase (the first is during ES java  
client use, the second is using the REST calls) . It's really weird that  
the FETCH phase is taking any time at all, if I set \_source = false.

On Thursday, December 18, 2014 5:33:05 PM UTC-5, Jörg Prante wrote:

> How about this?
> 
> [gist:509b3db873a30d8961ed · GitHub](https://gist.github.com/anonymous/509b3db873a30d8961ed#comment-1359074)
> 
> Jörg
> 
> On Thu, Dec 18, 2014 at 7:48 PM, Marie Jacob \<[jacob...@gmail.com](mailto:jacob...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > I'm benchmarking results for an ES cluster, using both the REST api and  
> > native Java client. We're getting very different response times, between  
> > each of these (the REST api is doing approximately 50% better in the 95th  
> > percentile). I was wondering what the cause of this is, since the search  
> > requests look identical to me (unless I missed something).
> > 
> > Here are the queries:
> > 
> > [gist:509b3db873a30d8961ed · GitHub](https://gist.github.com/anonymous/509b3db873a30d8961ed)
> > 
> > Our setup: 20 node cluster, 20 shards/2 replicas, and benchmarking from a  
> > separate machine with JMeter (an HTTP sampler for each of the 20 nodes, and  
> > a separate test plan with a Java sampler initializing the ES java client,  
> > and sending queries).
> > 
> > Any help appreciated.
> > 
> > -M
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/060e3e34-1326-4d6d-a645-670924818d6c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/060e3e34-1326-4d6d-a645-670924818d6c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 19, 2014, 8:20am UTC](https://discuss.elastic.co/t/performance-difference-between-rest-and-java-api/21320/4 "2014-12-19T08:20:31Z")

</div>

The idea is for tracing the issue to rebuild the query from simple to  
complex and compare.

I would start with the query and add the filters step by step, to identify  
the part which causes trouble.

On possible cause is that REST API is using some defaults which have to be  
set in the Java API explicitly.

Jörg

On Fri, Dec 19, 2014 at 1:18 AM, Marie Jacob [jacob.marie@gmail.com](mailto:jacob.marie@gmail.com) wrote:

> Thanks Jörg.
> 
> I tried that, and it seems to make no difference. All I could gather are  
> these graphs (attached) from the bigdesk plugin that are showing  
> performance for the query and fetch phase (the first is during ES java  
> client use, the second is using the REST calls) . It's really weird that  
> the FETCH phase is taking any time at all, if I set \_source = false.
> 
> On Thursday, December 18, 2014 5:33:05 PM UTC-5, Jörg Prante wrote:
> 
> > How about this?
> > 
> > [gist:509b3db873a30d8961ed · GitHub](https://gist.github.com/anonymous/509b3db873a30d8961ed#comment-1359074)
> > 
> > Jörg
> > 
> > On Thu, Dec 18, 2014 at 7:48 PM, Marie Jacob [jacob...@gmail.com](mailto:jacob...@gmail.com) wrote:
> > 
> > > I'm benchmarking results for an ES cluster, using both the REST api and  
> > > native Java client. We're getting very different response times, between  
> > > each of these (the REST api is doing approximately 50% better in the 95th  
> > > percentile). I was wondering what the cause of this is, since the search  
> > > requests look identical to me (unless I missed something).
> > > 
> > > Here are the queries:
> > > 
> > > [gist:509b3db873a30d8961ed · GitHub](https://gist.github.com/anonymous/509b3db873a30d8961ed)
> > > 
> > > Our setup: 20 node cluster, 20 shards/2 replicas, and benchmarking from  
> > > a separate machine with JMeter (an HTTP sampler for each of the 20 nodes,  
> > > and a separate test plan with a Java sampler initializing the ES java  
> > > client, and sending queries).
> > > 
> > > Any help appreciated.
> > > 
> > > -M
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a5915f2f-ed31-4abb-af68-77c67a586aa9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/060e3e34-1326-4d6d-a645-670924818d6c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/060e3e34-1326-4d6d-a645-670924818d6c%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/060e3e34-1326-4d6d-a645-670924818d6c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/060e3e34-1326-4d6d-a645-670924818d6c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHRJSL\_wJoj-Q%2BypXC3Ej79fNPC-6j-BEJ-LMpPXU8yDQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHRJSL_wJoj-Q%2BypXC3Ej79fNPC-6j-BEJ-LMpPXU8yDQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:42am UTC](https://discuss.elastic.co/t/performance-difference-between-rest-and-java-api/21320/5 "2017-07-06T00:42:45Z")

</div>


