Forum Discussion

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

uncommon loadbalancing requirement

Hi,

 

I don't know how to solve a specific loadbalancing-problem. The situation is:

 

  • Servers A, B and C (Web-Servers)
  • A and B can handle all the web requests/respond to all urls (e.g. /company/test1, /company/test2, /company/test3)
  • C is a test-system that answers all the requests, but is only connected to the production-system with /company/test1 and to the test-system with /company/test2 and /test3
  • C should only be used when A and B are down.

This configuration does not really make sense to me, nevertheless I have to handle it. So, how do I configure the loadbalancing?

 

First, I would use priority-groups and assign priority 10 to Servers A and B, and priority 5 to Server c. So, Server C is only used when A and B are down/disabled. But how can I make sure, that only /company/test1 is forwarded to Server C?

 

Thanks in advance

 

Regards,

 

Thorsten

 

10 Replies

  • Hi Thorsten,

    You're right, you have to use priority groups.

    Regarding your needs on checking URI, here is an iRule :

    when HTTP_REQUEST { 
        if { [HTTP::uri] starts_with "/company/test1" and [LB::server addr] equals "Your_member_IP"}{   
            return;
        }
        else {
            discard;
        }
    }
    
    • fat_138651's avatar
      fat_138651
      Icon for Nimbostratus rankNimbostratus
      Hi Thomas, I have just started using F5-Loadbalancers, so this will be my first contact with iRules. But this iRule seems to be just the solution I need. Thanks, Thorsten
  • Hi Thorsten,

    You're right, you have to use priority groups.

    Regarding your needs on checking URI, here is an iRule :

    when HTTP_REQUEST { 
        if { [HTTP::uri] starts_with "/company/test1" and [LB::server addr] equals "Your_member_IP"}{   
            return;
        }
        else {
            discard;
        }
    }
    
    • fat_138651's avatar
      fat_138651
      Icon for Nimbostratus rankNimbostratus
      Hi Thomas, I have just started using F5-Loadbalancers, so this will be my first contact with iRules. But this iRule seems to be just the solution I need. Thanks, Thorsten
  • Hi again,

    I had to change the iRule a little bit to fit my needs, but unfortunately it doesn't work. Thats my iRule:

    when HTTP_REQUEST { 
    if { (not [HTTP::uri] contains "/test1") and [LB::server addr] equals "10.10.10.3"}{   
        discard;
        }
    }
    

    But my Browser only shows the index.html if the iRule is not activated. Did I mess sth. up?

    Regards,

    Thorsten

  • Hi Thorsten,

    I made a mistake and I didn't see it before... I'm sorry 😕

    Here is the good event matching your needs :

    when LB_SELECTED { 
    if { (not [HTTP::uri] contains "/test1") and [LB::server addr] equals "10.10.10.3"}{   
        discard;
        }
    }
    
  • Hi Thomas,

    no problem :). I'm happy that you took time to think about my problem and even if the iRule was not working, you pushed me in the right direction. I am just playing around with the iRule and figured out, that is does not work because [LB:server addr] has no value.

    Regarding your latest suggestion, I am not sure if the event LB_SELECTED will work for the [HTTP:uri] command. I'm afraid it will work for [LB:server add] but not for [HTTP:uri] because the reference of [HTTP:uri] says:

    Valid Events:
    CACHE_REQUEST, CACHE_RESPONSE, HTTP_CLASS_FAILED, HTTP_CLASS_SELECTED,  HTTP_REQUEST, HTTP_REQUEST_DATA, HTTP_REQUEST_SEND, REWRITE_REQUEST_DONE, SERVER_CONNECTED
    

    What can I do? Do I have to check two events? Is that possible?

    Thanks, Thorsten

    • Thomas_Gobet's avatar
      Thomas_Gobet
      Icon for Nimbostratus rankNimbostratus
      Yes you can check two events in a same iRule. With that you define a flag if your first event is OK and you'll be able to know in LB_SELECTED if everything was OK before.
  • So, I am not totally through with testing, but Thomas' solution seems to work. Can anyone explain the sense of "Valid events" to me?

     

    Regard,

     

    Thorsten

     

  • Thanks a lot Thomas. I went through the web based training for iRules, but thats just good to get a rough overview. But today I learned many things about troubleshooting iRules :-)