Closed (won't fix)
Project:
Amazon SES
Version:
6.x-1.0-beta2
Component:
Miscellaneous
Priority:
Minor
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Apr 2011 at 15:58 UTC
Updated:
15 Aug 2015 at 11:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mikeker commentedThere are two things that will affect your throughput: your MaxSendRate (as determined by Amazon) and the number of requests your server can make simultaneously. Amazon starts you at 1 message/second to prevent spammers from using SES and increases the number as you prove the quality of your emails. (See their doc pages for info on sending limits). There is also an option to petition the AWS powers-that-be to increase your limits by reviewing your use-case in person. (Sorry, don't have the link to that on hand...)
The number of simultaneous threads issue is because SES takes about 2-3 seconds to process a single call to AmazonSES::send_email(). There was some talk about how to deal with this using CFBatchRequest to help with queuing messages on the Amazon forums but I haven't tried those options yet.
Comment #2
Ryan Palmer commentedAs mentioned, Amazon will limit you to 1/second and 1000/day until you prove to them you're not a spammer. I believe they will raise your rate automatically, and this is something you can monitor from the Amazon SES module backend. It's worth noting that you could potentially send emails faster by sending the message to multiple recipients. They are billed as separate messages but would get sent all at once, I believe.
If your needs are great, you may need to send messages into a queue multiple threads can attack. I'm afraid job_queue for 6 and the built-in queue for 7 probably won't buy you much (except batch processing) since they run on single-threaded cron. If you would like to place a small bounty on this, I'd be more than happy to write it up as a separate module to enable using something like Amazon SQS, but for now it's not in my pipeline.
http://aws.amazon.com/sqs/
Ryan Palmer
// Lead Developer, Drupal Connect
// drupalconnect.com
Comment #3
chadhester commentedSo, we had our limits increased to 50k/day, with a 14emails/second rate. That means that we can email 50k people in just shy of an hour. But am I reading your second limitation correctly by assuming:
1 email call every 2-3 seconds = 20-30 emails per minute, or 1200-1800 emails per hour?
If that's the case, that's lower than what we need, and this is a concern large enough for me to ask what it would take to optimize this. I am more than willing to put in some time to realize this functionality. I imagine it would be of great benefit to anyone that seriously considers using this module for bulk mailings.
Thoughts?
Comment #4
Ryan Palmer commentedI haven't personally tested the time it takes to send messages at that rate, so I can't confirm or deny the "2-3 seconds per message" observation. But it would not surprise me if this was the case, considering round-trip network latency and so-on. Do you host with Amazon? It could potentially be faster if you did.
Comment #5
chadhester commentedIt appears that it could be faster for us, but I am having problems with testing due to some sort of "Illegal Address" error. I'm looking into that now, but I came across what looks like a possible fix:
https://forums.aws.amazon.com/thread.jspa?threadID=59211
BTW, is that you, Ryan, commenting at the bottom? Kudos for standing up for the Drupal numbers, if so! :)
Also, regarding the bounty for optimizing the throughput of this module using a batch/queuing technique, what is your time/price estimate? Our company may consider such a thing. I'm the lead developer, but I (like most) also have several other things on my plate. Trying to weigh our options versus going with another service. Mailchimp sorely disappointed us for our needs, which is why we're looking at stuff like SendGrid and Amazon SES (or others).
Comment #6
Ryan Palmer commentedNope, that wasn't me! I didn't read the thread yet. What's the problem?
Comment #7
chadhester commentedThe issue appears to be a problem with the message headers... I'm still digging into the problem, but if it proves to be related to this SES module, I'll file a separate issue with any findings.
Regarding the bounty, let me know your thoughts when you get a chance.
Thanks!
Comment #8
chadhester commentedhttp://drupal.org/node/1121202
Comment #9
mikeker commentedLet me clarify that those number are what I was seeing when calling Amazon's servers from either my localhost or the server my site is running on (cheap-ass shared hosting). As Ryan mentions, I assume you'll get better results if you on an EC2 instance. Though my latency to other AWS services usually isn't very high, so who knows...
I've had some success using CFBatchRequest (see the link in #1). Theoretically, you could batch all your calls and execute them in parallel, but I haven't played with it too much so I don't know the ramifications this would have on you hitting your MaxSendLimit. When I get that figured out, I'll submit a patch.
Comment #10
mikeker commentedAttached is a patch that allows bulk sending without multiple calls to send_email(). It involves a bit of refactoring, so I would appreciate testing and reviews...
Here's what I did:
With an array of 100 email addresses, I was getting a turnaround from send_email of around 1.8 seconds (180 seconds total processing time) vs. about 7.5 seconds using this method.
Please see the note at approx line 65 in amazon_ses.mail.inc regarding hitting your MaxSendRate using this method. I haven't hit it in my (fairly limited) testing, but I'm interested in hearing how others fair. Specifically post your MaxSendRate and the number of messages successfully sent via this method. In particular, post any Throttling errors you get.
Eg:
Without any confirmation from Amazon, it seem they have doing the right thing w.r.t. queuing messages and sending them at whatever your allowed MaxSendRate is. Either that or they allow short bursts over your MaxSendRate as long as you don't do it too often. Either way, I believe getting some real numbers would be instructive.
Thanks.
Comment #11
mikeker commentedScratch that... Just ran another test with a total of 485 messages:
MaxSendRate: 5.0
Max24HourSend: 10000
Send 270 successfully
215 returned errors
209 were throttling errors
I had not sent any messages in the previous 24 hours so all the throttling was due to too many messages per second.
Comment #12
mikeker commentedOK, here's another patch -- same refactoring as #10 -- but it gets the user's MaxSendRate from Amazon and uses that for the queue size. I've had better luck with this method, sending to basically the same list in #11 but without the throttling errors. 'Course it took 70 seconds to process the request...
In order to truly maximize the rate we can send emails via SES, we would need to track the time it takes for each batch to process and use that to adjust the queue size (eg: 2 second round trip means we use 2 * MaxSendRate in order to make as close to MaxSendRate requests per second). Anyhow, the refactoring makes it easier to do something like that in the future.
Comment #13
Ryan Palmer commentedCoo, thanks for that. Is this for the D6 branch?
Comment #14
wamilton commentedNot trying to be contrary, just curious: what does this get you versus just bracketing the actual send in locks and variable_get/set to ensure each process waits long enough?
That way it will work even if you need to send a bunch of different emails. For example, trying to use SES to send the account creation email after using the user_import module still wouldn't work. I only mention this because it happened to me yesterday. ;)
In any case, it seems like a good idea to guarantee that you never exceed the send rate, and just log whether or not it was an issue, regardless of whether the module is being used correctly.
Something like this:
Comment #15
mikeker commented@Ryan, yes it's a D6 patch... I don't have a D7 project using SES yet. ;)
@wamilton, the issue I'm trying to solve is that SES can take 2 seconds to process a single send_email() call, at least from my localhost and cheap shared hosting account. This patch allows you to essentially send send_email multiple requests to SES in parallel. If your MaxSendRate is 10 you can get 100 emails out in 20 seconds (sending 10 in parallel) rather than 3+ minutes (sending one at a time).
Though this raises the point that if you're getting a round trip from SES in less than 1 second, you may get throttled. That's a problem I'm hoping to have one of these days... Or if you have two processes that trigger send events, you may get throttled. Adding the semaphore lock would be a good idea in both the bulk and non-bulk send functions.
Comment #16
druvision commentedNice thread, but old.
SES initial max send limit is now supposed to be 10,000 emails per day. Which is increased automatically if quality is sufficient.
The other numbers are quite nice, but I would like to get more updated info regarding Drupal throughput.
Comment #17
tkuldeep17 commentedSorry, Now my code base does not support for drupal 6.