News for hackers. Stuff that matters.
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by Eikon on Sunday November 03, 2024 @05:52PM (#42036761)
You know what performs better than redis in this setup? An hashmap.

Why Postgres wouldn’t run on the same server as the app? It’s actually pretty common.

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by secretmark on Sunday November 03, 2024 @06:18PM (#42036914)
What if there are multiple processes that require access to a shared cache?
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by mbreese on Sunday November 03, 2024 @06:31PM (#42036998)
And I think this is the main use case they were looking for. If you have a web app where each request is a separate process/call (not uncommon), and you don’t have a good shared global state, Redis is a great tool. It is an in-memory data structure store that can respond to requests from different processes. I always considered it an evolution from memcached.

If you only have one long lived process or good global variable control, then it is much less appealing in the single-server scenario. Similarly, if you require access from multiple hosts, it becomes a less obvious choice (especially if you already have a database in the loop). And redis is also overkill is you’re using it only as a cache.

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by xxs on Monday November 04, 2024 @04:23AM (#42039887)
>shared cache

As in performance improvement - cache should never be considered a datastore, e.g. you can pull the plug and nothing else happens (aside losing performance). It'd be a lot more beneficial all the processes to have a local cache, themselves. The latter is at least 4 orders of magnitude faster than redis. Now you may like some partitioning, too.

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by secondcoming on Sunday November 03, 2024 @06:06PM (#42036841)
There's more to redis than just being a K/V store.
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by strken on Sunday November 03, 2024 @06:14PM (#42036884)
Perhaps you could elaborate? It would be helpful to understand what Redis can do that cannot be done easily with local memory.

Acting as shared memory for an inherently single-CPU language like JS is one I can think of. However, I don't use Redis, so you'd be better placed to drive the discussion forward with examples.

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by quantadev on Sunday November 03, 2024 @07:48PM (#42037407)
I have Docker running in swarm mode where it will spin up multiple load balanced instances of my web app (where requests can get routed randomly to any instance). So I use Redis to store "User Session Information" so the session can be read/written from any instance, supposedly faster than using a DB.
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by tbrownaw on Sunday November 03, 2024 @09:35PM (#42037898)
When I've used redis to store web sessions, it is in fact acting as a k/v store. The session ID is the key, and the (serialized) session state is the value.
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by quantadev on Sunday November 03, 2024 @10:25PM (#42038142)
Yep, that's what I'm doing too. I bet it's the most common use case for Redis.
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by shakow on Sunday November 03, 2024 @06:15PM (#42036897)
> Perhaps you could elaborate?

IPC, I suppose?

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by mperham on Sunday November 03, 2024 @10:59PM (#42038302)
Redis provides low-level persistent data structures which can be used to implement business logic distributed safely across a number of machines. That’s a LOT harder than in-memory in-process.

My Sidekiq background job system runs entirely on top of Redis. Structures like Sorted Sets become the basis for indexes. Lists provide extremely fast queue behavior and Hashes map easily to persistent objects. Databases, traditionally, have not performed well when used as queues.

Those are the big 3 structures necessary to implement anything: trees, lists and maps.

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by strken on Monday November 04, 2024 @02:27AM (#42039337)
I'm a bit confused here, because the original comment was that "most people will never really see the point of Redis, which is that if it is running on the same machine as the application, it can respond in much less than a millisecond", to which the response was "there's more to redis than just being a K/V store".

I do see the point of Redis if you have multiple hosts, but I was unsure why someone would use it on just one host.

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by mperham on Monday November 04, 2024 @10:20AM (#42042306)
Right, it's still useful as shared data for multiple processes on the same machine. A SQL database mostly forces your data into one structure: the table. Redis instead provides commands which operate directly on those different data structures I mentioned.
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by runeblaze on Sunday November 03, 2024 @11:14PM (#42038372)
Just to add -- sometimes I use Redis when I don't have a trusted impl of HyperLogLog or sorted set (and I have a vague suspicion that I am going to do IPC later -- so not worth it to wrap my own HLL).
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by chipdart on Sunday November 03, 2024 @07:25PM (#42037310)
> There's more to redis than just being a K/V store.

That's perfectly fine. You can compare Redis to other specialized tools just like you can compare it with Postgres and SQLite.

Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by Eikon on Sunday November 03, 2024 @06:07PM (#42036846)
There’s more data structures in your favorite language std lib than an hashmap, at least, I hope so :)
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by ummonk on Sunday November 03, 2024 @06:08PM (#42036850)
Like?
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by noident on Sunday November 03, 2024 @06:18PM (#42036917)
Re:Do you need Redis? PostgreSQL does queuing, locking, and ... by 101011 on Sunday November 03, 2024 @10:39PM (#42038221)
TIL about a Cuckoo Filter.

Also, never realized redis has native support for a Bloom Filter.