Hi,
I wrote a short iRule to keep persistent connections between clients and certain pool members. The iRule uses “s_id” values as persistence keys from URIs (requests) and HTTP headers (responses). The iRule works as expected, but during load tests I noticed a bunch of duplicate entries in the persistence table.
Here are some snips from “bigpipe persist show all” output:
| Mode universal Value 01e77eb1-2758-4b2e-9224-59e375a64723
| virtual 10.100.190.70:http node 10.100.110.1:http age 836sec
| Mode universal Value 01e77eb1-2758-4b2e-9224-59e375a64723
| virtual 10.100.190.70:http node 10.100.110.1:http age 848sec
| Mode universal Value 028f6aff-e262-43cf-98fe-b46b3ae95c86
| virtual 10.100.190.70:http node 10.100.110.1:http age 736sec
| Mode universal Value 028f6aff-e262-43cf-98fe-b46b3ae95c86
| virtual 10.100.190.70:http node 10.100.110.1:http age 748sec
| Mode universal Value ffdd135d-4e9f-48e3-8dc0-c69f6c88f20c
| virtual 10.100.190.70:http node 10.100.110.2:http age 414sec
| Mode universal Value ffdd135d-4e9f-48e3-8dc0-c69f6c88f20c
| virtual 10.100.190.70:http node 10.100.110.2:http age 426sec
I can see that duplicate persistence entries (with the same value) both point to the same node. That is ok, I guess. Traffic is routed as intended.
My question is why do I see duplicate entries with different timeouts? I made modifications to the iRule just to prevent this, but no luck. This also only happens under heavy load. When testing with few requests / clients, this does not happen.
Here is the iRule. Can anyone explain this behaviour?
when HTTP_REQUEST {
set DEBUG_REQ 1
set MY_SID null
set namevals [split [HTTP::uri] "?&"]
set MATCH 0
split the URI
for {set i 0} {$i < [llength $namevals]} {incr i} {
if a splitted part starts with "s_id", get the data
if { [lindex $namevals $i] starts_with "s_id=" } {
set MY_SID [lindex [split [lindex $namevals $i] "="] 1]
if { "[persist lookup uie $MY_SID]" eq "" } {
if { $DEBUG_REQ eq 1 } { log local0. "(request-sid) Found a s_id in a request that isn't in the persistency table. Ignoring. MY_SID is $MY_SID - [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri] " }
} else {
set MATCH 1
}
}
}
if { $MATCH eq 1 } {
persist uie $MY_SID
if { $DEBUG_REQ eq 1 } { log local0. "(request) MY_SID is $MY_SID - [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri] " }
} else {
pool [LB::server pool]
if { $DEBUG_REQ eq 1 } { log local0. "(request-nosid) MY_SID is $MY_SID - [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri] " }
}
}
when HTTP_RESPONSE {
set DEBUG_RESP 1
if { [HTTP::header exists X-Session-Id] } {
set MY_SID [HTTP::header X-Session-Id]
if { "[persist lookup uie $MY_SID]" eq "" } {
persist add uie $MY_SID 2100
if { $DEBUG_RESP eq 1 } { log local0. "(response) Adding persist: $MY_SID - [IP::server_addr] -> [IP::client_addr] - status: [HTTP::status] - pool info: [LB::server] / [LB::server addr] " }
} else {
if { $DEBUG_RESP eq 1 } { log local0. "(response) s_id $MY_SID already mapped to: [persist lookup uie $MY_SID] - [IP::server_addr] -> [IP::client_addr] - status: [HTTP::status] - pool info: [LB::server] / [LB::server addr] " }
}
} else {
if { $DEBUG_RESP eq 1 } { log local0. "(response-nosid) No Session header in response - [IP::server_addr] -> [IP::client_addr] - status: [HTTP::status] - pool info: [LB::server] / [LB::server addr] " }
}
}
Br, Miro