Forum Discussion

U_franco_117956's avatar
U_franco_117956
Icon for Nimbostratus rankNimbostratus
Mar 20, 2014

HTTP redirect if connections per pool member exceed a threshold with tables

Hi.

I´m taking a view to a lot of devcentral documents, and tables are getting me crazy.

I´m interested to get the following behavior. We want to limit the number of connections to our load balanced severs to 500 TCP connections in one of our vservers. If TCP connections per pool member reach that threshold (all of them are owning 500 TCP connections), an HTTP redirect to sorry server has to be send to client.

I think I could use one irule like this to limit the number of TCP connections per pool member because our system is CMP:

    when CLIENT_ACCEPTED {
    set key "[IP::client_addr]:[TCP::client_port]"
}

when LB_SELECTED {
    set tbl "connlimit:[LB::server]"
    table set -subtable $tbl $key "ignored" 180    
    if { [table keys -subtable $tbl -count] > 5 } {
        table delete -subtable $tbl $key
        event CLIENT_CLOSED disable
        reject
    } else {
        set timer [after 60000 -periodic { table lookup -subtable $tbl $key }]
    }
}

when CLIENT_CLOSED {
    after cancel $timer
    table delete -subtable $tbl $key
}

The question is, i don´t know how to proceed with HTTP redirection if this irule is managed when HTTP_REQUEST event is not launched.

Have i to use this irule to control TCP connection limit per pool member?? How could I manage HTTP redirection if TCP connection limit is managed before to HTTP Request??

Thanks.