For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Bill_Guo_210985's avatar
Bill_Guo_210985
Icon for Nimbostratus rankNimbostratus
Aug 16, 2015

how to use irule to achieve the complicated load balancing requirement (url contents, cookies for site stickiness)

The application is pointed to one vip with serveral url contents. These url contents are categorized to 2 classes (Content A and content B). Content A is load balanced in the pool-a (spanned at Site 1 and Site 2). Content B is load balanced in pool-b-site1 and pool-b-site2 based on its cookie A value (when accessing contentA, cookie A is insert for presistence). The client always accesses content A first. Then goes to content B.

 

The following is the load balancing logic we would like to achieve. Step 1, url content check. if it is content A, then go to pool-a (using cookie insert persistence, cookie name A). if it is content B, then go to step 2.

 

Step2, check the value of the cookie A to get the site stickiness. if cookie A's value is pointed to a site1 backend server, then go to pool-b-site1 (using cookie insert persistence, cookie name B) if cookie A's value is pointed to a site2 backend server, then go to pool-b-site2 (using cookie insert persistence, cookie name B)

 

Can I use irule to achieve that? I have never written irule before, any helpful information related above load balancing is appreciated.

 

Thanks in advance.

 

2 Replies

  • David_Larsen_23's avatar
    David_Larsen_23
    Historic F5 Account
    This might get you started in the right direction. From here you will have to figure out how to set the persistence to follow the cookie value. That shouldn't be too hard: {{ when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "contenta" { pool A HTTP::header insert CookieA [LB::server] } "contentb" { set mycookie {[HTTP::cookie CookieA]} if [HTTP::cookie CookieA] { switch -glob $mycookie { "site1" { pool poolB-site1 HTTP::header insert CookieB [LB::server] HTTP::header remove CookieA } "site2" { pool poolB-site2 HTTP::header insert CookieB [LB::server] HTTP::header remove CookieA } } } } } } }}