Simple autoscaling pattern with LXC, Jenkins, and Sensu
In Chapter 6, Clustering and Horizontal Scaling with LXC, we looked at how to horizontally scale services with LXC and HAProxy, by provisioning more containers on multiple hosts. In this chapter, we explored different ways of monitoring the resource utilization of LXC containers and triggering actions based on the alerts. With all of this knowledge in place, we can now implement a commonly used autoscaling pattern, as shown in the following diagram:
The pattern uses Jenkins as a build system, controlled by the Sensu alert handlers. When a Sensu agent running inside an LXC container receives a scheduled check from the Sensu server, for example, a memory check, it executes the script and returns either OK
, Warning
, or a Critical
status, depending on the configured alert thresholds. If the Critical
status is returned, then a configured Sensu handler, which can be as simple as a curl
command, makes an API call to the Jenkins server, which...