The three small features I was interested on implementing with Instant Servers were:
- Simplify the creation of machines preconfigured to be used of locust slaves for my load testing
- Starting the slaves automatically on the machine startup so that the master detects them and is able to schedule jobs
- Stopping the machine automatically when it is not used for any test for some time to make sure we don't waste our money when forgetting to stop those unused machines
Creation of machinesTo simplify the creation of machines I decided to build an instance with all the required packages and use it as template to clone the actual slave nodes. To be able to find this instance later automatically I used Instant Server tags. As far as I know unfortunately there is no UI for tagging in Instant Servers but you could use a script similar to mine .
This machine needs to have python, locust, the test file (locustfile.py), all the basic packages (make, gcc) and the packages required to start locust automatically (see next point).
Auto starting slavesTo make sure that the slaves are started during machine startup and that we start multiple instances in every box (because locust is single threaded and I want to use multicore machines) I used supervisord with the following (hopefully autoexplicative) configuration. Tune the numprocs parameter depending on the machine you are using.
command=locust -f /root/locustfile.py --master-host=220.127.116.11 --slave
stderr_logfile = /var/log/supervisord/locust-stderr.log
stdout_logfile = /var/log/supervisord/locust-stdout.log
Auto stopping machines
To monitor the usage of a machine I could be using the extensive Analytics API in instant servers but I decided to use the locust log file for simplicity. I created a python script  monitoring log files for activity and if there is no activity for some minutes it invokes the stop Instant Servers API to shut down that instance.
Note: It was not possible to use the existing python SDK with Instant Servers and I had to fork it and made a small modification. More details in next post.
PD. If I ever mention the word "cloud" in any of this posts, please feel free to insult me, I will deserve it.