Redis as a database (2021)
medium.com
medium.com
KVRocks: Backed by RocksDB https://github.com/apache/kvrocks
Tendis: Backed by RocksDB https://github.com/Tencent/Tendis
Tidis: Distributed, backed by TiKV https://github.com/tidb-incubator/tidis
You're still designing the system the same way... your main considerations are still, "why/how is it OK if this thing is reset/cleared/rolled-back at any moment?" and "why/how is the data here up-to-date/recent enough for my cases?"
I've also heard of it as a database for online game scoring systems.
That said, I think the fact that Redis stores everything in memory can make it unsuitable for certain projects as a database where only a small fraction of the whole data set is ever exposed to users at any given time.
Which do you prefer, simple APIs, or SQL?
Once I had it working and could attach hundreds of tags to each of the millions of data objects (Didgets); the whole system started to look like a sparse relational database table. So I used the tagging system to create tables and run queries against them. It turned out to be extremely flexible and fast.
To my surprise, it could often outperform traditional DB systems like SQLite or PostgreSQL. https://www.youtube.com/watch?v=Va5ZqfwQXWI
The demoe/paper on Quake vm's migrating across servers in particular had some cool techniques for incremental snapshotting. It d send over one image of memory, let the game-server keep running, track what was changing, then send those deltas to the other server. Trying to re-snapshot an entire in-memory database feels sizable, but for slowly changing data incremental snapshots feel like they have potential.
With redis's persistance mechanisms (RDP + AOF), I see how one could set up their own CDC on top of those (tailing the AOF and reimplementing the redis instruction protocol to convert that to proper data changes), but does anyone know of a more structured way of piping out a change log?
I don't see anything obvious like a debezium connector.
But IMO, I'd be weary about data durability with Redis.
For example we have a service that writes that continuously does circular writes to a redis database to keep 200 megs up to date for other services to read from.
A lot of time is taken recalculating the data being updated. But its the best way we've found to eventually update even when things are going wrong.
Databases are cool but I don’t see how this is #10 on HN.
My position is that memcache is still a better cache (with a suitable static type system and serializer) and postgres is still a better database.
I think Redis is great in the space of "I need a little bit more structure than memcache", but if you're rising to the level of unscrewing a data structure or needing nontrivial types, then Redis was not the tool for that job.
Edit: worth noting when you under-engineer something for Redis, it's far more difficult to get it out again later than it is to add more schema to a relational DB.
I'd not recommend it for heavy-use in Production.
autocomplete = inproc caching (no network turnaround). We do that.
job queue = SQS / RabbitMQ. we do that (SQS)