Please help about clear ES cache


(palmer) #1

Hi , i'm a tester, by use ES 5.3, testing the search result used time;
original search use about 20s, after cache search use 2s;

but don't know how to correct clear the cache , (have tried command "curl -XPOST '127.0.0.1:9200/_cache/clear?pretty'" and restart Elasticsearch, but the search time still use the cache way, it's always about 2s)


(Zachary Tong) #2

I'm not sure if cache clearing works with "all" indices implicitly. You may have to use the _all special identifier or a wildcard, e.g.:

/_all/_cache/clear or /*/_cache/clear/

That said... why do you want to clear the cache for testing? It won't give you an accurate understanding of the performance of the system, since Elasticsearch cache things by default. A better way to test is to use a realistic production workload (real documents, a variety of real queries, etc) so that caching effects are spread across the data and you get a more accurate picture.

Also, there is OS level caching which you can't control. That may be what you're running into anyway. E.g. the operating system will see that you are accessing the same files (lucene segments) repeatedly and cache them in memory for fast access. That could be why you see a fast response even after restarting elasticsearch... the OS has cached the relevant files.

Benchmarking is usually about using a realistic workload so that caching is applied like the real world, rather than trying to fight and eliminate caching for a "pure" benchmark. :slight_smile:


(Julien) #3

The command looks correct. Also if a node was just restarted there is no cached information yet in the jvm heap, although another node may have cache in case you are on several nodes cluster...
What is the output of the clear cache api, if es respond without error then it most likely worked, and note response time can vary in case garbage collection kicked in while serving the search or in case data nodes are busy with other threads... This should not usually make a difference of seconds but rather ms although it all relative of usage and resources...


(palmer) #4

thanks help, paste output at below:
[root@localhost ~]# curl -XPOST '127.0.0.1:9200/_cache/clear?pretty'
{
"_shards" : {
"total" : 515,
"successful" : 515,
"failed" : 0
}
}


(palmer) #5

thanks a lot, i think i got the answer from 2nd phase


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.