Forum Discussion
iRule that will limit connections
1) limit the web servers to 50 connections each.
2) any connection after 50 will be redirected to another site.
3) Clients are using cookies for persistence.
4) Once a client gets a cookie we need to keep persistence.
rule session_limit {
my qustion is - i
1)Is the max_active_clients- of 50, is that for the pool or each member?
2) How do we guarantee that we always send users to a server that has the capacity? We notice - that when we have a few connections available on a server. We will still get redirected – for example - one servers will have 40 connections- the other about 10. So we will get redirted - in this case to yahoo. Is there a way to set the limit on the per node basis? It looks like we are setting the limit on the per vip basis.
Below is what we have:
rule session_limit {
when RULE_INIT {
array set ::active_sessions { }
set ::total_active_clients 0
set ::max_active_clients 50
}
when HTTP_REQUEST {
if { [HTTP::cookie exist "BIGipServerhalifax"] } {
pool halifax
incr ::total_active_clients
log "Total Clients $::total_active_clients"
log "Active Sessions $::active_sessions { } "
} else { if { $::total_active_clients < $::max_active_clients } {
if { [HTTP::uri] contains "linkID=halifax" } {
pool halifax
incr ::total_active_clients
} else { HTTP::redirect "http://pleasehold.evenue.net/bigip/nocookies.html" }
} else { HTTP::redirect "http://www.yahoo.com/"
return
}
}
}
when CLIENT_CLOSED {
incr ::total_active_clients -1
}
}
- Deb_Allen_18Historic F5 AccountHey Bob --
- bob_rao_7722Historic F5 AccountIs the connections based on active connections or total connections?
- Deb_Allen_18Historic F5 AccountMake sure I have the logic straight first:
if cookie exists load balance to default pool w/persistence (session already exists, so don't increment counter) if no cookie exists if uristring exists redirect to "nocookies" page if connection limit not yet reached load balance to default pool increment counter else if connection limit already reached redirect to "server busy" page
rule session_limit { when RULE_INIT { set ::total_active_clients 0 set ::max_active_clients 50 } when HTTP_REQUEST { ; If persistence cookie already exists, ; allow persistent connection without incrementing counter if { [HTTP::cookie exists "BIGipServerhalifax"] } { pool halifax return ; If no cookie, check for URI link parameter ; & redirect if present } else { if { [HTTP::uri] contains "linkID=halifax" } { HTTP::redirect "http://pleasehold.evenue.net/bigip/nocookies.html" return } ; Still no cookie ; Check limit vs. active ; Allow in if there's room, and incr counter for this new cnx if { $::total_active_clients < $::max_active_clients } { incr ::total_active_clients pool halifax return ; otherwise redirect } else { HTTP::redirect "http://www.yahoo.com/" return } } } when CLIENT_CLOSED { incr ::total_active_clients -1 } }
- David_Horton_20
Nimbostratus
Hi - Leslie_South_55
Nimbostratus
I am testing your rule, and sometimes I get the followingSep 11 10:09:12 tmm tmm[1055]: 01220001:3: TCL error: Rule rule_http-session-limit - Operation not supported. Multiple redirect/respond invocations not allowed (line 23) invoked from within "HTTP::redirect "http://www.google.com""
log local0. "current active clients $::total_active_clients"
Recent Discussions
Related Content
* 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