Forum Discussion

Evan_104403's avatar
Evan_104403
Historic F5 Account
Apr 25, 2008

Comments on the efficiency of this script

Or even, better, hints to improve the performance of it!

 

 

What it does: In the event of a response code other than 2xx, 3xx or 404, it will reselect a pool member.

 

 

Ok, here it is:

 

when RULE_INIT {

 

set retries 0

 

}

 

when CLIENT_ACCEPTED {

 

set retries 0

 

}

 

when HTTP_REQUEST {

 

set request [HTTP::request]

 

set url [HTTP::uri]

 

set hmethod [HTTP::method]

 

log local0. "HTTP request: $request"

 

}

 

when LB_SELECTED {

 

if { $retries >= 1 } {

 

log local0. "befor is [LB::server addr]"

 

LB::reselect pool pol_hitamg

 

log local0. "after is [LB::server addr]"

 

}

 

}

 

when LB_FAILED {

 

reject

 

}

 

when HTTP_RESPONSE {

 

if {not (([HTTP::status] starts_with "2") or([HTTP::status] starts_with "3") or ([HTTP::status] eq "404"))}{

 

STATS::incr Masrawy_stats status_error

 

log local0. "$url"

 

incr retries

 

log "4xx error caught: retry $retries out of [active_members [LB::server pool]]"

 

log "the uri is $request"

 

check to see if the no of you have tried all the servers in the pool

 

if { ($retries < [active_members [LB::server pool]]) and (not($hmethod equals "POST"))} {

 

log local0. $hmethod

 

HTTP::retry $request

 

all server are down then go and serve the page of error

 

} else {

 

reject

 

log local0. "$url"

 

log local0. "$url"

 

log local0. "the page couldnt be found on any of the servers $request"

 

}

 

}

 

}
No RepliesBe the first to reply