I've been experiencing very slow Solr server responses of 12 to 20 seconds for only my first page request after the site has site idle for a few minutes. All subsequent requests are very fast. I've placed some timers in the code and I've tracked it down to the following code in the core drupal_http_request function.

  // Fetch response.
  $response = '';
  while (!feof($fp) && $chunk = fread($fp, 1024)) {
    $response .= $chunk;
  }

So the socket is already open and it's trying to read. As I said this is ONLY happening after the site sites idle for a bit and then all subsequent requests are much much faster. I'm suspecting that this might be an Apache Solr setup issue but I was wondering if any of our Drupal users have experienced this? I'm just using the packaged jetty server and I followed the install instruction given here in this module so I've done no other customizations of the Solr side.

CommentFileSizeAuthor
#6 repopulate-371858-6.patch726 bytespwolanin

Comments

JacobSingh’s picture

Status: Active » Fixed

This is likely solr's autowarming cache. Take a look on the Solr site for it, you'll find out how to pre-fill it and deal with this issue. Hopefully not a huge deal if you have enough traffic to keep your searcher going. Basically, every cron run if you send up docs, it will re-gen the cache on the next search, or by and a query you specify in your solrconfig.xml.

Take a look at the Solr docs, it should be explained (a lot) better there.
Best,
Jacob

dreed47’s picture

Thanks, I'll take a look at that. I see in the cron hook for the apachesolr module it's doing a $solr->clearCache and a $solr->Optimize. Could that also be causing a problem if I'm running very frequent cron runs (like every 15 minutes)

dreed47’s picture

Commenting out the $solr->clearCache line in the cron hook seems to have helped this issue greatly for me. I'm not sure if a clearCache is needed before we run an Optimize and I'm not sure of what affect this will have if I DON'T clear the cache on every cron run. Although, conceptually, it seems that we would NOT want to clear the cache that often anyways.

pwolanin’s picture

The cache here only has the Luke data, so it should be pretty low cost to regenerate

dreed47’s picture

Category: support » feature
Status: Fixed » Active

It definitely has huge performance impacts for my use case. Would it make sense to provide an option on one of the settings page to not clear the cache on every cron run? I've changed this to a feature request.

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new726 bytes

So I'd imagine this is the problem - if we don't have the cached data (which we need to build the facet blocks, etc) the page hangs while getting it.

The easy solution is to re-populate the cache on cron, rather than waiting for an actual search request.

See if this helps.

dreed47’s picture

+1 That patch works for me.

pwolanin’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

francewhoa’s picture

Another option to increase performance is to make Apache Solr the only search engine available http://drupal.org/node/504804

DriesS’s picture

I found a nice tool ( http://wekkars.com ) that wake up your server after some time, it solved this problem for me.