Server Load when Sending 1000 Emails at Once
Posted: Sun Feb 27, 2005 10:14 am
I am writing a script that will be automated to run once a day using a cron job. It will be similar to how job (recruitment) sites send emails to users every day based on their stored search criteria.
This is what I have worked out in my head so far:
At 1am every morning my script will (for every user in my database):
1. Run a SELECT COUNT query with the stored search criteria and a clause to search for jobs that were posted after the date that the previous email was sent. Eg. SELECT COUNT(*) FROM jobs WHERE location='London' AND post_date > $date_last_email_sent
2. If the count is greater than zero, then send an email to the user stating how many new jobs have been posted.
3. Update date_last_email_sent field with NOW().
Now if I have 1000 users in my database, this script will loop 1000 times and send 1000 emails (assuming all searches have matches).
What are the implications of this on a server? I'll only be using shared hosting. Would it be too heavy to run every day?
Is there a better way I can do this? I'd like to hear your thoughts.
This is what I have worked out in my head so far:
At 1am every morning my script will (for every user in my database):
1. Run a SELECT COUNT query with the stored search criteria and a clause to search for jobs that were posted after the date that the previous email was sent. Eg. SELECT COUNT(*) FROM jobs WHERE location='London' AND post_date > $date_last_email_sent
2. If the count is greater than zero, then send an email to the user stating how many new jobs have been posted.
3. Update date_last_email_sent field with NOW().
Now if I have 1000 users in my database, this script will loop 1000 times and send 1000 emails (assuming all searches have matches).
What are the implications of this on a server? I'll only be using shared hosting. Would it be too heavy to run every day?
Is there a better way I can do this? I'd like to hear your thoughts.