Forum Discussion
Wil_Schultz_101
Nimbostratus
Jul 30, 2007Reselect pool on status code 500 or above...
So we run some Tomcat servers, when we undeploy the server will send a 503 that states that the application is unavailable. I do have a check that looks for a static page every 5 seconds and fails at ...
sam_81897
Nimbostratus
Oct 03, 2011So I am trying to do the following with the iRule which was submitted by Wil Schultz:
1. Client Sends HTTP Post to F5
2. F5 Proxies connection to Server1
3. Server1 is shutting down, replies with HTTP Status Code 5XX
4. F5 Catches 503, redirects request to another Server2 in pool
5. Server2 fulfills the request sends HTTP200 OK to F5
6. F5 Relays 200OK to client.
The main thing is that I do not want the client to see the 500 error. Is there additional logic that I need to implement to ensure the client does not see the 500 error? The iRule I am using is as follows:
this counter is used to limit the number of retrieswhen CLIENT_ACCEPTED {set retries 0}Try a new node if we have retried the connection once, set the method to rrThis is just an idea right nowwhen LB_SELECTED {if { $retries >= 1 } {log "Reselecting from node=[LB::server addr] in pool=[LB::server pool]"set mypool [LB::server pool]LB::mode rrLB::reselect pool $mypool}}we need to capture the request data to send the request again after receiving a 500 errorwhen HTTP_REQUEST {set myhttprequest [HTTP::request]}This is the guts here, examine each HTTP response. If you get an HTTP 500 error do the following: Check to ensure we have not tried multiple times Detach from the current node Select a new node from the current pool when HTTP_RESPONSE {if { [HTTP::status] starts_with "5" } {log "$myhttprequest has generated a [HTTP::status]"if { ($retries < [active_members [LB::server pool]] ) } {incr retriesHTTP::retry $myhttprequest log "500 error received. HTTP request $myhttprequest has been retried to [LB::server addr]."}}} Mark the node down and select a new node on LB failure.when LB_FAILED {log "Failure of node=[LB::server addr] in pool=[LB::server pool]"set mypool [LB::server pool]LB::downLB::mode rrLB::reselect pool $mypoool}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects