Search code examples
djangodjango-admindjango-signalsdjango-email

Django smpt email backend slowing down performance


I'm developing/serving currently locally.

I'm using django-admin for internal users to add items.

I add in my signal code. My signal is post_save and it's purpose is to send an email to a user for approval. I test my signal using console.EmailBackend

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

I add a new item, there is no performance impact to the web browser. My models item page reloads quickly.

I update my EMAIL_BACKEND too use smpt details

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

I add a new item, the performance impact is massive, my web browser now takes 15-30 seconds to to reload the items page after adding.

Any thoughts around why the performance is so terrible?


Solution

  • Real e-mail send is slow in nature.

    I recommend recommend sending an email using asynchronous Queue task. For example Celery is good library for asynchronous Queue task.