Repaso
EspaƱol
System DesignCoreSD-36

Why put a message queue between an order service and an email service?

Options

  1. To make the emails arrive much faster to users
  2. To decouple them; emails are handled later (Correct option)
  3. Queues replace the need for a real database
  4. To encrypt each email that is being sent out

Answer

To decouple them: the order service drops a message and continues; the email service processes it when it can, even if it was briefly down

Why

Without a queue, the order service calls the email service directly and must wait; if the email service is down, the order request fails.

With a queue (RabbitMQ, SQS, Kafka) the order service just publishes 'order created' and responds to the user immediately. The email service reads messages at its own pace and catches up after outages.

This is asynchronous communication.

Remember

Queue = decouple producer and consumer; work happens later.

Key terms

Practice this question in Repaso