We are using rails in AWS with rake tasks. I think it makes sense to migrate these rake tasks to run in lambda's instead of running it on rails servers. If we move to leverage autoscaling I don't want to end up spinning up more instances if a rake task sends the cpu usage up. Any thoughts or approaches to this?
First of all, currently AWS Lambda doesn't natively support Ruby on Rails. However, you can still use Ruby on Rails by preparing the relevant Ruby executables by building them for Lambda environments and including them with your code.
For more details in doing this refer Scripting Languages for AWS Lambda: Running PHP, Ruby, and Go.
On the other hand, the benefit I see in using Lambda is the costs of execution where you pay on seconds (Keep in mind that, since you need to include Ruby executables with Lambda, it will increase the loading time of the function when running the rake tasks increasing the Lambda costs). In addition, you have to make sure your rake tasks will run within 5 minutes which is the maximum time limit for a single Lambda execution.
Apart from that, you can alternatively consider the following approaches as well.