DCC Forum
A by-request forum where viewers may engage with show hosts - before, during, and after LiveStreams.
cancel
Showing results for 
Search instead for 
Did you mean: 

Coding Live: Policies & iRules - Dec 8, 2022

JRahm
Community Manager
Community Manager

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.

 

29 REPLIES 29

Kai_Wilke
MVP
MVP

😬

Cheers, Kai


iRule can do… 😉

buulam
Community Manager
Community Manager

Your signature @Kai_Wilke should be good for this session 😁

~~~~~~~~~~~~~~~~~~
@buulam / YouTube.com/DevCentral

JRahm
Community Manager
Community Manager

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

buulam
Community Manager
Community Manager

yeah! Come on @Kai_Wilke @Daniel_Wolf  ?

~~~~~~~~~~~~~~~~~~
@buulam / YouTube.com/DevCentral

No way... i will be the random dude in the chat asking silly questions. 😂

Cheers, Kai 


iRule can do… 😉

JRahm
Community Manager
Community Manager

I'll have live coding from vscode working too, so you can join and write away!

Never worked with vscode and live coding. Still using iRule editor... 😬

Cheers, Kai

 


iRule can do… 😉

JRahm
Community Manager
Community Manager

I'll be using it on the show, you need to come over to the dark side...we have (http) cookies! 🙂

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


iRule can do… 😉

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.

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!

~~~~~~~~~~~~~~~~~~
@buulam / YouTube.com/DevCentral

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.

I want a cookie!

buulam
Community Manager
Community Manager

Also an important role 😁

~~~~~~~~~~~~~~~~~~
@buulam / YouTube.com/DevCentral

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


iRule can do… 😉

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...

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 

 


iRule can do… 😉

Kai_Wilke
MVP
MVP

Who catches the flaw in this X-Forwarded-For protection Jason just has shown us?

Kai_Wilke_0-1670527598430.png

Cheers, Kai


iRule can do… 😉

JRahm
Community Manager
Community Manager

the wonky capitalization within, you mean?

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


iRule can do… 😉

Kai_Wilke
MVP
MVP

Many thanks for the session Jason. I pretty much enjoyed to see what is not possible with LTP... 🤣 

Cheers, Kai


iRule can do… 😉

Kai_Wilke
MVP
MVP

And many thanks for showing us VS code with the BigIP plugin. I will definitely give it a try and see if I get comfortable with it.

Cheers, Kai


iRule can do… 😉

Kai_Wilke
MVP
MVP

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
}

 Kai_Wilke_0-1670536181062.png

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
	
}

Kai_Wilke_3-1670537290780.png

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
}

Kai_Wilke_4-1670538333199.png

Kai_Wilke_5-1670538546737.png

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

 


iRule can do… 😉

JRahm
Community Manager
Community Manager

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...

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
}

Kai_Wilke_0-1670562799782.png

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
}

Kai_Wilke_1-1670562889270.png

But it does matter if you trigger [switch]'s first (see below) or default (see above) conditions....

1st hit:

Kai_Wilke_5-1670564658279.png

25th hit:

Kai_Wilke_6-1670564709025.png

50th hit:

Kai_Wilke_7-1670564766015.png

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
}

Kai_Wilke_9-1670565688414.pngKai_Wilke_10-1670565820396.png

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
}

Kai_Wilke_12-1670567235763.png

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 


iRule can do… 😉

JRahm
Community Manager
Community Manager

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

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


iRule can do… 😉

JRahm
Community Manager
Community Manager

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.

Thats a good mix. 👍

Cheers, Kai


iRule can do… 😉