Cookie hashing causes HTTP requests that contain the same cookie value to be sent to same real server. When a HTTP request comes into a virtual server, the ServerIron ADX examines the cookie, hashes the content and automatically selects a real server from among those bound to the virtual server based on that hash. The HTTP request, as well as all subsequent HTTP requests that contain that same Cookie header value, go to that real server.
We will use csw and hash-to-bucket mechanism to achieve this objective. First we will search for particular cookie, in example below JSessionID, and then, will hash the value following the string up to a certain length. With hashing, ServerIron logically reduces the Cookie value to a number between 0 – 255 which allows it to send subsequent packets with same cookie to the same real server
csw-rule r1 header cookie pattern “JSessionID=” ! csw-policy p1 match r1 persist offset 0 length 16 persist-to-hash-bucket default forward 1 ! server real RS1 172.16.10.126 port 8080 port 8080 group-id 1 1 ! server real RS2 172.16.10.125 port 8080 port 8080 group-id 1 1 ! server virtual VIP1 172.16.0.31 port http port http csw-policy p1 port http csw bind http RS1 8080 RS2 8080