OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Improve Azure Email sending performance

Open BenedekFarkas opened this issue 3 months ago • 5 comments

Describe the bug

Sending an email through Azure Email Communication Services locks the foreground thread for the duration of sending the email, which usually takes 5-6 seconds (sometimes considerably more).

Orchard Core version

Since 2.0.0, when this feature was added in #15254.

To Reproduce

  1. Configuration Azure Email (instead of SMTP).
  2. Use the Email Test functionality on the Admin or set up a simple workflow that sends an email.

Observe that communication with AECS takes several seconds.

Expected behavior

While we cannot influence the behavior of AECS, we might find a way to trigger sending the email in a fire-and-forget fashion.

Logs and screenshots

See my previous comments on the PR: https://github.com/OrchardCMS/OrchardCore/pull/14749#issuecomment-1864735956 and https://github.com/OrchardCMS/OrchardCore/pull/14749#issuecomment-1866264091.

BenedekFarkas avatar Oct 05 '25 20:10 BenedekFarkas

We don't want to send e-mails in a fire and forget fashion, because then we won't know if sending fails (both for logging and showing it to the user, if it happened due to a user interaction).

Piedone avatar Oct 05 '25 21:10 Piedone

Let me know if you need a help on this

hishamco avatar Oct 05 '25 21:10 hishamco

That makes sense, although I'd imagine that in a non-business-critical scenario someone would opt to send it fast (and not block the page load) rather than reliably, if there's a choice.

Background/batch processing (in parallel) would be ideal, although in a user-triggered workflow some user interaction might still depend on sending the email, so it has to wait for it. On the other hand, if sending the email is the last step in the workflow execution, then it doesn't have to block the main thread (that's what I meant by fire-and-forget). Could be achieved by two different email activities and it's up to the user to choose.

I won't have time to work in this in the foreseeable future (before Harvest) for sure, so Hisham if you're interested, don't hold back!

BenedekFarkas avatar Oct 06 '25 20:10 BenedekFarkas

locks the foreground thread for the duration of sending the email

But it's the "foreground" thread only on the test page, right? An improvement could be to use an ajax call with a "waiting" notification (gif, text, ...) and check if it's done. But nothing server side to change IMO.

sebastienros avatar Oct 09 '25 17:10 sebastienros

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

github-actions[bot] avatar Oct 09 '25 17:10 github-actions[bot]