This seems to come up on HN at least once a year. Sure it can work but LISTEN ties up a connection which limits scalability as connections are limited and expensive. Also, mitigation strategies like PgBouncer cannot be used with this approach (nor can scale out solutions like CitusDB I don't think). Of course, if scalability is not a concern (or the connection limitations are eventually fixed in postgres - this has i…
Supabase's Realtime [1] is one of the solutions that can help with that. Although it doesn't exactly let you LISTEN at scale, but it allows the applications to be notified on changes in the database. > Listen to changes in a PostgreSQL Database and broadcasts them over WebSockets [1]: https://github.com/supabase/realtime Disclosure: I'm a Supabase employee.
Postgres is a great pub/sub and job server (2019)
151–160 of 209 posts
Re: Postgres is a great pub/sub and job server (2019)
#152Re: Postgres is a great pub/sub and job server (2019)
#153Earlier quoted context omitted.
What is your idea of 'most cases'? I've personally written real-time back-of-house order-tracking with rails and postgres pubsub (no redis!), and wrote a record synchronization queuing system with a table and some clever lock semantics that has been running in production for several years now -- which marketing relies upon as it oversees 10+ figures of yearly topline revenue. Neither of those projects were FAANG scal…
>some clever lock semantics Most senior+ engineers that I know would hear that and recoil. Getting "clever" with concurrency handling in your home-rolled queuing system is not something that coworkers, especially more senior coworkers, will appreciate inheriting, adapting, and maintaining. Believe me. I get that you're trying to flex some cool thing that you built, but it doesn't really have any bearing on the concep…
Re: Postgres is a great pub/sub and job server (2019)
#154Re: Postgres is a great pub/sub and job server (2019)
#155Doesn't LISTEN connection holds transaction and therefore prevent vacuuming of old rows?
Re: Postgres is a great pub/sub and job server (2019)
#156Earlier quoted context omitted.
Only for hundreds of thousands of messages per day, that's way too big of a server. But if you look on the rest of the thread, it doesn't do only that. Anyway, for a server that only does pub/sub with ACID guarantees, those specs are so large that there is certainly a bottleneck before they matter. So it wouldn't be strange if somebody gets one that can't even handle that, it just would mean that there is some issue…
Is your point that the server has room to grow? Or that you just “ain’t impressed by that”?
Re: Postgres is a great pub/sub and job server (2019)
#157Author here! A few updates since this was published two years ago: - The service mentioned (now called https://webapp.io ) eventually made it into YC (S20) and still uses postgres as its pub/sub implementation, doing hundreds of thousands of messages per day. The postgres instance now runs on 32 cores and 128gb of memory and has scaled well. - We bolstered Postgres's PUBLISH with Redis pub/sub for high traffic code p…
This is not much load at all, an iPhone running RabbitMQ could process many millions of messages per day. Even 1M messages per day is only 11 messages per second average. i.e. not taxing at all.
Re: Postgres is a great pub/sub and job server (2019)
#158If you're already using Postgres, you can avoid increasing operational complexity by introducing another database. Less operational complexity means better availability.
You can atomically modify jobs and the rest of your database. For example, you can atomically create a row and create a job to do processing on it.
Re: Postgres is a great pub/sub and job server (2019)
#159Earlier quoted context omitted.
Why should I rely on yet another microservice when I have PostgreSQL right there?
Everything is a nail, why should I use anything but this hammer?
Re: Postgres is a great pub/sub and job server (2019)
#160Earlier quoted context omitted.
> doing hundreds of thousands of messages per day > The postgres instance now runs on 32 cores and 128gb of memory and has scaled well. Am I the only one?
I should've clarified, the database handles more than just the "regular" pub/sub, some of the tables have over a billion rows.