Skip to content

Tool for testing Google Cloud autoscaling that generates VM instance CPU load on demand.

License

Notifications You must be signed in to change notification settings

epnasis/mig-cpuload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mig-cpuload

Tool for testing Google Cloud autoscaling that generates VM instance CPU load on demand.

  • Builds docker image and pushes it to current project Container Registry
  • Creates Managed Instance Group (MIG) with instance template, autoscaling and health-checks for autohealing
  • Each instance listens on external IP HTTP port for allowing you to:
    • Generate/stop 100% CPU load on each instance
    • Make unhealthy - disabling health-checks to test autohealing
  • You can adjust settings (CONFIG file) for your testing:
    • Machine type used in MIG (smaller bigger CPU/Memory)
    • Initialization time to simulate apps that require long time to start serving
    • Autoscaler configuration

Follow instructions below and watch your MIG autoscale based on the load you generate. Change load and see how MIG autoscaler reacts.

Getting started

  1. Open Cloud Shell or your favorite terminal that has gcloud/docker/make installed.

  2. Clone this repo

git clone https://github.com/epnasis/mig-cpuload.git
cd mig-cpuload/
  1. Skip this step if using Cloud Shell. Otherwise export your Google Cloud project to GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_PROJECT=<your_project_here>
  1. Create new autoscaled MIG for testing:
make

(Optional) Repeat make command to create more MIGs. You can adjust CONFIG file if you want to change MACHINE_TYPE or other MIG/autoscaler configuration.

  1. Connect to your MIG instance using your browser to generate/stop load and test autoscaler features.

Screenshot-with-instance-list

Click "Generate load" to create 100% utilization. Click "Stop load" to kill load at any time. Repeat for as many instances as you need in your testing scenario. You can also make instance unhealthy (disable health-checks) to trigger autohealing.

Screenshot-with-instance-external-IP-http

  1. Once done remove created resources with:
make clean

Configuration

Update CONFIG file to set instance group properties:

NAME=mig-cpuload
MACHINE_TYPE=e2-micro
ZONE=us-central1-a
MIN_NUM_REPLICAS=1
MAX_NUM_REPLICAS=10
TARGET_CPU_UTILIZATION=0.8
INIT_DELAY_SEC=0

Other commands

  • Recreate docker image - useful if you updated the app.py of CONFIG files
make docker
  • Create new instance template
make mig-template
  • Create new health-check
make mig-healthcheck

Contact

In case of questions contact [email protected]