Forum Discussion

Thorsten_Herrma's avatar
Thorsten_Herrma
Icon for Nimbostratus rankNimbostratus
Mar 08, 2016

Failover for Application Server nodes

Hello,

 

I am new to this forum and I have a question about failover and application server/tomcat.

 

Scenario:

 

We have a Cluster with 4 nodes and something like 100 Requests per seconds per node. The Load is balanced between the Application Server and cookie-persistence enabled. The Application Server have Session Replication between the 4 nodes configured. Now one Node goes down and I would like to redirect the Connection bounded to the shutdown/crushed node with out showing the User an 404/500 Status or loosing the connection.

 

Unfourtnately the Healthmonitor is to slow to detect the shutdown of the host. Is there a possibility to lookup the User Connection and redirect it when it times out or break to a specific host.

 

With Kind Regards

 

2 Replies

  • Hi Domunda,

    It would be possible to execute the

    HTTP::retry
    command, to replay the HTTP request to a different node, in the case the initial node would respond with 404/5xx error codes.

    To help you further it would be important to know if you access the application by using GET-only requests or if you need retry support also for POST requests?

    In addition to that it would be important to know if your F5 has some spare capacity left to handle the per-request health monitoring?

    Cheers, Kai

  • Hi Domunda,

    did some quick additions to an

    HTTP::retry
    iRule which I've written last week. The iRule will capture GET and POST request and replay the request if the server responds with 404 or 5xx.

    when RULE_INIT { 
        set static::max_retry_count 3
        set static::persistence_cookie "mycookie"
        set static::max_content_length 1048576
    } 
    when CLIENT_ACCEPTED { 
        set retry_count 0
    } 
    when HTTP_REQUEST {
        if { $retry_count == 0 } then {
            log local0.debug "Saving the initial HTTP request..." 
            set http_request [HTTP::request]
            if { [HTTP::method] equals "POST" } then {
                log local0.debug "POST request detected. Collecting the POST data..." 
                if { ( [HTTP::header value "Content-Length"] ne "" ) and ( [HTTP::header value "Content-Length"] < $static::max_content_length ) } then { 
                    HTTP::collect [HTTP::header value "Content-Length"] 
                } else { 
                    HTTP::collect $static::max_content_length 
                }
            }
        } else {
            log local0.debug "Removing the persistence cookie from replayed request..." 
            HTTP::cookie remove $static::persistence_cookie
        }
    }
    when HTTP_REQUEST_DATA {
        if { $retry_count == 0 } then {
            log local0.debug "Appending the collected POST data to the request. And releasing the request..." 
            append http_request [HTTP::payload]
            HTTP::release
            log local0.debug "Post Request [b64encode $http_request]"
        }
    }
    when LB_SELECTED { 
        if { $retry_count > 0 } then {
            if { $last_node eq [LB::server addr] } then {
                log local0.debug "Wrong Selection: member [LB::server addr]:[LB::server port] from pool [LB::server pool] (retry $retry_count)" 
                LB::reselect
            } else {
                log local0. "Good Selection: member [LB::server addr]:[LB::server port] from pool [LB::server pool] (retry $retry_count)" 
            }
        }
    } 
    when HTTP_RESPONSE { 
        if { (( [HTTP::status] equals 404 ) or ( [HTTP::status] starts_with 5 )) and ( $retry_count < $static::max_retry_count ) } then {
            log local0.debug "[HTTP::status] from [LB::server addr]:[LB::server port], trying another [LB::server pool] member (retry $retry_count)"
            set last_node [LB::server addr]
            incr retry_count
            HTTP::retry $http_request 
            return
        }
        set retry_count 0
        set http_request ""
    }
    

    Note: Remove or comment the

    [log]
    lines once tested and verified the iRule.

    Cheers, Kai