Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Managing workers on AWS

I occasionally have really high-CPU intensive tasks. They are launched into a separate high-intensity queue, that is consumed by a really large machine (lots of CPUs, lots of RAM). However, this machine only has to run about one hour per day.

I would like automate deployment of this image on AWS, to be triggered by outstanding messages in the high-intensity queue, and then safely stopped once it is not busy. Something along the lines of:

  • Some agent (presumably my own software running on my monitor server) checks the queue size, determines there are x > x_threshold new jobs to be done (e.g. I want to trigger if there are 5 outstanding "big" jobs")
  • A specific AWS instance is started, registers itself with the broker (RabbitMQ) and consumes the jobs
  • Once the worker has been idle for some t > t_idle (say, longer than 10 minutes), the machine is shut down.

Are there any tools that can I use for this, to ease the automation process, or am I going to have to bootstrap everything myself?

like image 784
Goro Avatar asked Apr 25 '26 01:04

Goro


1 Answers

You can public a custom metric to AWS CloudWatch, then set up an autoscale trigger and scaling policy based on your custom metrics. Autoscale can start the instance for you and will kill it based on your policy. You'll have to include the appropriate user data in the launch configuration to bootstrap your host. Just like userdata for any EC2 instance, it could be a bash script or ansible playbook or whatever your config management tool of choice is.

like image 137
Ben Whaley Avatar answered Apr 27 '26 14:04

Ben Whaley