Roger_Wolfson_8
Aug 26, 2006Nimbostratus
Advice on "persist hash" load balancing
Hi, I've been reading through past post about load balancing certain requests based on part of the request data using the "persist hash" method, but I haven't been able to implement it successfully. This is on v9.2.3.
I'll use the URL of this forum-post page as an example:
http://devcentral.f5.com/Default.aspx?tabid=28&forumid=5&view=post
I want to pick a member node of the pool based on the forumid value in the query string, to optimize caching on the web servers. A given user will be bounced between servers as they click between forums, but all requests for forum 5 will end up at a given node. For simplicity I'd rather use the "persist hash" method so I don't have to maintain a list of the actual nodes inside the irule.
Now that I've started testing my irule, however, I find that I'm getting assigned to the same server (at least for several minutes) regardless of page, as if it were persisting based on my client IP or other data rather than what I want.
The config:
A virtual server with one pool of two nodes, Round Robin, no default persistence profile.
My irule (I'm a TCL newbie, so feel free to point out errors):
when HTTP_REQUEST
{
if {[string tolower [HTTP::uri]] starts_with "/default.aspx"}
{
set forumid "none"
if {[string first forumid= [HTTP::query]] != -1}
{
set query [HTTP::query]
regexp -nocase forumid=(\d*) $query forumid
}
if {$forumid != "none"}
{
persist hash "$forumid"
}
}
}
I've tried to use the log local0. "something" syntax I've seen here to help debug, but I can't find where the output lands - I don't see it in the Logs section of the web UI. (I can probably optimize out the first test for the forumid substring, but I'll take care of that later). I've also tried the simpler version
when HTTP_REQUEST
{
persist hash [HTTP::query]
}
and this too seems to lock me to a single server regardless of query string, for a while before it switches. It seems like severing my TCP connection between my browser and the site (the bigip device) helps break the binding to a particular node, but even then the resulting one isn't deterministic based on the query string param.
Any advice on either what I'm doing wrong or how to better debug this?
Thanks!