# Sometimes index docs very slow

**URL:** <https://discuss.elastic.co/t/sometimes-index-docs-very-slow/55743>\
**Category:** Elasticsearch\
**Created:** [July 18, 2016, 10:24am UTC](https://discuss.elastic.co/t/sometimes-index-docs-very-slow/55743 "2016-07-18T10:24:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![famoss](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@famoss](https://discuss.elastic.co/u/famoss)\
**Post date:** [July 18, 2016, 10:24am UTC](https://discuss.elastic.co/t/sometimes-index-docs-very-slow/55743/1 "2016-07-18T10:24:56Z")

</div>

Today,i find my `es cluster` index docs very slow and precarious.

I added some log to calculate how long to call the `bulk` `api`.

`public void execute() throws Exception { logger.info("begin call es bulk api"); long startTime=System.currentTimeMillis(); try { BulkResponse bulkResponse = bulkRequestBuilder.execute().actionGet(); if (bulkResponse.hasFailures()) { throw new EventDeliveryException(bulkResponse.buildFailureMessage()); } } finally { bulkRequestBuilder = client.prepareBulk(); } logger.info("end es bulk api,time:"+(System.currentTimeMillis() -startTime)); }`

From the log.  
`end es bulk api,time:100 end es bulk api,time:1121 end es bulk api,time:56785 end es bulk api,time:16201 end es bulk api,time:401 end es bulk api,time:87543`  
I find es sometimes index docs very slow.

I use the api `curl 'localhost:9200/_cat/thread_poolv&h=id,host,bulk.size,bulk.active,bulk.rejected,bulk.completed,bulk.queueSize,bulk.queue'` and find the `active.bulk` and `buld.queue` are all less 2.

I use the command `top` and `iotop` and find the cpu usage and disk io are all very small.

How to find out where the problem is?  
Thank you

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [July 18, 2016, 1:12pm UTC](https://discuss.elastic.co/t/sometimes-index-docs-very-slow/55743/2 "2016-07-18T13:12:28Z")

</div>

Are your bulk indexing requests always the same number of documents, size of documents? If that varies then indexing time would also vary.

Try following the suggestions from this blog post?: [https://www.elastic.co/blog/performance-indexing-2-0](https://www.elastic.co/blog/performance-indexing-2-0)

If it's still randomly slow, can you post hot threads during a slow bulk request?

Mike

---

<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 5, 2017, 10:34pm UTC](https://discuss.elastic.co/t/sometimes-index-docs-very-slow/55743/3 "2017-07-05T22:34:42Z")

</div>


