We would like to setup up two nodes in a pool as follows.
All traffic goes to node 1 until there there are 500 connections.
After that traffic goes to node 2 which is a site that just says try again later.
Once a user gets to node 1, we want them to stay there.
Once node 1 clears up a bit, new users get back to node 1.
This is a legacy site and load balancing is not an option. It is running a black box piece of software so getting into its bowels and having it tell uers to come back later is not an option either.
Thanks in advance.
Try this:
when RULE_INIT {
set ::MaxConn 500
set ::CurConn 0
set ::RejectList [list / .html .htm .asp .pl ]
}
when CLIENT_ACCEPTED {
incr ::CurConn
}
when CLIENT_CLOSED {
incr ::CurConn -1
}
when HTTP_REQUEST {
if {
($::CurConn > $::MaxConn) and \
([matchclass [HTTP::path] ends_with $::RejectList]) \
} {
HTTP::respond 200 content "
Please Try again later
Please Try again later
"
drop
}
}
The iRule will only block html document and still allow non-html document (eg. image/flash/video).
It’s using global variable which means it doesn’t work perfectly in CMP platform (1600, 3600, 8400, 8800 and Viprion). As a ‘workaround’, you divide MaxConn with number of tmm process in yous system (eg. ps | grep npus). Statistic Profile might be better in CMP platform.
Modify it according to your environment.
Thanks Humphrey, this is great. I’m sure the user is going to ask about a better “come back late page, branded w/ the graphics of the site, etc.” Is there a way to redirect to another node?
Also what defines a connection vs. a session. They will get grumpy if users already in get redirected. My experience on the Microsoft IIS side is connections even SSL break pretty regularly and are re-established within a user “session”. Is that the same for connections at the LTM level?
Sorry for the follow-up questions.