Forum Discussion
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!
- dennypayneEmployeeThe log function to local0 should be putting log entries in the Local Traffic section of the Logs in the GUI, or /var/log/ltm if you SSH in.
- Roger_Wolfson_8NimbostratusThanks for the tips. I tweaked some log level settings and got it logging.
persist hash "$idmatch" log local0. "persisting on key $idmatch"
- Deb_Allen_18Historic F5 AccountActually, you might NEED to enable OneConnect.
- Roger_Wolfson_8NimbostratusThanks Deb, this seems to resolve the problem! However, is this a viable option to use in a production configuration, or does it have measurable impact against our previous benefit of connection marshalling? If I understand correctly the last thing you said, the total number of connections across all webserver nodes will now equal the total number of client connections to the Bigip device, where we're currently seeing only a small fraction of the total client connections appear on the webservers.
- Deb_Allen_18Historic F5 AccountHi Roger,
- unRuleY_95363Historic F5 AccountI just wanted to clarify, that each HTTP request is parsed and inspected, regardless of whether or not the OneConnect profile is attached. However, without OneConnect, a new LB decision is not made unless the pool changes. So, even though you mave now have new criteria that should dictate a new pool member be used, it does not detach to previous one. However, one of the aspects of OneConnect is that each request is load-balanced to a potentially new member (depending on the lb mode) and persistence is taken into account during the load-balancing decision.
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