Forum Discussion
multiple iRules
Could you clarify what you mean by mixed load balancing?
Priority only ensures rules are executed in the preferred order.
- mrgilchenDec 07, 2019
Altostratus
I run 2 scripts.
Each script check LB to get the client IP match with a pool by subnet.
So the 2 scripts are giving me the same results.
I check for client IP.
Script1:
set strSelectedPool [class match -value [IP::client_addr] equals "MEM-Manager-Subnet-To-Pool-Pairs"]
pool $strSelectedPool
Scrip2:
set strSelectedPool [class match -value [IP::client_addr] equals "ORG-Manager-Subnet-To-Pool-Pairs"]
pool $strSelectedPool
In that case when a request comes, it will mix the pools. and get the same result.
- Lee_SutcliffeDec 07, 2019
Nacreous
You can’t have two ‘pool’ commands executing.
You’ll need to add the following to stop iRule processing after the first pool has been selected (assuming an HTTP_REQUEST event
event disbale HTTP_REQUEST
- mrgilchenDec 08, 2019
Altostratus
What will happen to second pool in that case?
- Lee_SutcliffeDec 08, 2019
Nacreous
Nothing - remember the iRules are executed per connection or per HTTP request if you have an HTTP profile and using HTTP_REQUEST event for example.
Connection 1 matches first iRule - second one stops executing. because of 'event disable' command - it will only stop iRule processing for that event, for that connection.
Connection 2 matches second iRule - goes to pool 2
Given you're just selecting pools - why not use a conditional if statement like this? (not tested)
when CLIENT_ACCEPTED { if {[set strSelectedPool [class match -value [IP::client_addr] equals "MEM-Manager-Subnet-To-Pool-Pairs"]]} { pool $strSelectedPool } if {[set strSelectedPool [class match -value [IP::client_addr] equals "ORG-Manager-Subnet-To-Pool-Pairs"]]} { pool $strSelectedPool } }
- mrgilchenDec 08, 2019
Altostratus
I have exactly that code where first "if" is in script 1 and second "if" is in script 2.
I'm not just checking pools, there is a logic on what to do next considering the pool.
But what you are suggesting is having both in 1 script?
- Lee_SutcliffeDec 08, 2019
Nacreous
mate, it's up to you.
Having only seen a snippet of your iRules I suggested putting it in one as it looked simple.
If you have a lot of business logic - separate them.
You have three options
1) Spit your iRules, use priority to control event order and exit the event when you get to the 'pool' command.
2) Use a single iRule and use conditional logic to select the pool from a data group
3) use a combination of the two - preferred option as an if statement can help prevent a TCL error in the event there isn't a match in either data group.
Choice is yours, short of doing the iRule for you and without seeing your entire code there's not much more advice I can give.
- mrgilchenDec 08, 2019
Altostratus
I get you. It's now more clear to me.
btw, what is the difference matching the pool in CLIENT_ACCEPTED vs HTTP_REQUEST
- Lee_SutcliffeDec 08, 2019
Nacreous
CLIENT_ACCEPTED is triggered once after TCP three way hand shake so not ideal if connections are multiplexed.
HTTP_REQUEST triggers per http request such as a GET or POST
- mrgilchenDec 08, 2019
Altostratus
Thanks!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com