Our application needs to send email notofications to users. Sometimes a large amount of users are notified about a single event. Now we do it in straightforward (and maybe naive) way: 

  • Get list of users from DB (using aggregate)
  • Iterate through the aggregate results list (each record has a single user email address)
  • Send an individual email to a particular user at each iteration

It all works fine in test environments, but there is a concern: in production the number of users to notify at once can be as large as about 20000.

Are there any limitats we can potentially hit in this situation? I mean both exlicit limits (like maximun number of emails to send from a server within an hour, set by admin or by licence, etc...) and phisical server capacity limits (like the size of system email queue, memory and CPU usage...)

If the naive way I described is not likely to work, what options do we have to workaround limitations (like implement a queue manually and send a small number emails every 5 minutes, or so...)

Thank you.

Alexander Hagen-Thorn wrote:

Our application needs to send email notofications to users. Sometimes a large amount of users are notified about a single event. Now we do it in straightforward (and maybe naive) way: 

  • Get list of users from DB (using aggregate)
  • Iterate through the aggregate results list (each record has a single user email address)
  • Send an individual email to a particular user at each iteration

It all works fine in test environments, but there is a concern: in production the number of users to notify at once can be as large as about 20000.

Are there any limitats we can potentially hit in this situation? I mean both exlicit limits (like maximun number of emails to send from a server within an hour, set by admin or by licence, etc...) and phisical server capacity limits (like the size of system email queue, memory and CPU usage...)

If the naive way I described is not likely to work, what options do we have to workaround limitations (like implement a queue manually and send a small number emails every 5 minutes, or so...)

Thank you.


I don't think there is a limitation on how many email notifications it can send but actions and timers have timeouts. You can try to up the timeout or implement a way to tag the users that you have already sent the email to already then wake up the timer again before the set timeout then just continue on the users that wasn't included on the past runs.

Hi Alexander,

OutSystems uses SMTP providers to send email so it will depend more on SMTP server instead of OutSystems. OutSystems may timeout if server action runs longer for email sending I don't think it has more involvement.

Regarding correct approach of sending large number of emails you should use timer and along with that you should also do it in batches like few emails in every run and trigger the timer again (using wake timer action) if records are pending.

I agree with what Nikhil wrote. 

It depends on the used SMTP server. If you ever tried using Gmail for sending emails with Outsystems you will notice that you cannot send thousands of emails at once, they get throttled by Gmail.


Solution

Hi Alexander,

Emails are being sent asynchronously by the OutSystems Scheduler Service. 

The Send Email tool basically renders the email content and adds it to a queue. After that, the Scheduler Service periodically picks up emails from this queue and sends them out asynchronously.

If you're on an On-Premise environment, you could configure the maximum concurrent jobs that can be executed at the same time by each Front-End in the Configuration Tool.

Also, if you have multiple Front-Ends you can configure multiple servers to be able to send out emails.

Other limitations depend on the SMTP server being used by the platform, as Nikhil explained.

Regards,

Nordin

Solution