# Optimized Rest requests in case of embedded elastic search

**URL:** <https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698>\
**Category:** Elasticsearch\
**Created:** [February 10, 2014, 3:58pm UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698 "2014-02-10T15:58:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doru\_Sular](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Doru\_Sular](https://discuss.elastic.co/u/Doru_Sular)\
**Post date:** [February 10, 2014, 3:58pm UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698/1 "2014-02-10T15:58:59Z")

</div>

Hi guys,

I intend to use the elasticsearch embedded in my webapplication.  
Is there a kind of optimization for rest calls (for indexing a document for  
example) to not generate http traffic, when the elasticsearch is running in  
same virtual machine as the service caller? (Instead of generate an http  
request, just use java objects)  
Is there a way to index a document without using the rest api, in case the  
elasticsearch is embedded in the same webapplication?  
I want to index the log messages from my application as soon they are  
produced, but we have a lot of messages, should I be concerned of the http  
loading on the server?

Thank you very much,  
Doru

--  
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/81f4070a-7528-43a0-8c7e-af23c7699c41%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/81f4070a-7528-43a0-8c7e-af23c7699c41%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Tony\_Su](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tony\_Su](https://discuss.elastic.co/u/Tony_Su)\
**Post date:** [February 10, 2014, 9:52pm UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698/2 "2014-02-10T21:52:14Z")

</div>

Hi Doru,  
Based on what I've seen (but of course may be criticized by others)

I don't know if there is a sufficient reason to use the REST API and  
use something else instead.  
What is your concern? Network traffic? AFAIK if localhost is bound to lo or  
something similar, that isn't an issue.

As for your question about indexing your data before sending into ES, IMO  
that is what the Logstash examples illustrate.

The little 5-node ES cluster lab cluster I setup running ES, Redis,  
logstash and netcat as described in the Logstash 10-minute walkthrough was  
interesting re your question about separating load on to different apps  
running in different consoles. I could observe the apache data as it  
progressed through each app (because logstash was configured with a stdout  
output). I could see if there was a pause here and there, possibly  
indicating unused capacity.

I recommend you look at that tutorial and see if it answers your questions  
as well.

IMO,  
Tony

On Monday, February 10, 2014 7:58:59 AM UTC-8, Doru Sular wrote:

> Hi guys,
> 
> I intend to use the elasticsearch embedded in my webapplication.  
> Is there a kind of optimization for rest calls (for indexing a document  
> for example) to not generate http traffic, when the elasticsearch is  
> running in same virtual machine as the service caller? (Instead of generate  
> an http request, just use java objects)  
> Is there a way to index a document without using the rest api, in case the  
> elasticsearch is embedded in the same webapplication?  
> I want to index the log messages from my application as soon they are  
> produced, but we have a lot of messages, should I be concerned of the http  
> loading on the server?
> 
> Thank you very much,  
> Doru

--  
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/4c976cf9-1526-4e24-ac5f-187bb7e7e0d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4c976cf9-1526-4e24-ac5f-187bb7e7e0d1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Doru\_Sular](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Doru\_Sular](https://discuss.elastic.co/u/Doru_Sular)\
**Post date:** [February 11, 2014, 8:53am UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698/3 "2014-02-11T08:53:22Z")

</div>

Hi Tony,  
yes, network traffic might be a problem. I hope I can use easily the bulk  
option, otherweise it will be a "no go" for using elasticsearch.  
Still I have a question. What means "localhost is bound to lo or something  
similar" ?  
Thank you very much,  
Doru

On Monday, February 10, 2014 10:52:14 PM UTC+1, Tony Su wrote:

> Hi Doru,  
> Based on what I've seen (but of course may be criticized by others)
> 
> I don't know if there is a sufficient reason to use the REST API and  
> use something else instead.  
> What is your concern? Network traffic? AFAIK if localhost is bound to lo  
> or something similar, that isn't an issue.
> 
> As for your question about indexing your data before sending into ES, IMO  
> that is what the Logstash examples illustrate.
> 
> The little 5-node ES cluster lab cluster I setup running ES, Redis,  
> logstash and netcat as described in the Logstash 10-minute walkthrough was  
> interesting re your question about separating load on to different apps  
> running in different consoles. I could observe the apache data as it  
> progressed through each app (because logstash was configured with a stdout  
> output). I could see if there was a pause here and there, possibly  
> indicating unused capacity.
> 
> I recommend you look at that tutorial and see if it answers your questions  
> as well.
> 
> IMO,  
> Tony
> 
> On Monday, February 10, 2014 7:58:59 AM UTC-8, Doru Sular wrote:
> 
> > Hi guys,
> > 
> > I intend to use the elasticsearch embedded in my webapplication.  
> > Is there a kind of optimization for rest calls (for indexing a document  
> > for example) to not generate http traffic, when the elasticsearch is  
> > running in same virtual machine as the service caller? (Instead of generate  
> > an http request, just use java objects)  
> > Is there a way to index a document without using the rest api, in case  
> > the elasticsearch is embedded in the same webapplication?  
> > I want to index the log messages from my application as soon they are  
> > produced, but we have a lot of messages, should I be concerned of the http  
> > loading on the server?
> > 
> > Thank you very much,  
> > Doru

--  
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/709363dc-72e3-4ec2-ba9e-80349af3790a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/709363dc-72e3-4ec2-ba9e-80349af3790a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jaymode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaymode/32/50103_2.png) [@jaymode](https://discuss.elastic.co/u/jaymode)\
**Post date:** [February 12, 2014, 2:03am UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698/4 "2014-02-12T02:03:51Z")

</div>

Look at the Java API[http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/).  
From my look through elasticsearch code, it does not generate HTTP requests  
but routes them through services.

How many logs do you generate on average? Do your servers have enough  
resources to handle indexing and searching at the same time? I think you  
should worry about these questions more than HTTP loading on your server.

Additionally logging messages from a web application to elasticsearch in  
the same webapp requires some thought into implementation; you can wind up  
in an endless loop if a class that saves your logs to elasticsearch also  
logs a message. Another item to think about is how to index the logs and  
how long to retain them.

On Monday, February 10, 2014 10:58:59 AM UTC-5, Doru Sular wrote:

> Hi guys,
> 
> I intend to use the elasticsearch embedded in my webapplication.  
> Is there a kind of optimization for rest calls (for indexing a document  
> for example) to not generate http traffic, when the elasticsearch is  
> running in same virtual machine as the service caller? (Instead of generate  
> an http request, just use java objects)  
> Is there a way to index a document without using the rest api, in case the  
> elasticsearch is embedded in the same webapplication?  
> I want to index the log messages from my application as soon they are  
> produced, but we have a lot of messages, should I be concerned of the http  
> loading on the server?
> 
> Thank you very much,  
> Doru

--  
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/c0f60c04-a939-4ea8-aade-e3781a54cafb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c0f60c04-a939-4ea8-aade-e3781a54cafb%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [February 12, 2014, 9:10am UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698/5 "2014-02-12T09:10:59Z")

</div>

I wrap up my Elasticsearch apps in a Wildfly web app with JAX-RS API, using  
the native java transport protocol.

You do not need to use HTTP with Java app logs. Just write a log4j appender  
or something like this and connect this to a bulk indexer.

Jörg

--  
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/CAKdsXoHbCLfwrZ9dwXnV3%3D%2B\_sZj%3DeNgEA2XkF3751iddAB5\_wg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHbCLfwrZ9dwXnV3%3D%2B_sZj%3DeNgEA2XkF3751iddAB5_wg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Doru\_Sular](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Doru\_Sular](https://discuss.elastic.co/u/Doru_Sular)\
**Post date:** [February 13, 2014, 1:36pm UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698/6 "2014-02-13T13:36:53Z")

</div>

Hi Jörg,  
Can you please provide the name of the elasticsearch classes needed to  
implement a bulk indexer?  
Thank you very much,  
Doru

On Wednesday, February 12, 2014 10:10:59 AM UTC+1, Jörg Prante wrote:

> I wrap up my Elasticsearch apps in a Wildfly web app with JAX-RS API,  
> using the native java transport protocol.
> 
> You do not need to use HTTP with Java app logs. Just write a log4j  
> appender or something like this and connect this to a bulk indexer.
> 
> Jörg

--  
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/77cfe567-a3cb-4058-b918-31fdf4bb8611%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/77cfe567-a3cb-4058-b918-31fdf4bb8611%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:50am UTC](https://discuss.elastic.co/t/optimized-rest-requests-in-case-of-embedded-elastic-search/15698/7 "2017-07-06T01:50:31Z")

</div>

Closed on July 6, 2017, 1:50am UTC


