Gartner has predicted that worldwide information security spending will witness a growth of 7% in 2017, with the total amount spent reaching close to $93 billion in 2018. This in...
By: Vijay Mhaskar | October 30, 2015
In this blog I am talking about simple yet very useful Solr handler which is PingRequestHandler. We can use Ping Request Handler as a endpoint for an HTTP Load-Balancer(Like HAProxy) to use when checking the “up status” of a Solr server.
We can configure PingRequestHandler with some defaults indicating a request that should be executed. If configured request succeeds, then the PingRequestHandler will respond back with a simple “OK” status. If the request fails, then the PingRequestHandler will respond back with the corresponding HTTP Error code. Clients can be configured to poll the PingRequestHandler monitoring for these types of responses to know if there is a problem with the Solr server.
The Ping option will not open new page we can see status of the request on the core overview page. The length of time the request has taken is displayed next to the Ping option, in milliseconds.
To configure this handler in Solr we need to add request handler in Solrconfig.xml file like below,
<requestHandler name="/admin/ping" class="solr.PingRequestHandler"> <lst name="invariants"> <str name="q">Management of Rubella in pregnancy</str> </lst> <lst name="defaults"> <str name="echoParams">all</str> <str name="df">article</str> </lst> <str name="healthcheckFile">server-enabled.txt</str> </requestHandler>
We can configure healthcheckFile that can be used to enable/disable the PingRequestHandler. We should always remember below points while using healthcheck file,
- If the health check file exists, the handler will execute the query and returns status as described previously.
- If the health check file does not exist, the handler will throw an HTTP error even though the server is working fine and the query would have succeeded.
This health check file feature can be used as a way to indicate to some Load Balancers that the server should be “removed from rotation” for maintenance, or upgrades, or whatever reason you may wish.
The health check file may be created/deleted by any external system, or the PingRequestHandler itself can be used to create/delete the file by specifying an “action” param in a request:
http://host:port/solr/admin/ping?action=enable – creates the health check file if it does not already exist
http://host:port/solr/admin/ping?action=disable – deletes the health check file if it exists
http://host:port/solr/admin/ping?action=status – returns a status code indicating if the healthcheck file exists (“enabled”) or not (“disabled”)
Below are screenshots of Solr Admin page after configuring PingRequestHandler