An idempotent request is one that does not cause any change or inconsistency in an application when retried. To enhance the availability of your applications deployed on an Application Server cluster, configure the load balancer to retry failed idempotent HTTP requests on all the Application Server instances in a cluster. This option can be used for read-only requests, for example, to retry a search request.
This section describes the following topics:
To configure idempotent URL response, specify the URLs that can be safely retried in idempotent-url-pattern elements in the sun-web.xml file. For example:
<idempotent-url-pattern url-pattern="sun_java/*" no-of-retries="10"/>
If none of the server instances can successfully serve the request, an error page is returned.
Since all requests for a given session are sent to the same application server instance, and if that Application Server instance is unreachable, the load balancer returns an error message. Normally, the request is not retried on another Application Server instance. However, if the URL pattern matches that specified in the sun-web.xml file, the request is implicitly retried on another Application Server instance in the cluster.
In HTTP, some methods (such as GET) are idempotent, while other methods (such as POST) are not. In effect, retrying an idempotent URL should not cause values to change on the server or in the database. The only difference should be a change in the response received by the user.
Examples of idempotent requests include search engine queries and database queries. The underlying principle is that the retry does not cause an update or modification of data.
A search engine, for example, sends HTTP requests with the same URL pattern to the load balancer. Specifying the URL pattern of the search request to the load balancer ensures that HTTP requests with the specified URL pattern are implicitly retried on another Application Server instance.
For example, if the request URL sent to the Application Server is of the type /search/something.html, then the URL pattern can be specified as /search/*.
Examples of non-idempotent requests include banking transactions and online shopping. If you retry such requests, money might be transferred twice from your account.