Queue those emails and add delay to them. Take the count of users and divide it by the limit per second. That will give you max delay. Start from 0 and increment it for every chunk.
Throttle Vapor Queue for sending emails...
We are in the process of moving our application to vapor, and have come across an issue when sending multiple emails. As part of the sign up process, admins can upload a csv with perhaps thousands of users. This triggers a welcome email to be sent to each user. We use amazon SES for mailing, and that has a send limit of 14 per second. Previously we were able to throttle the queued jobs with redis to ensure we don't exceed this limit and get a bunch of unnecessary failed jobs.
With vapor, it is very possible that SQS will process these jobs at a rate higher than SES can cope with, resulting in failed jobs and emails not getting sent. Is there a good way around this?
I am aware we can increase the send limit with SES, but that still leaves a hard limit that we may exceed...
Please or to participate in this conversation.