Simple as that, I am using AWS SDK in Node to make a Lambda procedure that is in charge of sending emails according to data it receives.
I would like to 'delay' that email, delivering in a date and time received, not in the specific moment that the function was called. The Date and Time to deliver are parameters received by the function. Any thoughts? I couldn't find much searching on the web.
Thanks in advance!
You should develop a queue for sending email because AWS SES does not offer that feature and if you want to send a lot of emails very soon, you have the problem with sending limit. So, the queue is vital in any email sender service.
For the queue, you can use AWS SQS, for handling hard and soft bounces you can use AWS SNS and AWS lambda function to manage all of them.
SES does not provide this natively. What I've done is to create a queue to process the emails plus schedule them within my limits.
Here's the psuedocode:
queue = []
limitPerSecond = <Your API limit>
putEmailsInQueue(queue)
while (true) {
processQueue(queue)
wait 1s
}
function processQueue(queue) {
numberOfEmailsToPop = limitPerSecond
emailsToSend = popEmailsFromQueue(queue, numberOfEmailsToPop)
sendEmails(emailsToSend)
}
You can also check out huhumails.com
Disclaimer: I'm the author of the service and I made it to make it easier for people to worry less about this issue.
HuhuMails acts as the middle-man between you and Amazon SES to take care of email scheduling and make sure your emails are sent within your rate limit. It also accepts date and timezone parameters if you want to send your email in the future.
I'm currently using this for my other websites as well. Hope you and other people find it useful. Let me know if you have any questions.
Related
I have been trying to pass data with event using scheduled eventbridge. But the documentation for serverless framework is not very clear.
Objective: I want to create an email notification system with custom data. So users can turn on notification for lets say 1 week/2 week etc. And They will receive emails with their custom data as long as they keep notifications turned on. If they turn it off, I want to stop sending.
Please let me know if there is a better approach than scheduled eventbridge to reach my objective. And an example of the scheduled eventdrive in serverless.yml with lambda would be much appreciated.
I am using Stripe with the separate charges and transfers flow. The way this goes is that my platform receives the full payment minus the Stripe fees, and then I do a Transfer to the seller's connected account, which is then paid out to their bank. I set up a webhook to run on the "transfer.paid" event, so I can update some book-keeping records on my platform's database when the money is transferred to the connected account. I wish to test this endpoint so that I can see whether my event behaves as expected. However, it seems that the webhook testing available through the Stripe Dashboard sends only dummy data, or only populates a few items of the request body with data from the last transaction made in the account. It seems the only way to receive real data is to allow the event to trigger by itself. In my case, though,the transfers are taking up to seven days to complete, which means I have to send and wait a whole week to see the result, which is really slowing down my development time. This seems really inefficient, unless there is something fundamental that I am not understanding about webhooks. Does anyone have any idea how I can test my webhook endpoints with real data without having to wait so long? Any info will be greatly appreciated.
Unfortunately the only way to test events with 'real' payloads for some things like Subscription-based events and Payouts is to wait for the event to occur in testmode.
I'm creating a consumer of an Azure Service Bus topic (subscription) that does nothing but store some statistics. The messages sent to the topic contains a rather large body, that is handled by another consumer on a second subscription on the same topic.
Since the statistics consumer can handle a large number of messages in one go, I was wondering if it is possible to receive a lot of messages but leave out the body to improve performance when communicating with Service Bus and to receive even more messages in one go.
I'm currently doing this:
this.messageReceiver = new MessageReceiver(conn, path);
...
await messageReceiver.ReceiveAsync(10, TimeSpan.FromSeconds(5));
It works pretty sweet but it would be nice to be able to receive 100 or more messages, without having to worry about moving large messages over the network.
Before anyone suggests it, I already know that I can ask for a count, etc. on a topic subscription. I still need the Message object since that contains an entry in the UserProperties dictionary that is used to calculate the stats.
Not possible. You can peek, but that brings the whole payload and headers w/o incrementing the DeliveryCount of the message. You could request it as a broker feature here.
The current setup of the project I am working on is based on Nodejs/Express and AWS. AWS Lambda is triggered on a daily basis and is used to call an API endpoint which is expected to fire a varying number of emails via Sendgrid (hundreds to thousands). With a lower number of emails it worked fine but when the number of emails was around 1000 the Lambda timed out and the API crashed.
The limit on Lambda was 1 minute. Raising it up to 5 minutes might make this case of 1000 emails pass but might fail when the number is several thousands. Apart from that we would like to avoid keeping the server busy for several minutes because of which it was set to 1 minute initially.
We are now looking for better solutions to this specific situation. What would be a better approach, is it an option to use SNS Queue, or Serverless with moving all the code that sends the emails to Lambda?
Thanks for any inputs in advance and if more information is required please let me know.
Lambdas are not designed for long running operations. You can use Elastic Beanstalk Workers https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html
Briefly, the lambda publish the task to an SQS queue and an elastic beanstalk app handles it.
I have the following dilemma:
I need to send a heartbeat message every 5 minutes (or less) to all users of my app
I thought about topic messaging, but the 1 million subscriber limit is not acceptable for my application
So: the only possibility left is sending out the message in batches of 1000
This is really resource intensive
Now my question:
How can I make this process of batching and sending really efficient? Is there a good solution already made, preferably in node.js?
Thank you,
Sebastian
You may use XMPP, instead of HTTP.
As google says, it is less resource intensive in respect to HTTP:
The asynchronous nature of XMPP allows you to send more messages with
fewer resources.
Also you can have 1000 similtanouis connection per app (sender ID):
For each sender ID, GCM allows 1000 connections in parallel.
Also there exists a node-xmpp solution available for that.