Forum Discussion
DJ_23086
Altocumulus
Mar 12, 2009Limit connections to nodes
Hi
I'm having some issues with this one, and haven't been able to put together anything useful.
We have been requested to look into limiting the connections (http) to nodes. The setup is fairly straightforward, and I'd probably be able to tweak one of the example scripts off of Codeshare, but we are using pools for more than one VIP, and also on occasion nodes in more than one pool which seems to rule out limiting connections per VIP or pool?
Is there a way that we can somehow monitor and manage a maximum connection limit to each node, and serve a maintenance page or redirect to a maintenance pool for overflow? I would expect this would need to be tracked via session cookie or something, to differentiate between current and new clients.
Eg. server limit 250 connections, new connection number 251 gets redirected to a "Too many users, please try again later" page or overflow pool.
Any pointers?
- The_Bhattman
Nimbostratus
- DJ_23086
Altocumulus
Hi CBwhen RULE_INIT { set ::total_active_clients 0 set ::max_active_clients 1 log local0. "rule session_limit initialized: total/max: $::total_active_clients/$::max_active_clients" } when CLIENT_ACCEPTED { log local0. "Client accepted" log local0. "active clients $::total_active_clients" } when HTTP_REQUEST { log local0. "current active clients $::total_active_clients" ; test cookie presence if {[HTTP::cookie exists "ClientID"]} { log local0. "active user with cookie making http request" set need_cookie 0 set client_id [HTTP::cookie "ClientID"] ; if cookie not present & connection limit not reached, set up client_id } else { if {$::total_active_clients < $::max_active_clients} { log local0. "http request from new client access granted. cookie set." set need_cookie 1 set client_id [format "%08d" [expr { int(100000000 * rand()) }]] log local0. "current active clients $::total_active_clients" log local0. "new active client" incr ::total_active_clients log local0. "current active clients $::total_active_clients" ; otherwise redirect } else { log local0. "http request from non active connection denied" HTTP::redirect "http://www.google.com" incr ::total_active_clients log local0. "attempting to close connection" catch HTTP::close catch TCP::close return } } } when HTTP_RESPONSE { ; insert cookie if needed if {$need_cookie == 1} { HTTP::cookie insert name "ClientID" value $client_id } } when CLIENT_CLOSED { ; decrement current connection counter for this client_id log local0. "current active clients $::total_active_clients" log local0. "client closed" log local0. [IP::remote_addr] if {$::total_active_clients > 0} { log local0. "decremeting active clients" incr ::total_active_clients -1 } log local0. "current active clients $::total_active_clients" }
- DJ_23086
Altocumulus
Given this a little more thought, and I think I was overcomplicating it slightly...when LB_FAILED { pool overflowpool }
- DJ_23086
Altocumulus
Anyone able to confirm the above should/shouldn't work? I'm just a bit unsure that the LB_FAILED event for each VIP would fire in this case?- goutham
Nimbostratus
Could you please share the code if you managed to get that irule working. I am currently working on the same request.
Thanks GR
- hoolio
Cirrostratus
You could test by setting a connection limit on the node to 1, configuring an iRule which logs something in the LB_FAILED event and then make two connections to the VIP.
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