zlacker

[return to "Do you really need Redis? How to get away with just PostgreSQL"]
1. pilif+p9[view] [source] 2021-06-12 08:43:02
>>hyzyla+(OP)
For pub/sub, I would recommend against using PostgreSQL if you're doing it at any kind of scale because LISTEN ties up one connection completely and Postgres connections are very expensive compared to a redis connection.
◧◩
2. postgr+O81[view] [source] 2021-06-12 18:51:47
>>pilif+p9
> LISTEN ties up one connection completely

I've seen this twice in this thread, but I don't know what that means. Can you explain a bit?

◧◩◪
3. sa46+Di1[view] [source] 2021-06-12 20:33:52
>>postgr+O81
When a client connects to Postgres, Postgres creates a new process just for that client. Separate processes are great for isolation but it means Postgres connections are a bit expensive (this is an active area of improvement). Postgres really starts to struggle once you a have a few thousand connections, even if those connections aren’t doing anything.

The common workaround is to use a connection pooler like PGBouncer so that clients reuse connections. This approach doesn’t work for LISTEN because typically a client will listen for its entire lifecycle so you can’t share connections in a pool.

◧◩◪◨
4. postgr+fd2[view] [source] 2021-06-13 08:09:34
>>sa46+Di1
> This approach doesn’t work for LISTEN because typically a client will listen for its entire lifecycle so you can’t share connections in a pool.

But you only need one connection for LISTEN per database, total. So I'm confused why this is made out to be a big issue.

[go to top]