4 ms·
Can 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 ea
by fyp 7y ago
Can 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 per LISTEN query and also how many channels is too much.
- colinchartier 7y agoYou can listen multiple times per database connection. I'm not sure what the maximum scale is, but I've never hit it.
- osigurdson 7y agoBased on what I have read and some experimentation, I concluded that it will not scale very well beyond ~500 listener processes because there needs to be one persistent connection per listener. Furthermore, my understanding is using pgbouncer will not help since it needs to use session pooling in order to support LISTEN.