I'm currently working on a email notification of a social media website, and I want to send users email notification whenever the user is not viewing the site(at least for a certain period,30mins,1h,etc)
I'm considering using a cron job for sending those email notification and fire the cron job every 30 minutes.
Let's say user A commented on user B at 2014/8/13 18:39:00, it would have a row in the comment table of the database base like
comment_user user_received comment_send_time view_or_not(y/n) email(y/n)
user_A user_B 2014/8/13 18:39:00 n n
in my corn job php script, I would check if the interval between the current time and the comment_send_time is greater than 30mins
, and is view=n
email=n
and the cron job is going to send user_B an email notification of the new comment, and after the email being sent successfully, updated the email to n
, so that it can prevent sending a redundant email notification.
My concern is if I run the cron job every 30 mins, will it harms the server performance, and will a cron job be a proper way to handle this task and what other options would be