Forum Discussion
Adam_24063
Nimbostratus
Mar 19, 2007persist based on cookie with URI pools
Howdy, I'm trying to take our working jsessionid iRule and add a twist. We'd like for requests with a .seam URI to go to one pool, while all other requests go to a different pool (the motivation here is to equal out expensive seam requests which treverse a Tomcat backend vs. simple JavaScript/JPGs/etc). Below is the working rule we use today:
rule jsessionid {
when HTTP_RESPONSE {
if { [HTTP::cookie exists "JSESSIONID"] } {
persist add uie [HTTP::cookie "JSESSIONID"] 86400
}
}
when HTTP_REQUEST {
if { [HTTP::cookie exists "JSESSIONID"] } {
persist uie [HTTP::cookie "JSESSIONID"] 86400
if { [HTTP::uri] contains ".seam" } { log local0. "IP:[IP::remote_addr] URI:[HTTP::uri] NODE:[LB::server]" }
} else {
set jsess [findstr [HTTP::uri] ";jsessionid=" 12 32]
if { $jsess != "" } {
persist uie $jsess 86400
}
}
}
}
Along with the attempted new rule..
rule seam_persist {
when HTTP_RESPONSE {
if { [HTTP::cookie exists "JSESSIONID"] } {
persist add uie [HTTP::cookie "JSESSIONID"] 86400
}
}
when HTTP_REQUEST {
if { [HTTP::uri] ends_with ".seam" } {
pool www_seam
log local0. "POOL:seam IP:[IP::remote_addr] URI:[HTTP::uri] NODE:[LB::server]"
} else {
pool www
log local0. "POOL:www IP:[IP::remote_addr] URI:[HTTP::uri] NODE:[LB::server]"
}
if { [HTTP::cookie exists "JSESSIONID"] } {
persist uie [HTTP::cookie "JSESSIONID"] 86400
} else {
set jsess [findstr [HTTP::uri] ";jsessionid=" 12 32]
if { $jsess != "" } {
persist uie $jsess 86400
}
}
}
}
It should be noted the URI selection work fines, what we're running into is requests aren't being holding stickyness or persistence; this is obvious from navigating our application or logging LB::server. Thanks for the help!
- Wes_98712
Nimbostratus
First off I would highly suggest you get away from handling cookie persistence in the dynamic fashion that you are doing with Irules, the cookie hash function handles it much better, believe me, I had a very extensive JSESSIONID iRule that performed almost the exact same thing, but failed on more than one occassion when the server took a dive. So, what I would suggest is that you use a cookie hash persistence profile, set it to expire with the same timeout value as your deployment descriptors state within the web.xml, or application.xml. - Adam_24063
Nimbostratus
Thanks for the reply. We avoided the cookie function to support folks who don't accept cookies, this is why you see the ";jsession" string in URI's. - Wes_98712
Nimbostratus
Yes that is the standard reason, which escaped me, which is why I always use simple persistence as a backup in case the cookie fails, but doesn't always work.
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