Re:Do you really need Redis? How to get away with just Postg...
by taffer on Saturday June 12, 2021 @05:41PM
(#27487649)
You need one connection per worker thread, and realistically you would only have one worker per cpu core. So how many LISTENing connections do you really need?
[ Parent
| on HN ]
Re:Do you really need Redis? How to get away with just Postg...
by sa46 on Saturday June 12, 2021 @06:49PM
(#27488057)
You generally have more than one database connection per thread. As an example, consider Node.js which acts like a single threaded process. You’d probably want to be able to handle more than 1 database query concurrently since network latency tends to dominate OLTP requests.
How you setup LISTEN and NOTIFY is app dependent. In a multi-tenant database, you could have 1 NOTIFY channel per tenant.
As you scale, you probably do something that listens in a smarter way, maybe 1 Go channel per client with a single LISTEN instead of 1 database connection per client. The downside is that now the app code is responsible for tenant isolation instead of the database.
Re:Do you really need Redis? How to get away with just Postg...
by taffer on Sunday June 13, 2021 @07:43AM
(#27491724)
> [...] since network latency tends to dominate OLTP requests.
You are absolutely right about that. However, in this case we are talking about background workers. I would argue that background workers, such as an image resizing worker, are typically CPU-bound and do not perform high-volume OLTP queries. Therefore, a background worker does not require multiple database connections per thread as a web server would.