schema_version: 1 decision: id: queue-between-api-and-worker title: A queue between the API and the worker status: accepted date: 2026-09-16 elements: [api, queue, worker] diagrams: [0200-containers/online-shop.archify] context: > Order confirmation emails and invoices were sent inside the checkout request. A slow mail provider made checkout slow; a failing one made checkout fail. decision: > The API enqueues a job per side effect on SQS. One worker service consumes the queue and does the slow work. Checkout returns as soon as the order is stored. consequences: > Emails arrive seconds later, not instantly. Jobs must be idempotent because SQS delivers at least once. The worker is the second place that writes to the database.