Forum Discussion
Matt_Breedlove_
Nimbostratus
Jun 24, 2009single VS distributing new connections across multiple pools with persistence
We have a single VS in standard mode with 2 pools of servers. Each pool contains different servers.
VS has cookie insert persistence with named cookie and a 17min timeout.
Goal is to have 1 out of every X number of NEW connections only go to the second pool. Once a client has been sent to the second pool, the subsequent requests from that user should also follow into the the second pool if during same session.
We have a single global variable that increments each time HTTP_REQUEST occurs, but we want to modify this so that it only increments on new connections
Current rule:
when RULE_INIT {
set ::cnt 0
}
when HTTP_REQUEST {
incr $cnt
if { $cnt = 4000 } {
set ::cnt 0
pool pool2
} else {
pool $pool1
}
}
Pool 2 is about 20% of the capacity of Pool 1 and using different class of server hardware.
One thing that I was thinking of was to look for the named persistence cookie, and if it does not already exist then increment the global var
The assumption is that new/initial HTTP connections can be identified in the VS's iRule by looking for the presence of the named inserted cookie via the persistence profile.
We have the megaproxy issue so we are dependent on cookie inserted persistence
Possible changed rule
when RULE_INIT {
set ::cnt 0
}
when HTTP_REQUEST {
if { ([HTTP::cookie] exists "namedcookie_from_persistence_profile") } {
send connection to existing persisted server in whichever pool its in
Can 'persist' just be used or does the member and pool need to be looked up and then
manually pooled there?
} else {
Assumption is only brand new initial connections with no persistence yet defined are
being dealt with at this point
incr $cnt
if { $cnt = 4000 } {
set ::cnt 0
pool pool2 New persistence record is formed after this 'pool'
} else {
pool $pool1
}
}
}
Is this the right strategy?
Can 'persist' be used in place of 'pool' to make sure the specific member in the respective pool is reused for the rest of that sessions http requests? Or is 'pool' required to actually farm the connection out
What we are trying to avoid is having User Bob come in and hit homepage on global var cont 3998, go to a server in pool a, then click on 2 links and the second link sets the global var to 4000, which causes Bob to have his second click "pooled" to the second pool. Rather we would not want User Bob's subsequent http requests to be capable of incrementing that global var, so that when User Joe comes in on new connection and he trips the counter to 4000, then his requests and subsequent requests in same connection/session go to that same node in the second pool
Once the persistence cookie expires then the user can be sent to either of the pools.
If the node in the pool is marked down by a monitor, we would expect that to wipe out the named persistence cookie causing them to be free to be subject to new pool and new subsequent persistence record being created
Thanks for the help
- hoolio
Cirrostratus
Persistence is specific to the pool. If the two pools you want to use have different members, then you would want to specify a different persistence cookie name depending on which pool to send the client to. So you could use 'persist cookie insert pool1_cookie 0' to insert a session cookie for pool 1 / use the existing cookie in the client's request to select the same pool1 member.when HTTP_REQUEST { Check if client has pool1 persistence cookie if {[string length [HTTP::cookie value $pool1_persist_cookie_name]]}{ Client has pool1 persistence cookie. Check if pool is up? Specify pool1 persistence to select same pool1 member persist cookie insert $pool1_persist_cookie_name 0 Check if client has pool2 persistence cookie } elseif {[string length [HTTP::cookie value $pool2_persist_cookie_name]]}{ Client has pool2 persistence cookie. Check if pool is up? Specify pool2 persistence to select same pool2 member persist cookie insert $pool2_persist_cookie_name 0 } else { Client has no persistence cookie, so select between pool1 and pool2 Set persistence based on selected pool } }
- Matt_Breedlove_
Nimbostratus
So to clarify, can the rule be simplified even further?when RULE_INIT { set ::cnt 0 } when HTTP_REQUEST { if {[HTTP::cookie exists FOO]}{ persist cookie passive FOO This should pass connection along to the pool/member that the client has in the persistence record...irule terminates here just like I did a 'pool' command...correct? } else { incr $cnt if { $cnt = 4000 } { set ::cnt 0 pool pool2 New FOO cookie for user inserted via profile } else { pool $pool1 New FOO cookie for user inserted via profile } } }
- hoolio
Cirrostratus
There can only be one default pool associated with a virtual server. This default pool would be used if the rule didn't specify a new pool. The persistence cookie has an encoding of the pool member IP:port. So consider the following scenario: - Matt_Breedlove_
Nimbostratus
Ok, so you are saying that in the above:persist cookie passive FOO
persist cookie insert $pool1_persist_cookie_name 0
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