-
-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch Deliveries #89
Comments
I think this would make more sense to be a bit more like: delivery_by :postmark # Sends individual emails
delivery_by :postmark, bulk: true # Sends them in bulk class DeliveryMethods::Postmark
def deliver
end
def bulk_deliver
recipients.each_slice(1000) do |group|
# send group
end
end
end That way you could still use Postmark to delivery individually or in bulk. The question I have is...how does Postmark know when to actually send in bulk? It'd need to queue up the recipients somehow know when it was ready to run. |
@excid3 yeah that's nice, I like the idea of being able to support both single and batch delivery in a single delivery method. 👍 One consideration is resiliency to failure. By putting the If the As for your question, Postmark, Sendgrid, Mailgun and just about every other mail provider I've come across deal with bulk sending via a single POST request, with up to 1,000 email addresses in the payload, they'll then split that list, queue and deliver everything once it's on their server. Does that make sense? |
Agreed. 👍 Maybe the option becomes something like this where you can specific the size of each slice. delivery_by :postmark, bulk: { group_size: 1000 } Then this would queue up X number of Postmark bulk delivery job (3 jobs if it had 3000 recipients). In theory, this wouldn't change too much of the existing functionality, just add to it. |
@excid3 how to improve the bulk insert with the database option using Rails 5.2? |
@SirRawlins I added an implementation in #127 🙇. Let me know your thoughts! |
@matteomelotti I saw this same issue when sending to a large number of recipients, the deliver_later method runs very slow while it adds all the jobs to the queue. I pulled the call to |
@manojmj92 awesome, I'm sorry for the slow reply, I've not been working with Noticed over the past few weeks. Your PR looks good on the face of things but will leave it for @excid3 to review properly when he gets time. |
I'm leaving for a couple weeks on vacation, but I'll try and check this out when I get back. |
@excid3 great. Have an awesome vacation, it's well deserved. |
Any update? |
I would love to see this, as I'm implements Expo notifications, which supports batch delivery. |
@excid3 Could you review this? Seems like an essential feature! |
From @SirRawlins
Batching is something I'd love to see.
If we have a notification to deliver to several thousand recipients, then some mail services such a Postmark/Sendgrid/Mailgun allow you to batch send 1,000 messages at a time, converting 000s of API requests into a single call.
Being able to define
DeliveryMethod
classes that were instantiated and enqueued with a collection of recipients, instead of just a single recipient would be nice.Something like this pseudocode is what I imagine:
This would require some refactoring of the
delivery
,deliver_later
andrun_delivery
methods inNoticed::Base
to batch and loop recipients if theDeliveryMethod
supported it.Not sure if the gains in efficiency and scalability would make it worthwhile though?
Originally posted by @SirRawlins in #83 (comment)
The text was updated successfully, but these errors were encountered: