Don't Kill Your Servers With Kindness And Consideration
These times are very busy and it is good to see a brisk demand for CF developers but that is not the focus of this blog piece, however it is always good to spread good news. I have written many times about clustering, most of those pieces have related to hardware clustering which typically includes fail-over and load-balancing and this article will also be about just that. There are a few caveats to be aware of, some of what I put here is repetition from previous blog posts but they are important points.
The way that a typical clustering device determines if a server-instance-node is available is via some sort of "heartbeat/ping" to each server-instance-node. There are several ways to do this which we show below, before going into detail there is one very important point to raise here; do not set any heartbeat/ping to ping too frequently, we have had several clients who have had performance issues caused by heartbeat/pings that are too frequent, our recommendation is set the heartbeat/ping to do this no more frequently than every 10 seconds. Also, do not have the heartbeat/ping set to become more aggressive if there is an apparent problem with the response from server-instance-node; that just makes matters much worse.
Here are some pointers to setting up clustering devices. Typically, directly after install, a hardware clustering devices ping will default to looking for a 200 response, which, if pointed at a web site tells the clustering device that the web site is responding. At this point, it can often seem like a good idea to simply point the 200 heartbeat/ping to a ColdFusion based or any other application/dynamic based site and as mentioned just look for a 200 response, there is a danger in doing this. If that application has very heavy initialization characteristics, the heartbeat/ping will run that code and we have had clients running such heartbeat checks at two or even one second intervals. So here is our recommended procedure, this relates to ColdFusion applications in particular.
Create a directory, ideally outside of the main application root, this is important. In that directory put an Application.cfm or Application.cfc file with very simple settings only those required to run the code as follows. Create a very simple query, no Select*; which pulls a single row of data from the database, ideally a short string and set your clustering device to look for that string. This way you know the web server, ColdFusion, the database and the network are all responding.
One last point, which I often emphasize, people often call clustering devices (F5 BigIP, Cisco ACE etc) "load-balancers" when that is only one of the things they do. In fact it is usually for fail-over, another thing they do, that they are first employed.