带有 GAE 和每分钟配额的批量电子邮件

发布于 2024-10-20 19:51:42 字数 516 浏览 6 评论 0原文

我正在与 GAE 一起开发一个投票应用程序,其中涉及向每个选民发送电子邮件。在我最初的测试中,我超过了每分钟电子邮件配额,并引发了这个异常:

OverQuotaError: The API call mail.Send() required more quota than is available.

我能够通过启用计费来解决这个短期问题,这大大增加了每分钟电子邮件配额,但是防止这种情况的正确方法是什么?将来是否会提出这样的例外?如果我的应用程序非常成功并且超出了更大的配额,那么引发此异常将是一个大问题。

我不想将发送电子邮件的调用放在 try, except 块中,因为这是在处理表单后完成的,并且我不希望用户等待对 POST 的响应。

这是任务队列的一个很好的用例吗?如果是这样,我是否会将发送一批电子邮件的请求放入任务队列中,或者将每个发送电子邮件的请求放入任务队列中?前者似乎更好,因为处理 POST 会更快。无论我采取哪种方式,我是否会在发送每封电子邮件之间添加延迟,以确保它们不会发送得太快而超出配额?

I'm developing a voting application with GAE, which involves sending email to each voter. In my initial tests, I went over the per-minute email quota, and this exception was raised:

OverQuotaError: The API call mail.Send() required more quota than is available.

I was able to solve this short term by enabling billing, which greatly increases the per minute email quota, but what is the right way to prevent such an exception from being raised in the future? If my app becomes wildly successful and I exceed the larger quota, it would be a big problem to have this exception raised.

I don't want to put the call to send emails in a try, except block, since this is being done after processing a form, and I don't want the user to wait around for the response to the POST.

Is this a good use case for a task queue? If so, would I put a request to send a batch of emails in the task queue or would each request to send an email go in the task queue? The former seems better in that processing the POST would be faster. Regardless of which way I do it, would I add a delay between sending each email to ensure they are not sent to fast and I go over quota?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戴着白色围巾的女孩 2024-10-27 19:51:42

是的,非常适合任务队列,因为您可以通过更改队列中的属性来限制发送电子邮件的速率。yaml

每个任务一封电子邮件最好,因此如果任务失败并重试,它只会重试失败的不是整个批次的

yes, ideally suited to the task queue as you can limit the rate at which your emails are sent out by changing the properties in the queue.yaml

one email per task would be best, so if the task fails and is retried it will only retry the failed one not all of the batch

梅倚清风 2024-10-27 19:51:42

是的。使用任务队列。如果任务正在发送电子邮件,您可以决定每分钟应运行多少个任务。如果任务失败,它将重试执行。

yes. use a task queue. if a task is sending a email, you can decide how many tasks should run per minute. and if a task failed it will retry to execute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文