For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

vinceKahn_97184's avatar
vinceKahn_97184
Historic F5 Account
Jan 22, 2010

CARP Hash Persistence

I couldn't find anything in the docs on how to set this up. I've done what I think is correct but am surprised to see when I refresh a request it hits all three of my proxies.

 

 

I've created a Hash Persistence profile with CARP enabled. I created the following iRule and applied it to the new Hash profile.

 

 

when HTTP_REQUEST {

 

persist hash [HTTP::uri]

 

}

 

 

I then added the new persistence profile to my virtual server load balancing my proxies. I tested hitting "http://www.whatismyip.com/". With each refresh I see one of my three proxy IP's. With the older election hash iRule I'd always see only one of the three.

 

 

Did I set this up right? Are the results correct?

 

 

Thanks,

 

Vince

 

6 Replies

  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    Well, your iRule is selecting regular hash persistence, so it won't use the CARP-like algorithm, no. You either need to use "persist carp [HTTP::uri]" if you're on 10.1, or you need to do your text selection entirely through the persistence profile (start/end pattern, or offset/length). For doing it off uri, since HTTP requests look like " ", you could probably do a start and end pattern of a single space, but I haven't tested that.
  • vinceKahn_97184's avatar
    vinceKahn_97184
    Historic F5 Account
    That makes sense but what's the point of selecting "CARP" in the persistence profile? If I'm doing it in the iRule then why have bother with the persistence profile?
  • vinceKahn_97184's avatar
    vinceKahn_97184
    Historic F5 Account
    I've done some additional testing and can't account for the results. I removed the persistence profile and created a simple irule:

     

     

    when HTTP_REQUEST {

     

    persist carp [HTTP::uri]

     

    }

     

     

    With this I see the same results. My requests for http://www.whatismyip.com are spread across all three servers with each refresh. Shouldn't CARP force the identical request to just one of my proxy nodes? I also tried "HTTP::host". I expected the hash to always direct me to one proxy. It did not. If same requests are randomly hitting all three servers in my pool what's the point of using CARP?
  • vinceKahn_97184's avatar
    vinceKahn_97184
    Historic F5 Account
    For anyone that's interested I believe this is resolved. A few points made clear by F5 support.

     

     

    1. Needed to enable oneConnect for my proxy vip

     

    2. Hash persistence profile, set timeout to 0

     

    3. iRule needed to use "persist hash" not "persist carp"

     

     

    This is best practice.
  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    As for OneConnect, yeah, for multiple requests over the same connection, you'll want that. It's so first-nature to me I never suspect it isn't there.

     

     

    As for the other two points, that sounds really wrong to me. I'm sure your persistence is working with that config, but I'm also 99.9% sure it won't be using the CARP-like algorithm. I will run some tests and post back what I find.
  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    Wow, this was quite the investigation. Long story short, your config will work, and will use the CARP-like algorithm. What's happening is that the iRule is specifying default hash persistence, but your hash profile setting of the CARP-like algorithm is overriding that (the override does not happen in the vice versa case).

    I also did a test with a basic iRule:

     
        when HTTP_REQUEST { 
          persist carp [HTTP::uri] 
        } 
     

    and as I expected, got identical results, so I'm not sure why that didn't work for you.