Forum Discussion
j-boelhouwer_11
Nimbostratus
Hi Kai,
Thanks for your ideas.
Using the hash election there is no need to store the information in the memory since there will not be that many http requests hitting the LTM. It is only the first HTTP request a client makes. Consequent requests as derived from the m3u8 playlist are made to the edge server directly. So If there are say 20.000 clients in 1 hour requesting the initial m3u8 playlist then the iRule will be fired only 5.4 times per second on average (if the requests are evenly spread out) I have seen similar iRule executions well above 1000 tps. For now I have 2 edge nodes and the following iRule. For each request
Election Hash iRule
Version 1.0 Jan 5th 2016
MD5 calculation of Server + URI
Rule selects Server that scores highest
S = Current high score
N = Node being evaluated
W = Winning node
when HTTP_REQUEST {
if {[active_members -list pool_edge_nodes] > 0 } {
if { (([HTTP::method] eq "GET") && ([HTTP::uri] contains ".m3u8")) } {
Election Randomizer
Using md5 function + http::uri to generate a score. The highest wins.
set S ""
set R ""
foreach N [active_members -list pool_edge_nodes] {
if { [md5 $N[HTTP::uri]] > $S } {
set S [md5 $N[HTTP::uri]]
set W $N
}
}
log "winning server: $W"
Generate redirect
set edgeip [lindex $W 0]
set url "http://$edgeip[HTTP::uri]"
Send Redirect message
HTTP::redirect "$url"
log "[IP::client_addr] - Redirected to $url"
} else {
Send Service Unavailable message
HTTP::respond 503
log "[IP::client_addr] - Not redirected, no edge node available"
}
} else {
Send Service Unavailable message
HTTP::respond 404
log "[IP::client_addr] - Not redirected, not a valid request"
}
}
Thanks,
Jeroen
Kai_Wilke
Jan 05, 2016MVP
As i said in my last comment a stateless solution based on hashes/checksums should be alway prefered if possible.
I also don't believe that 5,4 RPS would have a noticable impact on your box. But if performance would become a problem in the future, then fell free to come back to devcentral, so that we could optimize your code a little bit. On the first sight your rule has the potential to save some cycles... ;-)
Cheers, Kai