When an HTTP request fails or returns an error code that is part of user-specified error codes, the Controller forwards these error messages back to the client. The Avi Load Balancer can be configured to retry such requests.

Configurable Options

HTTP server reselect is deactivated by default. The feature can be configured within individual pools. One can optionally select the error codes that trigger the feature. Once enabled, the feature works in all connection or SSH failure scenarios.

Error Codes

The pool configuration specifies the HTTP error response codes that must result in server reselection. The error codes can be specified in any of the following ways.

  • Explicit code number(s): Enter one or more individual error codes (for instance, 404).

  • Range of codes: Enter a range between 400-499 or 500 and 599 (for instance, 501-503).

  • Entire block of codes: 4xx or 5xx (for instance, 4xx).

Maximum Retries

The default maximum retry setting is 4. Following the first error response, the Avi Load Balancer resends the request to the pool up to 4 more times, for a total of 5 attempts. Each retry is sent to a different server, and each server can receive only one attempt.

If the setting for maximum retries is higher than the number of enabled and running servers within the pool, each of those servers still receives only one attempt. For example, if maximum retries is set to 4 but the pool has only 3 servers, the maximum number of retries is only 2. The initial attempt that fails goes to one of the servers, leaving 2 more servers to try. If the second server also sends a 4xx or 5xx error code in response to the request, the request is sent to the last server in the pool. If the last server also sends a 4xx or 5xx, the response from the server is sent back to the client.

Server Retry Timeout

The srv_retry_timeout variable can be set through the Avi Load Balancer REST API or CLI. Ensure that server_reselect.enabled is set to True for the srv_retry_timeout variable setting to take effect. The timeout range is 0-3600000 ms (60 mins). A value of 0 causes the timeout to default to the connection timeout value.

Server Reselection for Idempotent Requests

HTTP server reselect applies only to idempotent request methods, since a given request of this type always has the same result, even if an identical request is received multiple times by a server. Multiple identical requests of non-idempotent request methods (POST, LOCK, PATCH, and CONNECT) are by definition, not guaranteed to have the same effect as that of single such requests. So, HTTP server reselect is not performed for these request methods.

Configuring HTTP Server Reselect

HTTP server reselect can be enabled on the Advanced tab of the pool configuration.

  1. Navigate to Applications > Pools.

  2. Open the configuration popup for the pool.

    1. If you are enabling the feature in an existing pool, click the edit icon for the pool.

    2. For creating a new pool, click Create Pool, select the cloud name and click Next. Enter a name for the pool on the Settings tab, select the servers on the Servers tab.

  3. Click the Servers tab.

  4. Scroll down to select the HTTP Server Reselect check box.

  5. Enter the error response codes that trigger server reselection.

  6. Save the changes.

    1. If creating a new pool, click Next to review the settings and click SAVE.

    2. If editing an existing pool, click SAVE.

The following example enables HTTP server reselection for all 4xx error codes.



Based on this configuration, if a server in this pool responds to a client request with a 4xx error code, the Avi Load Balancer retries the request by sending it to another server in the pool. The retry process can happen up to 4 times (to 4 different servers).

CLI Example

Note:

Only significant lines of interest from the CLI output are included in the following example.

[admin:10-10-27-18]: > configure pool vs-test-pool
Updating an existing object. Currently, the object is:
+---------------------------------------+------------------------------------------------+
| Field                                 | Value                                          |
+---------------------------------------+------------------------------------------------+
| uuid                                  | pool-8e91b1a6-17bf-490e-b59a-05efd942a3f6      |
| name                                  | vs-test-pool                                   |
.                                                                                        .
.                                                                                        .
.                                                                                        .
| server_reselect                       |                                                |
|   enabled                             | False                                          |
|   num_retries                         | 4                                              |
|   retry_nonidempotent                 | False                                          |
|   srv_retry_timeout                   | 0 milliseconds                                 |
.                                                                                        .
.                                                                                        .
.                                                                                        .
+---------------------------------------+------------------------------------------------+                                                           
[admin:10-10-27-18]: pool> server_reselect enabled
[admin:10-10-27-18]: pool:server_reselect> srv_retry_timeout 5000
Overwriting the previously entered value for srv_retry_timeout
[admin:10-10-27-18]: pool:server_reselect> save
[admin:10-10-27-18]: pool> exit
+---------------------------------------+------------------------------------------------+
| Field                                 | Value                                          |
+---------------------------------------+------------------------------------------------+
| uuid                                  | pool-8e91b1a6-17bf-490e-b59a-05efd942a3f6      |
| name                                  | vs-test-pool                                   |
.                                                                                        .
.                                                                                        .
.                                                                                        .
| server_reselect                       |                                                |
|   enabled                             | True                                           |
|   num_retries                         | 4                                              |
|   retry_nonidempotent                 | False                                          |
|   srv_retry_timeout                   | 5000 milliseconds                              |
.                                                                                        .
.                                                                                        .
.                                                                                        .
+---------------------------------------+------------------------------------------------+

[admin:10-10-27-18]: > configure pool vs-test-pool server_reselect
[admin:10-10-27-18]: pool:server_reselect> no enabled
+---------------------+-------------------+
| Field               | Value             |
+---------------------+-------------------+
| enabled             | False             |
| num_retries         | 4                 |
| retry_nonidempotent | False             |
| srv_retry_timeout   | 5000 milliseconds |
+---------------------+-------------------+
[admin:10-10-27-18]: pool:server_reselect> srv_retry_timeout 0
Overwriting the previously entered value for srv_retry_timeout
[admin:10-10-27-18]: pool:server_reselect> save
[admin:10-10-27-18]: pool> save
+---------------------------------------+------------------------------------------------+
| Field                                 | Value                                          |
+---------------------------------------+------------------------------------------------+
| uuid                                  | pool-8e91b1a6-17bf-490e-b59a-05efd942a3f6      |
| name                                  | vs-test-pool                                   |
.                                                                                        .
.                                                                                        .
.                                                                                        .
| server_reselect                       |                                                |
|   enabled                             | False                                          |
|   num_retries                         | 4                                              |
|   retry_nonidempotent                 | False                                          |
|   srv_retry_timeout                   | 0 milliseconds                                 |
.                                                                                        .
.                                                                                        .
.                                                                                        .
+---------------------------------------+------------------------------------------------+
[admin:10-10-27-18]: >