# Elasticsearch client using too much cpu

**URL:** <https://discuss.elastic.co/t/elasticsearch-client-using-too-much-cpu/6749>\
**Category:** Elasticsearch\
**Created:** [February 19, 2012, 7:27pm UTC](https://discuss.elastic.co/t/elasticsearch-client-using-too-much-cpu/6749 "2012-02-19T19:27:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)\
**Post date:** [February 19, 2012, 7:27pm UTC](https://discuss.elastic.co/t/elasticsearch-client-using-too-much-cpu/6749/1 "2012-02-19T19:27:02Z")

</div>

hi,  
im pretty sure i am doing something wrong here as it doesnt make sense. can  
someone tell what it is?

my ES client is taking 100% cpu on a dual core ec2 m1.large instance (so  
effectively 50%). while the actual elasticsearch process is hardly taking  
any cpu.

my client is designed in the following way - there is one ES client worker  
thread which instantiates ES Client once in its constructor. Inside the run  
method, it dequeue messages from a local java blockingqueue and uses the  
client to do 2 things - a prepareGet and then prepareIndex. if it gets  
something from prepareget, it uses the sourcefield map to update the new  
document along with new fields that it wants to update. and then does  
prepareIndex.execute().actionGet();

there is only 1 thread talking to ES service. is this expected?

thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 20, 2012, 1:09pm UTC](https://discuss.elastic.co/t/elasticsearch-client-using-too-much-cpu/6749/2 "2012-02-20T13:09:52Z")

</div>

Can you profile the client and see where CPU is spent? VisualVM has a nice sampling profiler without needing to set anything up.

On Sunday, February 19, 2012 at 9:27 PM, T Vinod Gupta wrote:

> hi,  
> im pretty sure i am doing something wrong here as it doesnt make sense. can someone tell what it is?
> 
> my ES client is taking 100% cpu on a dual core ec2 m1.large instance (so effectively 50%). while the actual elasticsearch process is hardly taking any cpu.
> 
> my client is designed in the following way - there is one ES client worker thread which instantiates ES Client once in its constructor. Inside the run method, it dequeue messages from a local java blockingqueue and uses the client to do 2 things - a prepareGet and then prepareIndex. if it gets something from prepareget, it uses the sourcefield map to update the new document along with new fields that it wants to update. and then does prepareIndex.execute().actionGet();
> 
> there is only 1 thread talking to ES service. is this expected?
> 
> thanks

---

<div class="post-metadata">

**Author:** ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)\
**Post date:** [February 20, 2012, 6:57pm UTC](https://discuss.elastic.co/t/elasticsearch-client-using-too-much-cpu/6749/3 "2012-02-20T18:57:53Z")

</div>

attaching the visualvm profiler dump in xml.. i have never used this tool  
before, so not sure if i got the right data.. but it looks like lot of time  
spent in threadpoolworker run and a future in es.

thanks

On Mon, Feb 20, 2012 at 5:09 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Can you profile the client and see where CPU is spent? VisualVM has a  
> nice sampling profiler without needing to set anything up.
> 
> On Sunday, February 19, 2012 at 9:27 PM, T Vinod Gupta wrote:
> 
> hi,  
> im pretty sure i am doing something wrong here as it doesnt make sense.  
> can someone tell what it is?
> 
> my ES client is taking 100% cpu on a dual core ec2 m1.large instance (so  
> effectively 50%). while the actual elasticsearch process is hardly taking  
> any cpu.
> 
> my client is designed in the following way - there is one ES client worker  
> thread which instantiates ES Client once in its constructor. Inside the run  
> method, it dequeue messages from a local java blockingqueue and uses the  
> client to do 2 things - a prepareGet and then prepareIndex. if it gets  
> something from prepareget, it uses the sourcefield map to update the new  
> document along with new fields that it wants to update. and then does  
> prepareIndex.execute().actionGet();
> 
> there is only 1 thread talking to ES service. is this expected?
> 
> thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 21, 2012, 4:17pm UTC](https://discuss.elastic.co/t/elasticsearch-client-using-too-much-cpu/6749/4 "2012-02-21T16:17:41Z")

</div>

Kind of hard to tell based on that, maybe you can do more "heavy" profiling of the app?

On Monday, February 20, 2012 at 8:57 PM, T Vinod Gupta wrote:

> attaching the visualvm profiler dump in xml.. i have never used this tool before, so not sure if i got the right data.. but it looks like lot of time spent in threadpoolworker run and a future in es.
> 
> thanks
> 
> On Mon, Feb 20, 2012 at 5:09 AM, Shay Banon \<[kimchy@gmail.com](mailto:kimchy@gmail.com) ([mailto:kimchy@gmail.com](mailto:kimchy@gmail.com))\> wrote:
> 
> > Can you profile the client and see where CPU is spent? VisualVM has a nice sampling profiler without needing to set anything up.
> > 
> > On Sunday, February 19, 2012 at 9:27 PM, T Vinod Gupta wrote:
> > 
> > > hi,  
> > > im pretty sure i am doing something wrong here as it doesnt make sense. can someone tell what it is?
> > > 
> > > my ES client is taking 100% cpu on a dual core ec2 m1.large instance (so effectively 50%). while the actual elasticsearch process is hardly taking any cpu.
> > > 
> > > my client is designed in the following way - there is one ES client worker thread which instantiates ES Client once in its constructor. Inside the run method, it dequeue messages from a local java blockingqueue and uses the client to do 2 things - a prepareGet and then prepareIndex. if it gets something from prepareget, it uses the sourcefield map to update the new document along with new fields that it wants to update. and then does prepareIndex.execute().actionGet();
> > > 
> > > there is only 1 thread talking to ES service. is this expected?
> > > 
> > > thanks
> 
> Attachments:
> 
> - ESProfilerResults1.xml

---

<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, 3:38am UTC](https://discuss.elastic.co/t/elasticsearch-client-using-too-much-cpu/6749/5 "2017-07-06T03:38:40Z")

</div>


