Session affinity (sticky sessions) for Perlbal

Following the concept of "if you haven't blogged about it, it doesn't exist", I'd like to let you know of a new Perlbal plugin, which you might find useful: Perlbal::Plugin::SessionAffinity.

Session affinity (also known as sticky sessions) is the ability to provide a user with a consistent backend from a reverse proxy, such as Perlbal. This is useful in case you cannot share the session data between backends, but do not want to lose the session.

Mind you, although Perlbal doesn't support session affinity in core, there is a plugin available on CPAN, but while trying to get it working, I've found a few major problems with it. It requires patches, it's outdated, and most importantly: it doesn't seem to work.

Since StickySessions was already taken, I've decided to take the SessionAffinity namespace and start using that term instead, in order to divert from the previous plugin.

I won't go into detail how horrifying the other plugin's implementation is (hint: most of it simply copy-pasted from core functions in Perlbal), but the fact of the matter is that I found myself required to rewrite an implementation from scratch. I went through several ideas, which all had their advantages and disadvantages, and after receiving a suggestion by a core Perlbal developer, I have been able to come up with an implementation with which I feel comfortable.

The implementation details are (hopefully well) documented in the plugin documentation. I won't bore you with it. You might find it an interesting read because of the usage of socket reuse, which helped me create services that use the same sockets and thus not opening more listening ports. Pretty nifty.

Leave a comment

About Sawyer X

user-pic Gots to do the bloggingz