Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Irule to select pool in a complicated failover scenario

Kartheek_M
Nimbostratus
Nimbostratus

So long story long...we've an application in PROD and STG environments which has servers setup to handle traffic for 3 services (let us say A,B,C)

 

--------------- ---------------

PROD STG

--------------- ---------------

A_PROD_SRVR_1 A_STG_SRVR_1

A_PROD_SRVR_2 A_STG_SRVR_2

 

B_PROD_SRVR_1 B_STG_SRVR_1

B_PROD_SRVR_2 B_STG_SRVR_2

 

C_PROD_SRVR_1 C_STG_SRVR_1

C_PROD_SRVR_2 C_STG_SRVR_2

 

Set of requirements from the application to work are as follows :

 

1) Incoming PROD traffic for any service (A,B or C) should be load balanced between PROD servers (1 & 2) for that service

 

2) Incoming STG traffic for any service (A,B or C) should be load balanced between PROD servers (1 & 2) for that service

 

3) If both SRVR1 and SRVR2 for any of the services A, B or C are unreachable, then all the incoming PROD traffic for all the services (A and B and C) should be handled by STG servers.

For example, if B_PROD_SRVR_1 and B_PROD_SRVR_2 are down, then the PROD traffic for service A should be handled by A_STG_SRVR_1 and A_STG_SRVR_2 and PROD traffic for service B should be handled by B_STG_SRVR_1 and B_STG_SRVR_2 and PROD traffic for service C should be handled by C_STG_SRVR_1 and C_STG_SRVR_2

 

Also, We're not running multiple services on any server. So we've in total 12 different servers here and ports for each service A,B,C is different to each other

 

I'm completely new to Irules and though I started learning recently, I'm still a long way away from writing a working irule for scenarios like this, hence reaching out to the community for help. Any suggestions or ideas is much appreciated!

1 REPLY 1

I initially thought why not go with Priority Group method for this. But your 3rd requirement makes it bit complicated. We have to play around with monitors for that. So I think the easy approach would be to go with an Irule.

Also to make this work, create your 3 A, B, C VIP's and map A, B, C as default pools.

Pool name - A_PROD_POOL (Servers - A_PROD_SRVR_1  & A_PROD_SRVR_2)

Pool name - A_STG_POOL (Servers - A_STG_SRVR_1 & A_STG_SRVR_2)

Pool name - B_PROD_POOL (Servers - B_PROD_SRVR_1  & B_PROD_SRVR_2)

Pool name - B_STG_POOL (Servers - B_STG_SRVR_1 & B_STG_SRVR_2)

Pool name - C_PROD_POOL (Servers - C_PROD_SRVR_1  & C_PROD_SRVR_2)

Pool name - C_STG_POOL (Servers - C_STG_SRVR_1 & C_STG_SRVR_2)

ltm rule test {
when CLIENT_ACCEPTED {
set poolname [findstr [LB::server pool] "" 8 ]
#The output of poolname will be A_PROD_POOL
set STG_POOL [string map {PROD STG} $poolname]
#The output of STG_POOL will be A_STG_POOL
}
 
when HTTP_REQUEST {
if { ([active_members A_PROD_POOL] > 0) && ([active_members B_PROD_POOL] > 0) && ([active_members C_PROD_POOL] > 0)} {
#When all services are Up, the traffic will goto default pool.
pool $poolname
} else {
#When any of services are down, the traffic will goto corresponding STAGING pool.
pool $STG_POOL
}
}

You can apply this Irule to all 3 vips, because its dynamic.