Delay sending email using Mandrill send_at or Celery / eta countdown

I usually send transactional emails in response to certain actions on my website, some of which I put off for a couple of hours. The function that actually queues up the email is a Celery task called .delay()

which ultimately invokes the Mandrill API call with djrill

.

I found that Mandrill offers an option send_at

on email sending that Mandrill delays sending the email until the specified time. In addition, celery offers options on eta

either a countdown

call apply_async()

or adelay()

task that will make the celery worker wait X amount of time before performing a task - which here will be equal to the same thing.

Ignoring the cost, which approach is preferred in architecture if you have a delay with celery by sending an email with countdown

or sending an email to Mandrill right away but with the option send_at

to have Mandrill wait for me? What factors should be considered when making this decision?

+3


source to share


1 answer


I will cover some of the points that we could take into account to make a choice here:

  • Fault Tolerance : If we put this responsibility on celery, then we may be more prone to crashes, since if the message queue (Rabbitmq, ZeroMQ or whatever), the machine or the celery itself fails, then the email will never be sent. Mandrill also failed, but probably in junior grade.

  • Maintenance . What if you need to change celery to something else? In this case, you need to migrate your code and maybe spend some time figuring out how to do it in the new MQ tool.

  • OOP . From the OPP point of view, we can see Mandrill as an object that sends emails, which brings several functions, for example. planning, so let's use this external service from our system, let it do its job!

  • Usability and scalability . Think of a hypothetical situation where you need to run your system on multiple servers at the same time due to increasing performance requirements; which is an easier and more efficient way to handle this scheduling?



These are not all aspects that should be considered for making a decision, but certainly some of them should not be overlooked. Hope this helps to understand a better / solid solution.

0


source







All Articles