Forum Discussion
Andy_Herrman_22
Nimbostratus
Jun 21, 2006Problem with persistence
I have a setup with a BIG-IP load balancer with 2 servers in a pool being load balanced. The URI that the user is connecting with contains a query parameter that is used for the persistence value. According to our logging the iRule is correctly extracting the value and setting the persistence, but requests with the same value don't always go to the same machine.
The iRule is pretty simple:
when HTTP_REQUEST {
set fulluri [HTTP::uri]
set uid [findstr [HTTP::uri] "uid=" 5 "&"]
if { $uid != "" } {
log local0. "Set persist value to uid: $uid | $fulluri"
persist uie $uid
}
else {
log local0. "No uid found in HTTP REQUEST | $fulluri"
}
}
The logging that displays always shows the correct uid value. However, I get logging on both servers showing that they've gotten requests, and those logs show the same uid. BIG-IP stats also show that it's sending requests to both servers, thought the persistence table seems correct.
Has anyone run into anything like this before? I can't find anything wrong with the iRule, and the requests are happening fast enough that the persistence values wouldn't be timing out.
- Andy_Herrman_22
Nimbostratus
That could explain it. - dennypayne
Employee
Hmm...not sure if it's possible (or how) to compare values that are already in the table... - Andy_Herrman_22
Nimbostratus
As long as it doesn't reset the persistence (change the server it points to) then it should be fine. - Andy_Herrman_22
Nimbostratus
It doesn't seem to like the
call. I'm getting the following error in the log:persist add uie $uid
when CLIENT_ACCEPTED { set add_persist 1 } when HTTP_REQUEST { set fulluri [HTTP::uri] set uid [findstr [HTTP::uri] "uid=" 5 "&"] if { $uid != "" } { if { $add_persist } { log local0. "Adding persist value to table: $uid | $fulluri" persist add uie $uid set add_persist 0 } else { log local0. "Set persist value to uid: $uid | $fulluri" persist uie $uid } } else { log local0. "No uid found in HTTP REQUEST | $fulluri" } }
- JRahm
Admin
I've only seen the persist add statement on the serverside events. - Deb_Allen_18Historic F5 AccountFrom my experience, the general idea seems to be:
- Andy_Herrman_22
Nimbostratus
The persistence value isn't generated in a response. The persistence value is part of all connections to the server, including the very first one.
should restart it.persist uie $uid
- Andy_Herrman_22
Nimbostratus
I changed the iRule to do the add in the response. According to the logs it's adding the correct value, but it's happening every time someone connects (which might be ok, I'm not sure). Unfortunately, the persistence still isn't working. The connections with the same uid are going to different servers.when HTTP_REQUEST { set fulluri [HTTP::uri] set uid [findstr [HTTP::uri] "uid=" 5 "&"] if { $uid != "" } { log local0. "Set persist value to uid: $uid | $fulluri" persist uie $uid } else { log local0. "No uid found in HTTP REQUEST | $fulluri" } } when HTTP_RESPONSE { if { $uid != "" } { log local0. "Adding persist value to table: $uid" persist add uie $uid } }
- dennypayne
Employee
Try using the CLIENT_ACCEPTED event that I used earlier to limit the addition of a record to the first connection.when CLIENT_ACCEPTED { set add_persist 1 when HTTP_RESPONSE { set uid [findstr [HTTP::uri] "uid=" 5 "&"] if { $uid != "" and $add_persist} { log local0. "Adding persist value to table: $uid" persist add uie $uid set add_persist 0 } when HTTP_REQUEST { set fulluri [HTTP::uri] set uid [findstr [HTTP::uri] "uid=" 5 "&"] if { $uid != "" } { log local0. "Using persist value uid: $uid | $fulluri" persist uie $uid } else { log local0. "No uid found in HTTP REQUEST | $fulluri" } }
- Andy_Herrman_22
Nimbostratus
The value for $uid was still in scope during the HTTP_RESPONSE message, so it had the correct value (same reason the add_persist value keeps it's value of 1 between CLIENT_ACCEPTED and HTTP_REQUEST). The logging messages I put in place verified this.
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