# Percolation time varies a lot

**URL:** <https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870>\
**Category:** Elasticsearch\
**Created:** [January 11, 2016, 11:22am UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870 "2016-01-11T11:22:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![anishek](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@anishek](https://discuss.elastic.co/u/anishek)\
**Post date:** [January 11, 2016, 11:22am UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/1 "2016-01-11T11:22:42Z")

</div>

Hello,

I am just testing the below on a single 40 core machine. It has 171 percolation documents under a single index (index1).

I create a test document to percolate against them. The test document is not changing and i am testing via  
`curl -XGET localhost:9200/index1/som_maping/_percolate -d '[doc json]'`

running the same doc at different times results the time taken to vary from 50 ms to 250 ms to get the result. Why is such huge variation for the same doc ?

There is no other operation running either on elasticsearch or on the machine. Any insight would be great !

Thanks

---

<div class="post-metadata">

**Author:** ![Daverino](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@Daverino](https://discuss.elastic.co/u/Daverino)\
**Post date:** [January 14, 2016, 5:03pm UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/2 "2016-01-14T17:03:27Z")

</div>

How are you measuring the response time?

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 15, 2016, 9:40am UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/3 "2016-01-15T09:40:04Z")

</div>

Would be good to know what is causing this. Did you measure network time or the `took` field that is included in the percolate response?

---

<div class="post-metadata">

**Author:** ![anishek](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@anishek](https://discuss.elastic.co/u/anishek)\
**Post date:** [January 15, 2016, 10:26am UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/4 "2016-01-15T10:26:17Z")

</div>

Using the "took" field in the response as well as have used the

`curl -w @curl_format.txt`

in the command to make sure network latency is not the major cause of this. network is not the problem, the percolation at ES side not consistent.

---

<div class="post-metadata">

**Author:** ![Daverino](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@Daverino](https://discuss.elastic.co/u/Daverino)\
**Post date:** [January 18, 2016, 5:00pm UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/5 "2016-01-18T17:00:50Z")

</div>

My first hunch would be to check your memory usage and load, although it sounds like you have plenty of resources. Since percolation is completely in memory and your index and document are both kept there, percolator is going to be much more dependent on your available resources and have little to no dependency on your disk.

---

<div class="post-metadata">

**Author:** ![anishek](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@anishek](https://discuss.elastic.co/u/anishek)\
**Post date:** [January 19, 2016, 3:24am UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/6 "2016-01-19T03:24:49Z")

</div>

Its a 48 core machine with about 32 gb ram , there are only 170 queries in it, in a single index ... no other operation is being performed on this machine except the curl request i make, the memory consumption is low and so is the cpu...

ES is given 8 GB to start with

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 19, 2016, 9:32am UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/7 "2016-01-19T09:32:15Z")

</div>

I would expect that the first percolate requests are slower than requests made after the first requests. Is this also the case here? Do the request that take 250 ms occur just after ES has started or does this happen randomly while you're testing things out? Also how many requests did you run and how requests do you execute concurrently to test the percolator?

---

<div class="post-metadata">

**Author:** ![anishek](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@anishek](https://discuss.elastic.co/u/anishek)\
**Post date:** [January 19, 2016, 9:51am UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/8 "2016-01-19T09:51:59Z")

</div>

I just tried about 5-8 times and the time varied at random for about 2 and 5th and 8th request i think. it was not only on the first request. the first one was intact very fast, there is no concurrency here as i am testing via curl on the Terminal, I am planning to do some tests here regarding some other feature in ES and will try and see if i can formulate or post some sort of table listing the way time varied with sample queries and docs.

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 19, 2016, 1:09pm UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/9 "2016-01-19T13:09:45Z")

</div>

I think this invariance in query times is caused by noise from the fact that the jvm is 'cold'. If you run the query lets say a 100 times then I expect query time to be different.

---

<div class="post-metadata">

**Author:** ![anishek](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@anishek](https://discuss.elastic.co/u/anishek)\
**Post date:** [January 19, 2016, 1:13pm UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/10 "2016-01-19T13:13:22Z")

</div>

Well what do u mean by JVM being cold, I am running the document samples in sequence one after another manually, So the queries should all be loaded in memory after the first run, requiring a 100 runs before consistent response times is just asking for too much i think, since in some of the actual scenarios you might have thousands of queries at the same time and such requirement might just make percolation api unusable.

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [January 19, 2016, 1:24pm UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/11 "2016-01-19T13:24:11Z")

</div>

No, I didn't mean that each query would need to be run a 100 times in order to have a consistent query time. The jvm jit compiler may not have yet optimized certain code paths. This can explain some invariance in query time when running the first search / percolate requests etc.

I'm just saying that you may need to run your query a couple of times before you start measuring response times. Maybe the 100 times I suggested are a bit too extreme. In general before benchmarking you should run a couple of (irrelevant) requests a number of times (lets say 10 times) and then start to run the requests you like measure query time for.

---

<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, 11:23pm UTC](https://discuss.elastic.co/t/percolation-time-varies-a-lot/38870/12 "2017-07-05T23:23:29Z")

</div>


