Disk IO is often a prominent bottleneck in computer system response speed, search engine query is very ordinary, reduce the search process of disk IO to enhance the search response speed is undoubtedly a great help, in SOLR, provide a self-contained cache mechanism. We just need to add a few configuration items to the Solrconfig.xml.
Let's take a look at SOLR's 3 caches.
Filter cache: This is the result of the cache filter (that is, query parameter FQ) and the basic enumeration type.
Document cache: This is the thing that is used to cache Lucene documents, which is the one that stores the field.
Query Result cache: This is a glance that caches the results of queries.
First, cache configuration
SOLR's cache configuration is in the query configuration section of the Solrconfig.xml file, which is between the <query> and </query> tags. SOLR implements 2 kinds of caching mechanisms, namely LRUCache, Fastlrucache;
LRUCache: Thread-safe linkedhashmap implementation.
Fastlrucache: Based on CONCURRENTHASHMAP implementation.
A single-threaded case Fastlrucache has a faster get operation and slower puts operations, so the query hit rate using it will be higher than LRUCache 75%, although the gap may be greater in multi-threaded situations.
Parameter description:
Class: Specifies which caching mechanism to use with SOLR.
Size: The amount of cache space that is allowed to allocate the number of entities (entity).
InitialSize: Allocates cache space for the initial number of entities (entity).
Autowarmcount: The number of entities that are automatically preloaded in.
1. Filter Cache
[HTML]View Plaincopy
- <Filtercache
- class="SOLR. Fastlrucache "
- size="
- initialsize="
- autowarmcount="/> "
2, Documentcache
[HTML]View Plaincopy
- <Queryresultcache
- class="SOLR. Fastlrucache "
- size="
- initialsize="
- autowarmcount="/> "
3. QueryResult Cache
[HTML]View Plaincopy
- <Documentcache
- class="SOLR. Fastlrucache "
- size="11000"
- initialsize="11000" />
4. Query Result window value setting
The query Result window value is used with query result cache. What is the concept of this value is that I set the Query Results window value of 50, I query 20 to 30 of the data, the first query SOLR will be removed from the index library 0 to 49 of the data, I will not have to page the index library to query, directly from the cache to take it, Greatly improves the query response speed.
[HTML]View Plaincopy
- <queryresultwindowsize>50</queryresultwindowsize>
Second, complete configuration
- <!--cache configuration--
- <query>
- <!--filter cache-->
- <filtercache
- class="SOLR. Fastlrucache "
- size="
- initialsize="
- autowarmcount="/> "
- <!--query results cache-->
- <queryresultcache
- class="SOLR. Fastlrucache "
- size="
- initialsize="
- autowarmcount="/> "
- <!--document Cache-->
- <documentcache
- class="SOLR. Fastlrucache "
- size="11000"
- initialsize="11000" />
- <queryresultwindowsize>200</queryresultwindowsize>
- </Query>
Solr4.7 Cache Technology