1. SitecoreAI development

Specify connection timeout

Sitecore interacts with the Solr server for index operations, running search queries, managing Solr schema, and administrating Solr cores. By default, Sitecore uses the same timeout configuration for all requests, regardless of the purpose of the request.

But requests with different purposes can sometimes benefit from having different request timeout values. For example, requests that update Solr schemas or change Solr core properties are rare so a longer timeout for such operations is acceptable. Search queries, on the other hand, can degrade the whole system performance if the timeout is too long.

Important

Do not set the timeout value to higher than 30 seconds. It is set to 30 seconds by default.

Therefore, you can specify distinct connection timeout values for three different types of operations:

  • Admin: used for core admin operations. You can see a full list of these operations at the Solr website.
  • Query: used for regular search queries.
  • Default: used for operations that are neither of the above.

To enable and specify distinct connections timeout values.

  1. Rename the App_Config\Include\Examples\Sitecore.ContentSearch.Solr.ConnectionSettings.config.example file to App_Config\Include\Examples\Sitecore.ContentSearch.Solr.ConnectionSettings.config.
  2. Specify the values (in milliseconds) you require for admin, query, and default:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
    <sitecore search:require="solr">
        <contentSearch>
            <indexConfigurations>
                <solrConnectionConfigurations>
                    <solrConnectionConfiguration name="admin">
                        <timeout>10</timeout>
                    </solrConnectionConfiguration>
                    <solrConnectionConfiguration name="query">
                        <timeout>10</timeout>
                    </solrConnectionConfiguration>
                    <solrConnectionConfiguration name="default">
                        <timeout>10</timeout>
                    </solrConnectionConfiguration>
                </solrConnectionConfigurations>
            </indexConfigurations>
        </contentSearch>
    </sitecore>
</configuration>
Note

The example above sets timeout by operation type. The ContentSearch.Solr.ConnectionTimeout can set the timeout for all operations. If a specific connection timeout for an operation is set to 0, it will fall back to the the ContentSearch.Solr.ConnectionTimeout value.

If you have suggestions for improving this article, let us know!