Getting the Point of Cacti

One important area I forgot to mention in my overview of PHP application server farm considerations is monitoring. How will you know how to tune your farm for performance, or when it is time to add a new server or two to the mix? When it comes to understanding individual server performance and health, cacti is one of the best tools around.
Cacti provides mrtg-like historical graphs of all the basics (load, network latency, processes in use) and comes with a wealth of additional scripts. Two that are extremely useful on a LAMP application farm are apachestats and mysqlstats, which will tell you how many hits per second or idle daemons are running in Apache, how many queries and threads are running in MySQL, and much more.

It often amazes me how many administrators are "flying blind" even in enterprise scenarios, without historical data to back up their troubleshooting and recommendations. Cacti is a remedy to such frustration and guesswork that is remarkably easy to install.

Cacti provides significant advantages over "in-the-moment" analysis tools because it uses the rrdtool database to log and graph historical data. This allows administrators to spot trends at a glance and cross-correlate different variables over time (e.g. the load was x at 4AM, the number of running processes was Y, and the network latency was Z). It helps you answer questions like: "was it the network? the load? zombie httpd processes? idle mysql threads?" with numerical evidence and attractive graphs.

In clustered configurations and server farms, the application functions like a kind of organism assembled from multiple machines. A tool like Cacti makes understanding the health of this organism possible. Many thanks to Tobias Oetiker for rrdtool and Ian Berry for cacti. Look for more on monitoring, tuning, and scaling PHP application server farms in the upcoming print issue of International PHP Magazine.

§ § §

Categories: PHP.