Sven Hoexter: Failing with F5: Implementing HTTP session persistence
In the old days people deployed the Apache HTTPD together with mod_jk and
mod_balancer in front of Apache Tomcat instances to achieve scalability and
resilience. That sooner or later turns out to not provide features you
nowadays would like to have to run a service 24/7. So it happened that I
had to jump into the sometimes cold sea of managing services fronted by
F5 BigIP devices, a somewhat common load balancing solution.
Soon after you start to introduce loadbalancing, because you grow beyond the
"one fat webserver" state, you'll have the requirement to implement some way
of session persistence. In the old days you might have added a unique jvmRoute
value to your mod_balancer pool and to your tomcat configuration to match the
connection to the right pool member. If you're clever you've set it on the
Tomcat as a variable that automatically builds up the jvmRoute based on the
hostname, so you can add new instances without having to touch the Tomcat
configuration. In case you were not that clever (like we were when we started)
you might have added placeholders in the server.xml to set the jvmRoute
value in your deployment script.
I think in a somewhat better world your first step usually is to introduce a
shared session store, be it the php session handler backed by a memcached or
Hazelcast for the Java afficionados, to avoid the persistence requirement on
your balancer. But if you grow even bigger the requirement will soon reappear
because you might have to add some form of sharding and now have to sent
users to the same cluster serving a specific shard.
In the end all of that is not cool and your developers have to be aware of
those issues. For all cases where fault tolerance within the session is
not a priority we aimed for something that we can enable or disable on the
balancer without application code changes.
The "let the box do its job" solution
The nicest solution from our point of view is letting the F5 inject a
cookie that points the device on subsequent requests to the right pool
node. If you like you can define the cookie name, a timeout, force the
injection on replies and some other tunables. Take a look at the help
for ltm persistence cookie if you'd like to have a look at the details.
The "let's do it by hand but on the box" solution
Most Java frameworks provide a session cookie called JSESSIONID.
Why not use that one and add a persistence table entry on the
BigIP with the cookie as the lookup key? As always if there's no
solution provided out of the box you can implement an iRule for it.
Kind of an F5 mantra.
There are many examples out there, here is what we ended up with:
when HTTP_REQUEST
if [HTTP::cookie "JSESSIONID"] ne ""
persist uie [string tolower [HTTP::cookie "JSESSIONID"]] 1800
when HTTP_RESPONSE
if [HTTP::cookie "JSESSIONID"] ne ""
persist add uie [string tolower [HTTP::cookie "JSESSIONID"]] 1800
And here is where I failed
Now imagine you're running an application that so far handles only
machine to machine traffic without session persistence.
A few month later you're approached to enable session persistence, because
someone introduced a management console for the application as a web user
interface. Without further ado you jump on board and provide - showcasing the
flexibility of the new balancer - session persistence based on cookies
injected by the BigIP. You've done it before, you enable it for the
test environment, everything looks fine, you enable it for the
production setup. Everything is fine (at least for now ...),
the WUI workes fine, sessions are persistent to the node the user hit
first.
A month or two later someone from the development team approaches you
again, this time asking if the balancing setup has some issues because
over 90% of the live traffic hit one of the two machines in the pool until
it wents down due to a crash or a deployment. Then about 90% hit the other
node, even after the crashed one is resurrected. But every time the
developer tests the balancing with a "while true" loop sending several hundred
requests via curl the balancing is perfectly equal.
After beeing puzzled by the behaviour myself we started to look at the
live traffic with tcpdump and suddenly it was all clear when I saw
the BigIP cookie beeing passed around. Actually everything behaved as
we configured it. The application used a proper HTTP library and that one
implemented cookies: If you receive one you're polite and pass it back to
the sender.
The original sender of course also implements HTTP with cookie support
and now, due to the natur of the traffic, we have long living connections
between two applications passing around the same cookie. On every single
HTTP request sent through this connection. And every time the balancer
will look at the cookie and happily base the routing decision on the pool
member noted in this cookie.
When we tested with curl we did not have the usage of cookies on our
mind. Because our false assumption was that the applications do not
create cookies for machine to machine traffic. Nobody, including myself,
actively remembered the decision to base the session persistence on cookies
injected by the balancer.
We went on and switched to the iRule mentioned above. Luckily we already
had that one implemented and tested for a different use case with the
requirement to not inject additional cookies.
- Can we maybe improve the change process for the balancer to handle a mixed traffic scenario?
- Do we need monitoring to monitor the balancing of requests?
- Is it a wise idea to mix machine2machine and user2machine traffic on the same port?
- Should we maybe, if we seperate properly, place management applications on a different system?
- Is our documentation sufficient?
In the Solomon Islands in the south Pacific some villagers practice a unique form of logging. If a tree is too large to be felled with an ax, the natives cut it down by yelling at it. (Can t lay my hands on the article, but I swear I read it.) Woodsmen with special powers creep up on a tree just at dawn and suddenly scream at it at the top of their lungs. They continue this for thirty days. The tree dies and falls over. The theory is that the hollering kills the spirit of the tree. According to the villagers, it always works.
Ah, those poor nave innocents. Such quaintly charming habits of the jungle. Screaming at trees, indeed. How primitive. Too bad thay don t have the advantages of modern technology and the scientific mind.
Me? I yell at my wife. And yell at the telephone and the lawn mower. And yell at the TV and the newspaper and my children. I ve been known to shake my fist and yell at the sky at times.
Man next door yells at his car a lot. And this summer I heard him yell at a stepladder for most of an afternoon. We modern, urban, educated folks yell at traffic and umpires and bills and banks and machines especially machines. Machines and relatives get most of the yelling.
Don t know what good it does. Machines and things just sit there. Even kicking doesn t always help. As for people, well, the Solomon Islanders may have a point. Yelling at living things does tend to kill the spirit in them. Sticks and stones may break our bones, but words will break our hearts .
by Robert Fulghum (
creating a free operating system in general & fixing bugs in particular
is a collaborative effort. today's example is bug report
Recently I build a new desktop system. The hightlights of the hardware are a pair of 512Gb SSDs, which were to be configured in software RAID for additional speed and reliability (I'm paranoid that they'd suddenly stop working one day). From power-on to the (GNOME) login-prompt takes approximately 10 seconds.
I had to fight with the Debian installer to get the beast working though as only the
You have a machine someplace, probably in The Cloud, and it has Linux
installed, but not to your liking. You want to do a clean reinstall,
maybe switching the distribution, or getting rid of the cruft. But
this requires running an installer, and it's too difficult to run d-i on
remote machines.
Wouldn't it be nice if you could point a program at that machine and have
it do a reinstall, on the fly, while the machine was running?
This is what I've now taught propellor to do! Here's a working
configuration which will make propellor convert a system running Fedora
(or probably many other Linux distros) to Debian:

Here s
One of the attention-grabbing measures in the Autumn Statement by Chancellor George Osborne was the