Controlling session persistenceSession persistence ties the requests from one client (ie, in one 'session') to the same back-end server node. It defeats the intelligence of the load-balancing algorithm, which tries to select the fastest, most available node for each request! In a web session, often it's only necessary to tie some requests to the same server node. For example, you may want to tie requests that begin "/servlet" to a server node, but let ZXTM be free to load-balance all other requests (images, static content) as appropriate. Configure a session persistence class with the desired configuration for your
if( string.startswith( http.getPath(), "/servlet" ) ) {
connection.setPersistenceClass( "servlet persistence" );
}
Owen Garrett
[Zeus Dev Team] 01 July 2005
Comments:This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Comment from:
Graham Moore [Zeus Systems Engineering]
You may want to tie the requests from one client to the same back-end node using data from the request body. First you need to know what piece of data is always present in every request (ie, a username). You can use the following TrafficScipt rule on a test system to write the data in the request body to the log.
log.info( string.append( " Client", request.getResponseIP(), " -- Body", http.getBody() ) );For each request that arrives, this rule will log the client IP Address and request body information. You can now examine the logfiles to identify a suitable field to use for session persistence. In this example we are using the username that follows a tag in the request body data. We can now disable the above rule and create a new rule to perform the session persistence based on the username.
$body = http.getBody();
# Extract username.
$match = string.regexmatch( $body, "(.*)", "i" );
if( $match ) {
$username = $1;
connection.setPersistenceKey( $username );
$message = "Username = " . $username;
} else {
$message = "No username";
}
log.info( $message );
All you need to do now is create a session persistence class called "Universal" and select the persistence type "Universal Session Persistence".
Comment from:
Chris Buckley [Visitor]
· http://www.cjbuckley.net/
To append to this, on my site i have three webserver pools. However, certain requests must always go to one specific node. TrafficScript easily allows me to perform this:
$path = http.getpath();
$host = http.getHostHeader();
if( string.contains( $path, "ids" ) ) {
connection.setPersistenceNode ( "web1:80" );
}else if( string.contains( $path, "awstat" ) ) {
connection.setPersistenceNode ( "web2:80" );
}else if( string.contains( $path, "mailscanner" ) ) {
connection.setPersistenceNode ( "web2:80" );
}else if( string.contains( $host, "rt" ) ) {
connection.setPersistenceNode ( "web1:80" );
}else if( string.contains( $host, "webmail" ) ) {
connection.setPersistenceNode ( "web3:80" );
}
Remember to set your persistence across your pool as 'Named Node'. ZXTM is now free to load balance *all* requests bar the ones i specifically refer to in the above trafficscript. It works a treat! |
Recent Articles
Other Resources
|


