Live data from Hacker News

Redis is fast – I'll cache in Postgres

dizzy.zone

241–250 of 311 posts

Re: Redis is fast – I'll cache in Postgres

#241

Having the ability to set a TTL on the cache key is a critical feature of a cache, not something that can be tacked on later. I always find these "don't use redis" posts kind of strange. Redis is so simple to operate at any scale, I don't quite get why it is important to remove it.

Postgres nationalists will applaud the conclusion no matter how bad the reasoning is.

Don't get me wrong, the idea that he wants to just use a RDMBS because his needs aren't great enough, is a perfectly inoffensive conclusion. The path that led him there is very unpersuasive.

It's also dangerous. Ultimately the author is willing to do a bit more work rather than learn something new. This works because he's using a popular tool people like. But overall, he doesn't demonstrate he's even thought about any of the things I'd consider most important; he just sort of assumes running a Redis is going to be hard and he'd rather not mess with it.

To me, the real question is just cost vs. how much load the DB can even take. My most important Redis cluster basically exists to take load off the DB, which takes high load even by simple queries. Using the DB as a cache only works if your issue is expensive queries.

I think there's an appeal that this guy reaches the conclusion someone wants to hear, and it's not an unreasonable conclusion, but it creates the illusion the reasoning he used to get there was solid.

I mean, if you take the same logic, cross out the word Postgres, and write in "Elasticsearch," and now it's an article about a guy who wants to cache in Elasticsearch because it's good enough, and he uses the exact same arguments about how he'll just write some jobs to handle expiry--is this still sounding like solid, reasonable logic? No it's crazy.

Re: Redis is fast – I'll cache in Postgres

#242
post #238
post #234

Earlier quoted context omitted.

So your big advantage is that nobody has lauched agentic tools for the end user yet?

Anyone can learn to unblock a sink by watching YouTube videos these days, and yet most people still hire a professional to do it for them. I don't think end users want to "optimize their PostgreSQL servers" even if they DID know that's a thing they can do. They want to hire experts who know how to make "that tech stuff" work.

I agree that people like to hire profesionals. That is why I hire db experts to work on our infra, not prompt engenieers.

Saying that anybody can learn to unblock a sink by watching youtube is your tipical HN mentality of stating opinons as facts.

Re: Redis is fast – I'll cache in Postgres

#243

Earlier quoted context omitted.

"If we don't need performance, we don't need caches" feels like a great broader takeaway here.

Sometimes, a cache is all about reducing expense: I.e, free cache query vs expensive API query.

Sometimes people host software on a server they own or rent, the server is plenty fast, and it costs literally nothing to issue those queries at the scale on which they’re needed.

Re: Redis is fast – I'll cache in Postgres

#244
post #14

If you use an UNLOGGED table in Postgres as a cache, and your DB restarts, you no longer have a cache. Then your main table gets a huge spike in traffic and likely grinds to a halt.

Not quite - if you have a crash / hard restart, the table is truncated. If Postgres gracefully shuts down, the data is retained.

Re: Redis is fast – I'll cache in Postgres

#245

Having the ability to set a TTL on the cache key is a critical feature of a cache, not something that can be tacked on later. I always find these "don't use redis" posts kind of strange. Redis is so simple to operate at any scale, I don't quite get why it is important to remove it.

It's not like it's bad, it's more like cutting down on the amount of systems you need to operate.

I have been running Redis for years as a cache and have spent less than 5 cumulative minutes "operating" it.

I'm a big "just use Postgres" fan but I think Redis is sufficiently simple and orthogonal to include in the stack.

Re: Redis is fast – I'll cache in Postgres

#246

> Both postgres and redis are used with the out of the box settings Ugh. I know this gives the illusion of fairness, but it's not how any self-respecting software engineer should approach benchmarks. You have hardware. Perhaps you have virtualized hardware. You tune to the hardware. There simply isn't another way, if you want to be taken seriously. Some will say that in a container-orchestrated environment, tuning go…

[deleted]

Re: Redis is fast – I'll cache in Postgres

#247

> Both postgres and redis are used with the out of the box settings Ugh. I know this gives the illusion of fairness, but it's not how any self-respecting software engineer should approach benchmarks. You have hardware. Perhaps you have virtualized hardware. You tune to the hardware. There simply isn't another way, if you want to be taken seriously. Some will say that in a container-orchestrated environment, tuning go…

[deleted]

Re: Redis is fast – I'll cache in Postgres

#248
As expected, Postgres - especially with Unlogged Tables - is fast enough; additionally, having less things to run on your infrastructure and fewer integrations to manage in your app is a hugely underrated benefit.

I am just a little bit surprised on the relatively low write performance for both Postgres and Redis here; but as I can see, the tests were run on just 2 CPUs and 8 GB of RAM machine. In my experience, with 8 CPUs, Postgres can easily handle more than 15 000 writes per second using regular tables; I would imagine that it can easily be 20 000+ for the Unlogged variety - who needs more than that to cache?

Re: Redis is fast – I'll cache in Postgres

#249
post #242
post #238

Earlier quoted context omitted.

Anyone can learn to unblock a sink by watching YouTube videos these days, and yet most people still hire a professional to do it for them. I don't think end users want to "optimize their PostgreSQL servers" even if they DID know that's a thing they can do. They want to hire experts who know how to make "that tech stuff" work.

I agree that people like to hire profesionals. That is why I hire db experts to work on our infra, not prompt engenieers. Saying that anybody can learn to unblock a sink by watching youtube is your tipical HN mentality of stating opinons as facts.

you can become a db expert with the right prompts

Re: Redis is fast – I'll cache in Postgres

#250

Earlier quoted context omitted.

> for only about five minutes of LLM query or web search I think I have more trust in the PG defaults that in the output of a LLM or copy pasting some configuration I might not really understand ...

> copy pasting some configuration I might not really understand Uh, yea... why would you? Do you do that for configurations you found that weren't from LLMs? I didn't think so. I see takes like this all the time and I'm really just mind-boggled by it. There are more than just the "prompt it and use what it gives me" use cases with the LLMs. You don't have to be that rigid. They're incredible learning and teaching too…

My comment is mainly in opposition to the "five minutes" part from parent.

If you have 5 minutes then you can't as you say :

> Then I will dig deeper into those things myself ...

So my point is I don't care if it's coming from LLM or a random blog, you won't have time to know if it's really working (ideally you would want to benchmark the change).

If you can't invest the time better to stay with the defaults, which in most project the maintainers spent quite a bit of time to make sensible.

Post reply on HN