Best way to build application triggering reminder at certain time

Question:

I want to build a python app sending reminder at certain time. It would have several subscribers. Each subscriber sets specific moment when they want to be notified. For example, John wants to have a reminder every days whereas Cassandra wants it every months.

I see several ways to do it :

  • Use a script running 24/7 with a while loop and checks if it’s time to do send the reminder.
  • Use a cron tab that runs the script every minutes to check if there’s reminder to send
  • Create a simple api (in Flask for example). It checks every minutes or so if there is a reminder to send to subscribers or even make a request to the api.

What is the best way to build such application in Python for few subscribers (10) and for a larger amount(1000)

Asked By: Pi-R

||

Answers:

For a small amount of subscribers I would do a script that run all the times, it would continuously check the time and send reminders as needed, you can use time and datetime modules for that.

For a large amount of subscribers it would be an API that can manage multiple request simultaneously, you can use Flask or Django or FastAPI for that.

For the API how would it work is that subscribers would make POST request with all the informational notification ( date, time, what message they want to receive for example ) then the server store those informations in a database like if you are familiar with python Celery seem the best one but you have Airflow too, it will schedule a reminder to be executed at a certain time.
Then when the reminder is executed it just retrieve the informations from the database, and send it via email for example

Answered By: Saxtheowl