Help with URI string-based session persistence
Hi all
Warning: Newer to F5 but really enjoying the experience so far. Trying to get my hands dirty with iRules.
I've been doing a lot of research on the forums and I haven't come across the "golden post" yet that can seem to help me with making an iRule for my problem. I feel like it should be easy using universal persistence but I cannot seem to get it to function. It could be my lack of understanding of how the F5s work internally..
Anyway here goes - Scenario: Request comes into LB with a unique "strID" value in the URI or in the HTTP Header "x-original-url" (if via proxy) - /some_uri?strID=Asb22332&TimeLimit=180&User=Joe&request=submit
What I need to have happen is to ensure that when a subsequent request comes into the LB with a URI of similar nature with the SAME strID value -- /some_uri?strID=Asb22332&TimeLimit=180&User=Bob&request=poll
That it goes to the same back-end node so the request is processed on the same node. This should happen very shortly after the first submit, so the persistence can be pretty low (30 seconds or less depending on tests).
Here is my code so far:
when HTTP_REQUEST {
set sid [findstr [HTTP::uri] "strID" 7 "&"]
log local0. "findstr output: [findstr [HTTP::uri] "strID" 7 "&"]"
if { $sid ne "" } {
log local0. "In IF statement! > $sid <"
set server [session lookup uie $sid]
log local0. "Server: $server"
if { $server ne "" } {
log local0. "Server Found: $server"
node [getfield $server : 1][getfield $server : 2]
}
else { persist uie $sid 60 }
}
}
The behavior I'm seeing is that it does find the strID value, and it will create a universal persistence record with the ID value. However, if I attempt to change that value, a new record is not created.. ? Also, when I hit F5, I do not see $server resolve, it logs just "Server: "
This makes me think my lookup command doesn't actually find the correct value - or I'm really not understanding session vs persistence.. perhaps I'm making it too complicated?
I would greatly appreciate any assistance with the above scenario! Thank you.
If this happens the LB just sends the request to the same node that the TCP session is tied to - but the iRule still logs as seeing the new strID value. I was confused and expected this to create a new persistence record and load balance the request, but something tells me I would need more logic in my iRule to detach the connection and re-load balance it with a new persistence record.
you can use oneconnect profile. it will do that for you.