Skip to content

Commit 9c3761c

Browse files
committed
Docs: add info on batch send performance
1 parent 0a95f13 commit 9c3761c

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

docs/tips/index.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,4 @@ done with Anymail:
1212
django_templates
1313
securing_webhooks
1414
test_backend
15-
16-
.. TODO:
17-
.. Working with django-mailer(2)
18-
.. Sharing backend connections (sessions)
19-
15+
performance

docs/tips/performance.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. _performance:
2+
3+
Batch send performance
4+
======================
5+
6+
If you are sending batches of hundreds of emails at a time, you can improve
7+
performance slightly by reusing a single HTTP connection to your ESP's
8+
API, rather than creating (and tearing down) a new connection for each message.
9+
10+
Most Anymail EmailBackends automatically reuse their HTTP connections when
11+
used with Django's batch-sending functions :func:`~django.core.mail.send_mass_mail` or
12+
:meth:`connection.send_messages`. See :ref:`django:topics-sending-multiple-emails`
13+
in the Django docs for more info and an example.
14+
15+
(The exception is when Anymail wraps an ESP's official Python package, and that
16+
package doesn't support connection reuse. Django's batch-sending functions will
17+
still work, but will incur the overhead of creating a separate connection for each
18+
message sent. Currently, only SparkPost has this limitation.)
19+
20+
If you need even more performance, you may want to consider your ESP's batch-sending
21+
features. When supported by your ESP, Anymail can send multiple messages with a single
22+
API call. See :ref:`batch-send` for details, and be sure to check the
23+
:ref:`ESP-specific info <supported-esps>` because batch sending capabilities vary
24+
significantly between ESPs.

0 commit comments

Comments
 (0)