Forum Discussion
About iRule
- Dec 13, 2022
Hi Michaelyang,
the iRule triggers on each TCP connection attempt a code, which:
- Checks if [IP::protocol] say that the protocol used is TCP (ID 6)
- It would then create a [list] based on "Client_IP VS_IP VS_Port TCP_ID"
- It would then sort the list in an increasing order
- It would then concatenate the list with "_" (basically a [join "x y" "_"] but he used [string map])
- It will then use the concatenated string as input for CARP based load balaing.
- Done
Slightly over engineered if you ask me. CARP hashes the input anyway, so you basically just need entrophy. Sorting something, and adding fixed values (like VS IP, Port and TCP Protocol) wont increase the entrophy of the resulting string. So the iRule below would probaly easier to unterstand and doing exactly the same task...
when CLIENT_ACCEPTED { if { [IP::protocol] == 6 } then { persist carp [IP::client_addr] } }
What it finally does, it makes sure that whenever ClientA connects to your VS, then the VS will forward the ClientA always to the same pool member (lets say MemberX) based on an internal carp based hash algorythm. If MemberX will be marked offline, then carp will elect a new destination based on the remaining members (lets say MemberY). If MemberX comes back online, then ClientA will automatically fallback to MemberX...
Note: Why your predecessor checks for Protocol ID = 6 at the beginning of the script probably remains secret. The information is somehow lost... 😉
Cheers, Kai
Hi Michaelyang,
the iRule triggers on each TCP connection attempt a code, which:
- Checks if [IP::protocol] say that the protocol used is TCP (ID 6)
- It would then create a [list] based on "Client_IP VS_IP VS_Port TCP_ID"
- It would then sort the list in an increasing order
- It would then concatenate the list with "_" (basically a [join "x y" "_"] but he used [string map])
- It will then use the concatenated string as input for CARP based load balaing.
- Done
Slightly over engineered if you ask me. CARP hashes the input anyway, so you basically just need entrophy. Sorting something, and adding fixed values (like VS IP, Port and TCP Protocol) wont increase the entrophy of the resulting string. So the iRule below would probaly easier to unterstand and doing exactly the same task...
when CLIENT_ACCEPTED {
if { [IP::protocol] == 6 } then {
persist carp [IP::client_addr]
}
}
What it finally does, it makes sure that whenever ClientA connects to your VS, then the VS will forward the ClientA always to the same pool member (lets say MemberX) based on an internal carp based hash algorythm. If MemberX will be marked offline, then carp will elect a new destination based on the remaining members (lets say MemberY). If MemberX comes back online, then ClientA will automatically fallback to MemberX...
Note: Why your predecessor checks for Protocol ID = 6 at the beginning of the script probably remains secret. The information is somehow lost... 😉
Cheers, Kai
- MichaelyangDec 14, 2022Cirrostratus
Hi Kai_Wike,
Thanks for the explanation
I have learned a lotThank you
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