Options

TCS Smart LB to caches

mischamischa Member
Posted by mischa

Code:

when RULE_INIT { set :: CACHEURLS [list "youtube.com" "googlevideo.com" "google.com" "facebook.com" "google.de" "apple.com" "fbcdn.net" "clipfish.de" "googlesyndication.com" "337.com" "aol.com" "bigfishgames.com" "bigpoint.net" "bild.de" "chip.de" "doubleclick.net" "comput erbild.de" "dailymotion.com" "dreamies.de" "ea.com" "ebay.de" "friendscout24.de" "gmx.net" "immobilienscout24.de" "jappy.de" "jappy.tv" "kicker.de" "last.fm" "live.com" "microsoft.com" "msn.com" "myvideo.de" "mzstatic.com" "n- tv.de" "pop6.com" "rtl.de" "soundcloud.com" "spiegel.de" "streamfarm.net" "twitter.com" "ytimg.com" "mdn.net" "whatismyipaddress.com" "whatismyip.com" "wer-kennt-wen.de" "wooga.com" "yahoo.com" "zynga.com"] set :: URLS2SG [list "1_2" "1_2" "1_2" "1_2" "1_2" "1_2" "1_2" "1_2" "1_2" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" "all" " all" "all" "all" "all" "all" "all" "all" "all" "3_4" ] } when HTTP_REQUEST { set HOST [string tolower [HTTP::host]] set URI [string tolower [HTTP::uri]] set HOST_LIST [split $HOST "."] set HOST [lindex $HOST_LIST [expr [llength $HOST_LIST]-2]].[lindex $HOST_LIST [expr [llength $HOST_LIST]-1]] set SEARCH_INDEX [lsearch -exact $::CACHEURLS $HOST] if { $SEARCH_INDEX != -1 } { set ServiceGroup [lindex $::URLS2SG $SEARCH_INDEX] log "ServiceGroup $ServiceGroup" switch $ServiceGroup { "1_2" { pool vxa1_vxa2 } "all" { pool vxa_service-group } } } else { log "not whitelisted; pool Gateway" pool Gateway } }

Comments

  • Options
    edited February 2014
    Posted by ddesmidt

    That's a great example and thanks for sharing it with the community.

    This aFleX will just work perfectly, now we can do a couple of changes to optimize it (limit the AX CPU usage from that aFleX).
    . "array" is more efficient than "list" when you try to look for an entry in a list
    . creation of variables takes some CPU resources + memory (not a lot a all but still) => avoid unnecessary variables

    The new aFleX with those changes looks like that:

    Code:

    when RULE_INIT { array set :: CACHEURLS [list "youtube.com" "vxa1_vxa2" "googlevideo.com" "vxa1_vxa2" "google.com" "vxa3_vxa4" "google.de" "vxa3_vxa4" "facebook.com" "vxa1_vxa2" "apple.com" "vxa3_vxa4" "fbcdn.net" "vxa1_vxa2" "clipfish.de" "vxa3_vxa4" "googlesyndication.com" "vxa 1_vxa2" "337.com" "vxa-service-group" "aol.com" "vxa-service-group" "bigfishgames.com" "vxa-service-group" "bigpoint.net" "vxa-service-group" "bild.de" "vxa-service-group" "chip.de" "vxa-service-group" "doubleclick.net" "vxa-service- group" "computerbild.de" "vxa-service-group" "dailymotion.com" "vxa-service-group" "dreamies.de" "vxa-service-group" "ea.com" "vxa-service-group" "ebay.de" "vxa-service-group" "friendscout24.de" "vxa-service-group" "gmx.net" "vxa-service- group" "immobilienscout24.de" "vxa-service-group" "jappy.de" "vxa-service-group" "jappy.tv" "vxa-service-group" "kicker.de" "vxa-service-group" "last.fm" "vxa-service-group" "live.com" "vxa-service-group" "microsoft.com" "vxa-service- group" "msn.com" "vxa-service-group" "myvideo.de" "vxa-service-group" "mzstatic.com" "vxa-service-group" "n-tv.de" "vxa-service-group" "pop6.com" "vxa-service-group" "rtl.de" "vxa-service-group" "soundcloud.com" "vxa-service-group" "spiegel.de" "vxa- service-group" "streamfarm.net" "vxa-service-group" "twitter.com" "vxa-service-group" "ytimg.com" "vxa-service-group" "mdn.net" "vxa-service-group" "whatismyipaddress.com" "vxa-service-group" "whatismyip.com" "vxa-service-group" "wer-kennt- wen.de" "vxa-service-group" "wooga.com" "vxa-service-group" "yahoo.com" "vxa-service-group" "zynga.com" "vxa-service-group"] } when HTTP_REQUEST { set HOST [string tolower [HTTP::host]] set URI [string tolower [HTTP::uri]] set HOST_LIST [split $HOST "."] set HOST [lindex $HOST_LIST [expr [llength $HOST_LIST]-2]].[lindex $HOST_LIST [expr [llength $HOST_LIST]-1]] if { [info exists ::CACHEURLS($HOST)] } { #log "ServiceGroup $::CACHEURLS($HOST)" pool $::CACHEURLS($HOST) } else { #log "not whitelisted; pool Gateway" pool Gateway } }
  • Options
    mleomleo Member
    edited February 2014
    1. Just curious what the used of this script?
    2. Should this apply to VIP or the Wildcard?
Sign In or Register to comment.