r/node • • Feb 27 '26

Postgres for everything, how accurate is this picture in your opinion?

Post image

For those interested Image from the book "Just use postgres"

267 Upvotes

75 comments sorted by

View all comments

Show parent comments

8

u/TimMensch Feb 27 '26

That sounds more like the DynamoDB use case.

If they don't need performance, then why do they need Redis at all? Why not just do a database lookup?

Pretty much the entire point of Redis is to be fast. Running it locally on every app server instance is another common strategy just to reduce network round trip times.

Atomicity is just a bonus feature that you can use if you need it.

4

u/MadeWithPat Feb 28 '26

I’d argue atomicity is more than nice to have - it’s kind of a key piece to BullMQ / using Redis for queues in general

1

u/TimMensch Feb 28 '26

If you need it you need it. The comment I'm replying to was claiming that some apps didn't need it.

I know how it all works and that's it's critical for reliable queues.

1

u/MadeWithPat Feb 28 '26

I’m just highlighting that you mentioned BullMQ then categorized atomicity as a nice to have. That’s all.

1

u/TimMensch Feb 28 '26

That fails under the "if you need it" clause at the end of the same sentence where I say it's nice to have. Using BullMQ would be a case of needing it. 🤷‍♂️

1

u/Coffee_Crisis Feb 28 '26

if you already have a high performing postgres db why wouldn't you use it to cache things?

1

u/TimMensch Feb 28 '26

If you're doing something that's low traffic, there's really low latency to your underutilized Postgres server, and there's no requirement for consistent performance of your cache? Sure. Fine. Use Postgres.

But understand the tradeoffs. Learn enough that you don't need to ask randos on the internet why you should or shouldn't make an architectural decision.

Postgres is a bottleneck if you need to be able to scale. There's only so much you can do with scaling vertically, and scaling horizontally pretty much only scales reads (unless you're using one of the forks that splits Postgres into shards, but in that case you'll probably not have access to the vector search or time series features--and also in that case, using a memory cache is a lot faster).

Redis is a known quantity for caching with a lot of features with well-understood performance characteristics. The wire protocol is brain-dead simple. You can inject custom logic on the server using Lua. It supports lists and hashes and incrementing elements and expiring keys and much more out of the box.

Postgres can be more like using heavy machinery to do minor garden work. Sure it can do it, but sometimes smaller, specialized tools really are the right answer. There's a reason all of those database startups make those claims about specialized tools: They really can be better for a job.

The thing is that there are tradeoffs. Among other things, many of those other tools require paid usage contracts. But maintaining them and dealing with backups can be substantial amounts of extra work compared to just using Postgres.

Whereas spinning up Redis as a memory cache without any long term storage is practically free. If you're using containers already, it's pasting in the correct docker config. It's a cache, so in the basic use case there's no need for backups or maintenance. If you have a bug that fails to delete keys or set timeouts correctly, you can just reboot it and have it start over from scratch.

There's a reason so many projects use Redis.

1

u/Coffee_Crisis Feb 28 '26

Sure, but most businesses don’t actually have significant scale