I’ve written the following universal persistence iRule, and it seems to work as intended. Anybody have any comments, suggestions, or improvements? In particular is there a better way than the regexp to do this? The sid is variable length.
when HTTP_REQUEST {
set server_id [ findstr [HTTP::uri] "sid" 4 "&" ]
if {$server_id ne ""} {
regexp {.*\.([0-9]+)$} $server_id match server_num
log "Force persist by sid to server $server_num"
use pool webfarm member 1.1.1.10$server_num 80
} else {
log "No sid, persisting by fallback method"
}
}
That’s pretty trick!
I can’t really think of any better way than doing the regexp unless the period is unique. If so, you could instead do another findstr like:
[findstr $server_id “.” 1] which will find the period and return the portion following it.
Thanks! Unfortunately the period isn’t unique. At least I have control over the IP addressing and can do tricks like this without having to maintain a data group.
Tcl is a pretty slick language, I haven’t written anything in it before now. Our entire web site was written in Tcl about 7 years ago. It was replaced because it was all CGI and suffered poor scalability, rather than because of problems with Tcl.