zlacker

[return to "Postgres is a great pub/sub and job server (2019)"]
1. osigur+Fh[view] [source] 2021-12-18 00:45:32
>>anonu+(OP)
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 improved in 14), this would be a very viable approach.

◧◩
2. gurjee+bD[view] [source] 2021-12-18 04:12:12
>>osigur+Fh
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.

◧◩◪
3. cpursl+Ij1[view] [source] 2021-12-18 13:06:51
>>gurjee+bD
I like Supabase's approach over pub/sub. One of the big advantages is they listen to the Postgres WAL which overcomes the 8000 bytes limitation[1] of the notify approach.

And Elixir is especially well suited for this type of workload. I actually extracted out much of the Supabase Realtime library so that I could work with the data directly in Elixir[2]

[1]: https://github.com/supabase/realtime#why-not-just-use-postgr...

[2]: https://github.com/cpursley/walex

[go to top]