System design hack: Postgres is a great pub/sub and job server
11–20 of 162 posts
Re: System design hack: Postgres is a great pub/sub and job server
#12If you're working with Ruby I have had good experiences with Que[1], which implements a pattern similar to the OP using advisory locks. [1]: https://github.com/que-rb/que
I really like the look of this approach, but don't want to build it myself if I can avoid it.
Re: System design hack: Postgres is a great pub/sub and job server
#13If you're working with Ruby I have had good experiences with Que[1], which implements a pattern similar to the OP using advisory locks. [1]: https://github.com/que-rb/que
Is there a similar library in Python? I really like the look of this approach, but don't want to build it myself if I can avoid it.
Re: System design hack: Postgres is a great pub/sub and job server
#14The use case I have in mind has a lot of logically separate queues. Is it better for each queue to have its own channel (so subscribers can listen to only the queue they need) or have all queues notify a global channel (and have subscribers filter for messages relevant to them). I am mainly confused about whether I need a dedicated db connection per LISTEN query and also how many channels is too much.
Re: System design hack: Postgres is a great pub/sub and job server
#15Can someone share their experience with scaling pg's NOTIFY and LISTEN? The use case I have in mind has a lot of logically separate queues. Is it better for each queue to have its own channel (so subscribers can listen to only the queue they need) or have all queues notify a global channel (and have subscribers filter for messages relevant to them). I am mainly confused about whether I need a dedicated db connection…
I'm not sure what the maximum scale is, but I've never hit it.
Re: System design hack: Postgres is a great pub/sub and job server
#16If you're working with Ruby I have had good experiences with Que[1], which implements a pattern similar to the OP using advisory locks. [1]: https://github.com/que-rb/que
Re: System design hack: Postgres is a great pub/sub and job server
#17If you're working with Ruby I have had good experiences with Que[1], which implements a pattern similar to the OP using advisory locks. [1]: https://github.com/que-rb/que
I wish all these libraries agreed on a common schema >_<
Re: System design hack: Postgres is a great pub/sub and job server
#18Re: System design hack: Postgres is a great pub/sub and job server
#19Used the "FOR UPDATE SKIP LOCKED LIMIT 1" trick to implement a job server in PG a few years ago for the first time. It's a great solution.
Re: System design hack: Postgres is a great pub/sub and job server
#20Isn't hijacking a DB as a "distributed" message queue a pretty well trodden path? Enterprises have been doing this for decades.
This pattern falls down if you need to poll the database, because if you have 3 queues and 100 workers you're making 300 queries per poll interval. The feature of postgres that makes this viable in comparison to most other databases is the "channel"