Forum Discussion

cokeefe28_17139's avatar
cokeefe28_17139
Icon for Nimbostratus rankNimbostratus
Jun 09, 2009

Load Balance PERSISTENT connection based on HTTP::Method

I have an issue where a persistent connection is being made to a VIP. I need to LB across 5 nodes in a pool. The only way that I think that this can be done is by LB based on each POST method that is being made in the socket.

 

 

Need help writing an iRule that watches for HTTP::method equals "POST" and LB from there.

2 Replies

  • There are a couple of possibilities on this.

     

     

    Couple of questions first though;

     

    1. Do you ONLY need to be sticky on POSTs, or is it OK to be sticky for GET's (and possibly others) as well?

     

    2. Will a single source IP address (client) ever create more than a single persistent connection to the virtual server?

     

    3. Does the client understand cookies?

     

    4. Is there something the application is using to identify a particular client or track state (e.g. JSESSIONID?)

     

     

    If you don't care about the GETs..

     

    ... and If the clients understand cookies, you don't even need an irule really - just create the virtual server they are using and set the persistence method to cookie.

     

    ... and If a client will only make ONE persistent connection to the VS, just use a source_addr persistence method.

     

    ... and If the backend app/web service the client is exchangin ginformation with uses something like a JSESSIONID variable set in a header, setup a universal persistence method based on that header value.

     

     

    OR if you DO care abou the Gets...

     

    .. everything else still applies, but you will need an irule then. A simple one would be;

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::method] equals "POST" } {

     

    persist source_addr [IP::client_addr]:[TCP::client_port]

     

    }

     

    } else {

     

    persist none

     

    }

     

     

     

     

    For a source_addr based affinity. Just switch up that "persist src_addr blah" line to "persist universal" or "cookie" or whatever you need it to do.

     

     

    HTH.
  • You cannot use persist source $ip:$port. The parameters that persist source accept are the subnet mask and a timeout in seconds. You could use persist uie for this though.

     

     

    If the poster is trying to use persistence, cookie insert persistence would be simple and make sense. However, it sounds like the issue is that all requests over the same client to VIP TCP connection are being sent to the same server. If the poster wants to ensure these are all load balanced, they can add a OneConnect profile to the virtual server. For more info, check the OneConnect page (Click here).

     

     

     

    OneConnect with HTTP

     

     

    Without OneConnect enabled, persistence data is examined only in the first request of a Keep-Alive connection, so if multiple requests are sent on the same clientside Keep-Alive connection, LTM will persist them all to the same destination as the first unless a OneConnect profile is applied (even if logic contained in an iRule dictates otherwise).

     

     

     

     

    Aaron