zlacker

[return to "Choose Postgres queue technology"]
1. 5id+k9[view] [source] 2023-09-24 21:33:48
>>bo0tzz+(OP)
One of the biggest benefits imo of using Postgres as your application queue, is that any async work you schedule benefits from transactionality.

That is, say you have a relatively complex backend mutation that needs to schedule some async work (eg sending an email after signup). With a Postgres queue, if you insert the job to send the email and then in a later part of the transaction, something fails and the transaction rollbacks, the email is never queued to be sent.

◧◩
2. thepti+dg[view] [source] 2023-09-24 22:37:30
>>5id+k9
Worth being clear that bridging to another non-idempotent system necessarily requires you to pick at-least-once or at-most-once semantics. So for emails, if you fail awaiting confirmation of your email you still need to pick between failing your transaction and potentially duplicating the email, or continuing and potentially dropping it.

The big advantage is for code paths which async modify your DB; these can be done fully transactionally with exactly-once semantics since the Job consumption and DB update are in the same transaction.

◧◩◪
3. skybri+Dj[view] [source] 2023-09-24 23:09:17
>>thepti+dg
Email might never arrive, though. The only way to know they got it is to have them follow a link to confirm.
◧◩◪◨
4. collin+jG[view] [source] 2023-09-25 03:41:12
>>skybri+Dj
That's kind of missing the parent's point. If you wanted to ensure emails arrive, that sounds like another queue that could be backed by a different table that is also produced into as part of the original transaction.
[go to top]