I am working on a feature that will allow the user to configure an email to be sent a time he chooses. Once he has saved this configuration, email will be delivered at his chosen time (or around that time) daily until he/she deactivates that configuration or deletes that. There can be many such configurations having different times.
So far I was doing something like this :
- Run a cron job every 10 minutes.
- Look for email configurations that are to be executed in (now - 10 minutes).
- Send those emails and update status logs.
This used to work fine but has few pitfalls.
Emails configured at intersection times like 02:00 were not sent sometimes.
Due to a deployment or high CPU usage corn didn't run at all.
In both the above scenarios, email that are missed won't be picked again in next 24 hours.
How should I go forward to design a robust system that guarantees that all emails are sent.
If it matters I am using Django and a linux machine.