views:

104

answers:

5

I need to send out emails at a rate exceeding App Engine's free email quota (8 emails/minute). I'm planning to use a TaskQueue to queue the emails, but I wondered: is there already a library or Python module I could use to automate this? It seems like the kind of problem someone might have run into before.

A: 

Easiest way in my opinion would be to use a queue, ex Amazon SQS, and pull 8 records per minute, in a cron job running every minute.

Considering it was pushed into the queue, then taken out, I am working out the math that it is an extremely cheap service.

See below, 0.000002 is the rate for 2 requests. (Add and View)

8 requests per minute, 60 minutes in an hour, and 24 hours in a day. Take into account 30 days in the average month, you are still under $1.

0.000002 * 8 * 60 * 24 * 30 = $0.6912

This might not be exactly what you were looking for, but it should be a pretty simple solution.

EDIT: See here, a python SQS & S3 Lib (sqs is all that you should be looking for).

http://pypi.python.org/pypi/Python-Amazon/0.5

Matt Dunbar
App Engine has its own task queue API. This is needlessly complicated.
Nick Johnson
A: 

I'm not familiar with any canned solutions to this problem, but it should be something very easy to solve. Write the emails to a datastore table, with an auto_add_now date field to record the order in which they entered. Your cron job that runs every minute pulls the eight oldest records off, mails them and deletes them.

Certainly, if you can solve this is a reasonably generic manner, you can be the person who solves this problem for everyone with a nice open source module.

Adam Crossland
+1  A: 

its cheaper to just pay for it for a year than to engineer a workaround.

Dustin Getz
I also think you are right about that. $0.0001 per email is cheap if you ask me. Say for example you sent 1000(3000 in total) extra messages every day. Then after 1 year you only pay 36.50 dollar if my calculation is right.
Alfred
+4  A: 

If it's an option, why not just enable billing? It'll jump the max rate from 8 recipients/minute to 5,100 recipients/minute.

The first 2000 recipients is free each day, as long as you aren't going over the daily free quotas my understanding is that it will not cost you anything (and if you need to email more than 2000 people per day you're going to have to enable billing anyways).

wf
+2  A: 

The deferred library is designed for exactly this sort of thing. Simply use deferred.defer(message.send), and make sure the queue you're using has the appropriate execution rate.

Nick Johnson
Precisely what I was looking for. Thank you!
amdfan
This is nice :)
Alfred