Amazon AWS state:
You should use AWS Auto Scaling if you have an application that uses one or more scalable resources and experiences variable load. A good example would be an e-commerce web application that receives variable traffic through the day.
Autoscaling isn’t just for workloads running in a public cloud or Hyperscalers. We can achieve the same functionality running in your data center on premises within VMware.
We need to run some tools to achieve this. I am sure you can accomplish the same with configuration management tools.
Let us look at how to autoscale when the VM in question hits a threshold of 95% consumption over a 10-minute duration. In this example we will perform horizontal scaling, meaning adding a second VM.
Prerequisites:
- VMware Aria Automation is fully set up and integrated with VMware Aria Operations (formerly vRealize Operations) for monitoring and alerting.
- VMware Aria Orchestrator workflows are available for automation tasks.
- The necessary permissions to create and modify policies, blueprints, and workflows.
Step-by-Step Configuration
1. Configure Monitoring in VMware Aria Operations
- Set Up Metric Collection:
- Ensure that the VMs are being monitored by VMware Aria Operations and that CPU usage metrics are being collected.
- Create a Custom Alert Definition:
- Go to the
Alerts
tab in VMware Aria Operations. - Create a new alert definition that triggers when the CPU usage of a VM exceeds 95% for 10 minutes.
- Criteria:
- Base Object Type: Virtual Machine.
- Condition: CPU usage (%) > 95%.
- Duration: 10 minutes.
- Alert Impact: Set the impact to
Performance
. - Notification: Enable notifications to send alerts via email or other channels.
- Go to the
2. Create a Scaling Workflow in VMware Aria Orchestrator
- Define a Workflow for Scaling:
- In VMware Aria Orchestrator, create a workflow that will perform the scaling action (e.g., add more vCPUs or clone a new VM).
- Scaling Options:
- Horizontal Scaling: Clone a new instance of the VM or deploy a new VM from a blueprint.
- Vertical Scaling: Increase the number of vCPUs or memory for the existing VM.
- Input Parameters: The workflow should accept inputs such as the VM name, resource settings (vCPU, memory), etc.
- Action: Implement the logic to scale the VM (e.g., via a PowerCLI script or vSphere API calls).
3. Integrate VMware Aria Operations with Aria Automation
- Create a Subscription:
- In VMware Aria Automation, navigate to the
Subscriptions
section. - Create a new subscription that listens to the alert from VMware Aria Operations.
- Filter: Set the filter criteria to trigger when the alert (CPU > 95% for 10 minutes) is received.
- In VMware Aria Automation, navigate to the
- Attach Workflow to Subscription:
- Attach the scaling workflow you created in VMware Aria Orchestrator to this subscription.
- This will trigger the workflow whenever the alert conditions are met.
4. Create and Apply Auto-Scaling Policies
- Define Auto-Scaling Policies:
- In VMware Aria Automation, define a policy for auto-scaling that uses the subscription and workflow created earlier.
- Set the policy to monitor CPU usage and take the scaling action automatically.
- Apply Policy to VMs:
- Apply this auto-scaling policy to the specific VMs or VM groups that need auto-scaling based on CPU usage.
5. Test the Configuration
- Simulate High CPU Load:
- Generate a high CPU load on the VM to test the auto-scaling configuration.
- Monitor the VM’s performance and verify that the scaling action is triggered when CPU usage exceeds 95% for 10 minutes.
- A good tool for this is CpuStress by Microsoft (If you run Windows) https://learn.microsoft.com/en-us/sysinternals/downloads/cpustres
- For Linux – Stress is a great tool https://linux.die.net/man/1/stress
6. Monitor and Adjust
- Monitor Scaling Actions:
- Use VMware Aria Operations to monitor the scaling actions and ensure they are executed as expected.
- Fine-Tune Alert Thresholds:
- If necessary, adjust the alert thresholds or scaling logic based on the observed performance.
Summary
Following these steps, you can configure VMware Aria Automation to automatically scale a VM when its CPU usage exceeds 95% for 10 minutes. This involves setting up alerts in VMware Aria Operations, creating scaling workflows in VMware Aria Orchestrator, and integrating these with VMware Aria Automation policies.