I am trying to make to make a reminder system and I am using quartz for my scheduling. However I come up with a couple possible ways how to do what I need to do but I am not sure what the best way is and how to test it.
Basically I have a reminder system that users can set reminders. It is like Google Calendar. You set the date and time that your event is and then you set a reminder by saying "remind me 15 minutes before"
So you could have a event on May 10th, 2011 9:59am and you could say reminded me "15 minutes before"
So that would be May 10th, 10:44am.
I will be in a hosted environment. (My site and the scheduling will be running of in the same environment and even in the same solution. So it can't slow down the users browsing my site by much.)
I am also using nhibernate and fluent nhibernate to do the db querying. I am using asp.net mvc 3 for my web site.
Option 1.
Do a database query every minutes and get all reminders that should be sent out in that minute. This of course will mean a database query every minute and probably too intensive for a shared environment.
Option 2.
Do a database query every 5 minutes and grab all the reminders that should be sent in that 5 minute block and store them in a collection(so memory) and then check every minute which ones need to be sent out.
This of course lessens the amount of queries done but not sure if this will get extremely memory intensive.
Option 3
Same as Option 2 but send a query every 15 minutes and store in a collection.
This of course means alot less databases queries but more stored in memory.
Option 4
Do a database query every 15 minutes and get all reminders in that block and fire them out immediately.
This means they won't be stored in memory very long and reduced amount of queries. However depending on when the user set to be reminded the email could arrive alot earlier then they set.
For instance they said remind me at 10:44am. I would have my scheduler start at 10:00am and it would grab from 10:00am to 10:15am and then 10:15am to 10:30am then 10:30am to 10:45am.
So that email would actually arrive 14 mins earlier then intended.