05-Dec-2022 11:53
Policies and iRules. iRules and policies. Usage can be either/or OR both/and, but where do you draw the lines of operational control? Join Jason at 10:45 pacific time on Thursday, December 8, 2022 to work through a few scenarios.
05-Dec-2022 15:52
Your signature @Kai_Wilke should be good for this session 😁
08-Dec-2022 08:32 - edited 08-Dec-2022 10:45
If you want to join me on camera...here's the guest link to come backstage: https://streamyard.com/8u6x7mreyk
And VSCode live share: https://prod.liveshare.vsengsaas.visualstudio.com/join?57B8EF9A54EBE300681E1CA6DDC6531ABFEB
08-Dec-2022 08:33
yeah! Come on @Kai_Wilke @Daniel_Wolf ?
08-Dec-2022 08:37
No way... i will be the random dude in the chat asking silly questions. 😂
Cheers, Kai
08-Dec-2022 08:39
I'll have live coding from vscode working too, so you can join and write away!
08-Dec-2022 08:42
Never worked with vscode and live coding. Still using iRule editor... 😬
Cheers, Kai
08-Dec-2022 09:19
I'll be using it on the show, you need to come over to the dark side...we have (http) cookies! 🙂
08-Dec-2022 10:18
I have VS code actually installed to write PS scripts (please dont tell). But never used live codings or used it for iRules.
Cheers, Kai
08-Dec-2022 10:25
There seems to be a certain distrust in PowerShell... before I decided that I will do only F5 and nothing else. Precisely speaking, I wrote half a book. My co-author left and it was never published.
08-Dec-2022 13:20
That's a bummer on the book. I know someone who might be interested in picking up the other half if you ever wanted to finish it!
08-Dec-2022 23:38
Oh, that was like 7 years ago. When I had no children and plenty of time... 🙂
I think I would have to start from scratch, PowerShell has changed so much in the past years. And I've hardly used PowerShell since back then.
08-Dec-2022 12:18
I want a cookie!
08-Dec-2022 08:39
Also an important role 😁
08-Dec-2022 08:46
Most lucrative role during a face-to-face F5 Agility. You earn soo many Starbucks voucher...
And making dudes like John Wagnon speechless is priceless anyway... 🤣
Cheers, Kai
08-Dec-2022 09:16
I would join, I will take the role of the random dude asking silly questions. Kai take the role of the shiny dude who actually knows stuff.
Not sure whether my face needs to be on camera...
08-Dec-2022 10:21
Shiny dude is something from the past. Jason just told me to join the Dark side. He promissed Cookies and i love them pretty much...
Cheers, Kai
08-Dec-2022 11:58
the wonky capitalization within, you mean?
08-Dec-2022 12:04
in LTP a header-replace has same problems as [HTTP::header replace] in iRule. If user-agent sends 2 header instances, only one instance gets replaced in the request. For a X-Forwarded-For protection this is obviously not the right way to do it...
Cheers, Kai
08-Dec-2022 14:37
Hi Folks,
for those how are interested knowing the performance difference of LTP vs. iRules.
Passthrough Setup:
The passthrough setup had the purpose to figure out the performance my naked setup to allow comparsion of the "noice"
when CLIENT_ACCEPTED {
set time(Passthrough) [clock clicks]
}
when HTTP_REQUEST {
lappend time(Passthrough) [clock clicks]
eval $static::debug_page
}
Without any LTP or additional iRule code in between CLIENT_ACCEPTED and HTTP_REQUEST it took a minimum of 13 clicks and an average of 83 clicks per HTTP request (after removing 10% slowest/fastes results) .
iRule Setup:
To test the performance of iRules I've added a [switch] statement consisting 50+default hostnames and a pool assigment.
when CLIENT_ACCEPTED {
set time(iRULE_50switch_default) [clock clicks]
}
when HTTP_REQUEST {
switch -exact -- [HTTP::host] {
"www.domain-01.de" { pool www.itacs.de }
"www.domain-02.de" { pool www.itacs.de }
... truncated ...
"www.domain-49.de" { pool www.itacs.de }
"www.domain-50.de" { pool www.itacs.de }
default { pool REST_API }
}
lappend time(LTP_50rules_default) [clock clicks]
eval $static::debug_page
}
The test was triggering the "default" condition of the [switch] (worst case) and it took a minimum of 24 clicks and an average of 102 clicks per HTTP request (after removing 10% slowest/fastes results).
Local Traffic Policy Setup:
To test the performance of Local Traffic Policies I've added a first match LTP policy consisting 50+1 (exist) hostnames and a pool assigment rules.
when CLIENT_ACCEPTED {
set time(LTP_50rules_default) [clock clicks]
}
when HTTP_REQUEST {
lappend time(LTP_50rules_default) [clock clicks]
eval $static::debug_page
}
The test was triggering the "default" condition of the LPT and it took a minimum of 18 clicks and an average of 92 clicks per HTTP request (after removing 10% slowest/fastes results).
Results:
The comparsion of Passthrough vs iRule vs LTP Setup is basically a minimum of 13 / 24 / 18 clicks and an average of 83 / 102 / 92 clicks per HTTP request. LPT is round about twice as fast at parsing 50+1 hostnames and assigning a pool.
So can we all agree that both methods are lightning fast and that LTP still sück because it cant even craft a HTTP response? 🤣
Cheers, Kai
08-Dec-2022 19:05 - edited 08-Dec-2022 19:06
just for giggles, is the iRule switch performance any different if the switch cases are bound since all the pool destinations are the same? Example:
when CLIENT_ACCEPTED {
set time(iRULE_50switch_default) [clock clicks]
}
when HTTP_REQUEST {
switch -exact -- [HTTP::host] {
"www.domain-01.de" -
"www.domain-02.de" -
... truncated ...
"www.domain-49.de" -
"www.domain-50.de" { pool www.itacs.de }
default { pool REST_API }
}
lappend time(LTP_50rules_default) [clock clicks]
eval $static::debug_page
}
similar for the policy, a single condition with all the hosts in the matches any field...
08-Dec-2022 22:29
Hi Jason,
for the [switch] it does basically dont matter if multiple condition trigger the same script or different scripts. The overhead from evaluating 50 strings is the same...
Single Script:
when HTTP_REQUEST {
lappend time(iRule_50rules_single_scripts) [clock clicks]
switch -exact -- [HTTP::host] {
"www.domain-01.de" -
"www.domain-02.de" -
... truncated ...
"www.domain-48.de" -
"www.domain-49.de" -
"www.domain-50.de" { pool www.itacs.de }
default { pool REST_API }
}
lappend time(iRule_50rules_single_scripts) [clock clicks]
eval $static::debug_page
}
Many individual Scripts:
when HTTP_REQUEST {
lappend time(iRule_50rules_single_scripts) [clock clicks]
switch -exact -- [HTTP::host] {
"www.domain-01.de" { pool www.itacs.de }
"www.domain-02.de" { pool www.itacs.de }
... truncated ...
"www.domain-50.de" { pool www.itacs.de }
"www.domain-50.de" { pool www.itacs.de }
default { pool REST_API }
}
lappend time(iRule_50rules_single_scripts) [clock clicks]
eval $static::debug_page
}
But it does matter if you trigger [switch]'s first (see below) or default (see above) conditions....
1st hit:
25th hit:
50th hit:
Old facts remaining the same. The more item in the list and the deeper your have to dig into the list the longer it takes to evaluate it.
Lets see if we can find some better replacements for [switch]...
Using [if]:
when HTTP_REQUEST {
lappend time(iRule_5if_1st_hit) [clock clicks]
if { [HTTP::host] eq "www.domain-01.de" } then { pool www.itacs.de }
elseif { [HTTP::host] eq "www.domain-02.de" } then { pool www.itacs.de }
elseif { [HTTP::host] eq "www.domain-03.de" } then { pool www.itacs.de }
elseif { [HTTP::host] eq "www.domain-04.de" } then { pool www.itacs.de }
elseif { [HTTP::host] eq "www.domain-05.de" } then { pool www.itacs.de }
else { pool REST_API }
lappend time(iRule_5if_1st_hit) [clock clicks]
eval $static::debug_page
}
1st hit [if] is slightly quicker than [switch}, 5th hit [if] is about the same as [switch]. Nothing new about...
[eval] loading a script from static::array() with 1.000.000 bucket entries
when RULE_INIT {
for { set x 1 } { $x < 1000000 } { incr x } {
set my_conditional_scripts(www.domain-${x}.de) { pool www.itacs.de }
}
}
when HTTP_REQUEST {
lappend time(iRule_eval_1million_bucket) [clock clicks]
if { [catch {
eval $my_conditional_scripts([HTTP::host])
}] } then {
pool REST_API
}
lappend time(iRule_eval_1million_bucket) [clock clicks]
eval $static::debug_page
}
Performance in the range of a 50-entry [switch] statemen, not bad. Can LTP handle 1M URLs? And how fast?
Will do some additional LTP tests in the evening. Lets see where LTP limits are...
Cheers, Kai
08-Dec-2022 22:56
Some of this reminds me of an article Joe did years ago to test where the sweet spots were for if/else vs switch vs class matching.
https://community.f5.com/t5/technical-articles/comparing-irule-control-statements/ta-p/282675
09-Dec-2022 00:10
Joe did some great work back then.
The only highly argueable part in his article is the conslusion, that [switch] is overall the best choice across the board.
His article did somehow not included a comparsion with just 1 or 5 items to compare. This is the area where [if] starts to shine. Beyond that scale [switch] will be undoubtedly the better choice.
When I started with iRules i've read Joes article and basically used [switch] everywhere. Took me a while to review my code and migrate back to [if] once I saw test results on TCL boards and did my own tests...
Over the years I've faced a couple guys who stricly followed this article and used also [switch] everywhere.... so it wasnt just me who followed his conclusion 😉
Cheers, Kai
09-Dec-2022 09:13
I think in user group presentations we landed on guidance of if/else for only the simplest solutions, switch to maybe 20, and data-groups for everything else.
09-Dec-2022 10:33 - edited 09-Dec-2022 10:33
Thats a good mix. 👍
Cheers, Kai