Skip to content

[Mailer] Better explain the load-balancing options #12301

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

Merged
merged 1 commit into from
Sep 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions components/mailer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,37 @@ binary. For third-party providers, refers to the following table:
Sendgrid smtp://apikey:KEY@sendgrid n/a api://KEY@sendgrid
==================== ================================== ================================== ================================

Failover Transport
------------------
Load Balancing
--------------

You can create failover transport with the help of `||` operator::
Symfony's mailer supports `load balancing`_ so you can distribute the mailing
workload across multiple transports. There are two main techniques to balance
the load: failover and round-robin.

Failover Load Balancing
~~~~~~~~~~~~~~~~~~~~~~~

A failover transport is configured with two or more transports joined by the
``||`` operator::

$dsn = 'api://id@postmark || smtp://key@sendgrid';

So if the first transport fails, the mailer will attempt to send through the
second transport.
The mailer will start using the first transport. If the sending fails, the
mailer won't retry it with the other transports, but it will switch to the next
transport automatically for the following deliveries.

Round Robin
-----------
Round-Robin Load Balancing
~~~~~~~~~~~~~~~~~~~~~~~~~~

If you want to send emails by using multiple transports in a round-robin fashion,
you can use the ``&&`` operator between the transports::
A round-robin transport is configured with two or more transports joined by the
``&&`` operator::

$dsn = 'api://id@postmark && smtp://key@sendgrid'

The mailer will start using the first transport and if it fails, it will retry
the same delivery with the next transports until one of them succeeds (or until
all of them fail).

Sending emails asynchronously
-----------------------------

Expand Down Expand Up @@ -167,3 +180,5 @@ Learn More

To learn more about how to use the mailer component, refer to the
:doc:`Symfony Framework Mailer documentation </mailer>`.

.. _`load balancing`: https://en.wikipedia.org/wiki/Load_balancing_(computing)