Solr Configuration
The Widget Framework uses Solr for a variety of look-up operations, and in a production environment it will exert a heavy load on Solr, especially if your Data Sources use many Solr-based query types such as Query by section, Query by tag and Query by search. You are therefore strongly recommended to enable Solr response caching. This will significantly reduce the load on Solr and improve its performance.
When configuring Solr you need to ensure:
-
That the Solr caches are large enough
-
That Solr caches search results for a suitable length of time
-
That Solr adds the correct HTTP caching headers to its search query responses
Below are some suggested settings for the Solr configuration file
(solrconfig.xml
) that you can start with, which
should give reasonable results. If you want to optimize your
installation further, then you should consult the Solr documentation.
-
<autoCommit> <maxDocs>100</maxDocs> <maxTime>300000</maxTime> </autoCommit>
This tells Solr to cache up to 100 query results for a period of 5 minutes.
-
<query> ... <queryResultCache class="solr.LRUCache" size="2048" initialSize="512" autowarmCount="0"/> <documentCache class="solr.LRUCache" size="20000" initialSize="1024" autowarmCount="0"/> ... </query>
This sets Solr's internal caches to a suitable size for holding the required number of results.
-
<requestDispatcher handleSelect="true"> ... <httpCaching lastModFrom="openTime" etagSeed="Solr"> <cacheControl>max-age=30, public</cacheControl> </httpCaching> ... </requestDispatcher>
This tells the Widget Framework to cache supplied results for 30 seconds.
With these settings in place, the first time a particular query is
submitted to Solr, it will perform the search, save the results in its
cache and also return the results to the
Widget Framework
with an HTTP header containing an instruction to cache the result for
30 seconds. If the same request is repeated within 30 seconds, then
the results will be returned from the
Widget Framework's
cache. If the same request is repeated after 30 seconds have elapsed,
then the
Widget Framework
will again submit a request to Solr, but with an HTTP caching header
asking for the response in its cache to be revalidated. If the result
is still in the Solr cache, then Solr will return an HTTP 304
Not Modified
response (since this is more efficient than
returning the cached response again). The
Widget Framework
can then use the response in its own cache and revalidate it for
another 30 seconds. If the Solr cache has expired in the mean time
then Solr will perform the requested search again, cache the results
and return them with the same caching header.
How much effect this configuration has on Solr performance will obviously depend on usage in your particular installation, and achieving optimum results may require some adjustment. For more information about Solr caching, see the Solr documentation.