Archiving system for reminders

I create a reservation system in Rails 4.2, where I need to send a set of letters to users at predefined intervals (for example, they have an upcoming reservation, feedback after that, a link to change / cancel an existing reservation, etc.). I looked around and found this and this , but I'm trying to choose between approaches.

I see two main ways to build this system.

  • Using a queuing system, such as delayed_job . Whenever someone makes a reservation, we queue all letters for the correct time when they should be sent.

    Pro: one line for all emails. Automatic repeat logic.

    Con: Thousands of letters end up in the queue in the system. You need to deactivate every time someone cancels the reservation (it depends: it’s quite easy to destroy messages associated with it). Somewhat more complex logic at what time we need emails to exit.

  • cron + rake task that runs at a predetermined interval (hourly? every fifteen minutes?) and checks the emails to be sent. It executes a query such as "Find all reservations that are in three days," and then sends all emails.

    Pro: Put everything in the application logic, reduce the number of states that we need to track.

    Con: you need to keep track of which letters were sent, which conceptually looks like any task table that we have already created above.

+6
source share
2 answers

The second approach is better (use the heroku scheduler if on heroku), the queues are longer for "run as soon as possible" than "run on this particular datetime"

0
source

One of the advantages of 1) the use of delayed_job (or Sidekiq) is that you can dynamically update the schedule of the task (or recurring task) from the site.

You can provide a page on your site to update repetitive tasks. Now delayed_job does not allow repetitive jobs to be performed by default. There are additional stones that may be of interest, although delayed_job_recurring or sidekiq-scheduler . If computing power is not a problem, I would always prefer the actual processing processor over cron, because for me it is just more manageable.

0
source

All Articles