Forum Discussion
Kevin_Stewart
Aug 06, 2013Employee
This is a crude example, but I think close to what you're trying to accomplish:
when RULE_INIT {
set ::lb_counter 1
}
when HTTP_REQUEST {
if { not ( [HTTP::header Cookie] contains "BIGipServer" ) } {
if { $::lb_counter == 1 } {
pool port-8081-pool
log local0. "sending to port-8081-pool"
set ::lb_counter 2
return
} elseif { $::lb_counter == 2 } {
pool port-8082-pool
log local0. "sending to port-8082-pool"
set ::lb_counter 1
}
}
}
Create two pools (example: "port-8081-pool" and "port-8082-pool") and apply the built-in cookie persistence profile to the the VS00 virtual server. On first request the client will not present a BIG-IP persistence cookie and get round robin load balanced to one of the pools. LTM will then inject that pool's persistence information into the first response to the client. Subsequent requests will contain the "BIGipServer" cookie and bypass the round robin function in favor the of the cookie's persistence information.
You could do something similar with VIP targeting, but you'd need to handle persistence a little more manually. The real benefit of VIP targeting is that each internal VIP could have its own unique configurations and iRules.