Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
61–70 of 82 posts
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#62Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#63https://github.com/pgmq/pgmq
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#64I haven't done a project that uses a database (be it sql or no sql) where the amount of deletes is comparable to the amount of inserts (and far larger than like tens per day, of course).
How does your average db server work with that, performance wise? Intuitively I'd think it's optimized more for inserts than for deletes, but of course I may be wrong.
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#65Why use string as status, instead of a boolean? That just wastes space for no discernable benefit, especially since the status is indexed. Also, consider turning event_type into an integer if possible, for similar reasons. Furthermore, why have two indexes with the same leading field (status)?
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#66Biggest thing to watch out with this approach is that you will inevitably have some failure or bug that will 10x, 100x, or 1000x the rate of dead messages and that will overload your DLQ database. You need a circuit breaker or rate limit on it.
This is the same risk with any DLQ. The idea behind a DLQ is it will retry (with some backoff) eventually, and if it fails enough, it will stay there. You need monitoring to observe the messages that can't escape DLQ. Ideally, nothing should ever stay in DLQ, and if it does, it's something that should be fixed.
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#67Great application of first principles. I think it's totally reasonable also, at even most production loads. (Example: My last workplace had a service that constantly roared at 30k events per second, and our DLQs would at most have orders of hundreds of messages in them). We would get paged if a message's age was older than an hour in the queue. The idea is that if your DLQ has consistently high volume, there is somet…
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#68Ofc I wouldn't us it for extremely high scale event processing, but it's great default for a message/task queue for 90% of business apps. If you're processing under a few 100m events/tasks per day with less than ~10k concurrent processes dequeuing from it it's what I'd default to. I work on apps that use such a PG based queue system and it provides indispensable features for us we couldn't achieve easily/cleanly with…
Very few things dna start at an extremely high scale event processing. There’s also an order of magnitude higher events when doing event based work in processing. This seems like a perfectly reasonable starting and gateway points that can have things organized for when the time comes. Most things don’t scale that big.
[1] https://www.adyen.com/knowledge-hub/design-to-duty-adyen-arc...
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#69It uses the same core primitives people are discussing here (FOR UPDATE SKIP LOCKED for claiming work; LISTEN/NOTIFY to wake workers), plus priorities, scheduled jobs, retries, heartbeats/visibility timeouts, and SQL-friendly observability. If you’re already on Postgres and want a pragmatic “just use Postgres” queue, it might be a useful reference / drop-in.
Re: Using PostgreSQL as a Dead Letter Queue for Event-Driven Systems
#70Earlier quoted context omitted.
Which system is immune to all downtime except the DC getting nuked?
Properly designed distributed systems. Challenge: Design a fault tolerant event-driven architecture. Only rule, you aren’t allowed to use a database. At all. This is actually an interview question for a top employer. Answer this right and you get a salary that will change your life.