Over a million developers have joined DZone.

Solr Delay Component

· Web Dev Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

First of all, why would you want to slow Solr down? After all, it’s great speed is one of the main reasons it’s become so popular. Well, I need to slow Solr down for testing load balancing timeouts / failover and to test parallel execution. Both are hard to do with response times well below a second. There are some tricks possible using inefficient queries, however that’s not very consistent.

So, I’ve made a simple component that allows you to slow Solr down for with an exact amount of time using the query string. When the component is enabled you can simple add your delay (in millisec) to the request like this: &delay=5000

Maybe this is useful to more people, so I’ve placed it on GitHub. Here are the steps to use it:

  1. Go to the GitHub project page https://github.com/basdenooijer/raspberry-solr-plugins and download the project.
  2. In the build dir of the project is one jar file. Place this in the instanceDir of your Solr core, in a folder called ‘lib’. This folder may not exist yet, in that case create it. For a Solr example install the directory is: /example/solr/lib
  3. Add the two snippets below to your solrconfig.xml (I’m assuming a default solrconfig.xml, otherwise you might need to adjust the configs)
  4. Restart Solr
  5. Test it by adding a delay param to your request. For instance:
    This should delay the query by one second, you should also be able to see this in the debug output. The delay param is in milliseconds. No param or a value of 0 disables the delay.

These are the two snippets you need to add to your solrconfig.xml:

Add this inside the requestHandler definition that is named “search”:

<arr name="last-components">

Outside the requestHandler definition add this:

<searchComponent name="delay" class="nl.raspberry.solr.DelayComponent">

Important warning: this component is intended purely for testing purposes. It’s not advised to enable this component on a production environment. First of all it’s useless, in production you should not be testing. But it can also easily be abused to flood the server with lots of queries with a big delay.

Source:  http://www.raspberry.nl/2012/01/04/solr-delay-component/

The Web Dev Zone is brought to you by Stormpath—offering a complete, pre-built User Management API for building web and mobile applications, and APIs. Download our new whitepaper: "Build Versus Buy: Customer Identity Management for Web and Mobile Applications".


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}