Forum Discussion
Robert_47833
Altostratus
Jul 29, 2011how to insert cookie and persist to it
Hi,dear irule
I have a pool cjj which has 10 members ,ration is the load blance method
I need to insert cookie and persist with cookie ,
for example client1 ----->VS---->pool membe...
The_Bhattman
Nimbostratus
Jul 31, 2011Hi Jucao,
Thanks for explanation. This was extremely helpful in understanding your issue.
Let's first approach your first issue where you want to make the iRule more efficient and bring down the cycles, before moving into item 2
The following is the code re-written to use switch commands and expression commands.
when HTTP_REQUEST timing on {
if {[class match $uri starts_with gen3abURLs_SRWD29] } {
log local0. "Entering testi"
set rand [expr { rand() }]
set value_cookie ""
switch -glob [HTTP::cookie value_cookie] {
"1" {
pool cjj1
}
"2" {
Pool cjj2"
}
default {
if { $rand <0.2 } {
Pool cjj1
set value_cookie 1
}
else {
pool cjj2
set value_cookie 2
}
}
}
}
}
when HTTP_RESPONSE {
if {$value_cookie ne "" } {
HTTP::cookie insert name value_cookie value $value_cookie path "/"
}
}
Hopefully that will drop the cycles down enough to be efficient for you.
Bhattman
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