Skip to end of metadata
Go to start of metadata

Overview of Request and Search Strings

The load balancer monitors the nodes in its pool by connecting to each node and sending a "request string."  The request string is in the form of the "GET" HTTP method/command.  The request string then looks for a "search string." The default search string is "200 OK".

Example

Let's look at a specific example where we are load balancing an HTTP server with the default request string: "GET / HTTP/1.0\r\n\r\n".  This string is made up of the "GET" command, the HTTP version you are using (HTTP/1.0) and a double CR/LF (\r\n\r\n) sequence at the end.  If everything is going well with your node, this request string will return a response that includes the phrase "200 OK".

We can see this happen when we 1) telnet to the node:

$ telnet 8.19.73.88 80
Trying 8.19.73.88...
Connected to 8.19.73.88 (8.19.73.88).
Escape character is '^]'.

And 2) type in the request string and hit return twice:

GET / HTTP/1.0

(Note that we didn't need "\r\n\r\n" because we are manually hitting return.)  If everything is OK, we get something like:

HTTP/1.0 200 OK
Date: Fri, 25 Apr 2008 19:04:00 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Thu, 24 Apr 2008 14:20:03 GMT
ETag: "18c220-26-44b9f2535aac0"
Accept-Ranges: bytes
Content-Length: 38
Connection: close
Content-Type: text/html; charset=UTF-8

Note that this output is a standard HTTP header, since there is no content on the web server yet.  "200 OK" is a standard part of an HTTP header when everything is running smoothly.  So if you leave the monitor in default mode, it will look for "200 OK"; when a node goes down "200 OK" will not be returned and the node will be pulled out of rotation.

Using Request and Search Strings to Intentionally Fail a Node

You may want to change the request and search strings so that you can intentionally fail a node without removing it from the pool.  In that case, it is easiest to create a file on your web servers and point the monitor there to look for the search string.  For example, you could make a file "status.html" and somewhere inside that file include the phrase "active." Then set your request string as:

GET /status.html HTTP/1.0\r\n\r\n

And set your search string as "active."

The load balancer will connect to your nodes and use the GET command to get the contents of "status.html".  If it finds "active" it will report the node as up; if it doesn't, it will report the node as down.  To remove a node from rotation just change "active" to something else in status.html.

Adding or Changing a Request and Search String

You can include a request or search string when you create a pool using the "manage-lb-pool create" command.  You can add or change the strings of an existing pool using the "manage-lb-pool modify" command.  For example:

manage-lb-pool modify --name=test_pool --request-string='GET /status.php HTTP/1.0\r\n\r\n' --search-string='status: active' --username <USERNAME>

Case of HTTP/1.1 Version

As the standard requires the hostname to be specified for the 1.1 version of HTTP protocol, the following command should be run in that case:

manage-lb-pool modify --name=test_pool --request-string='GET /status.php HTTP/1.1\r\n Host: www.sitename.com\r\n\r\n' --search-string='status: active' --username <USERNAME>
  • No labels