Rails scheduled task behind a load balancer

294 views Asked by At

I was wondering how to properly schedule a task for a rails application that sits behind an elastic load balancer.

This task is an automated weekly email that is to be sent out every Monday from the application. We currently have multiple EC2 instances that sit behind a LB.

I was going to use the whenever gem in order to accomplish this and have the schedule in the code repo, but thought it would attempt to run the task from all of our instances.

What can I do to run a scheduled rake task once per week on servers behind a load balancer?

1

There are 1 answers

0
Dean Galvin On BEST ANSWER

As zwippie said

Perhaps this converation is still relevant, it mentions that the tasks will only run on the machine with the :db role.

I believe that roles are the best solution to this problem currently.