KeyDB – A Multithreaded Fork of Redis
docs.keydb.dev
docs.keydb.dev
I see databases as a programming languages - if they have a proven track record of frequent releases and responsive authors after 5-7 years, they are usable for wider adoption.
Then, has someone independently verified the Jepsen testing framework? https://github.com/jepsen-io/jepsen/
As for verifying Jepsen, I’m not entirely sure what you mean? It’s a non-deterministic test suite and reports the infractions it finds; the infractions found are obviously correct to anyone in the industry that works on this stuff.
Passing a Jepsen test doesn’t prove your system is safe, and nobody involved with Jepsen has claimed that anywhere I’ve seen.
I don't think it matters. Jepsen finds problems. Lots of them. It's not intended to find all the problems. But it puts the databases it tests through a real beating by exercising cases that can happen, but are perhaps unlikely (or unlikely until you've been running the thing in production for quite a while). Having an independent review does nothing, practically, to make the results of the tests better.
In fact, almost nothing gets a perfectly clean Jepsen report. Moreover, many of the problems that are found get fixed before the report goes out. The whole point is that you can see how bad the problems are and judge for yourself whether the people maintaining the project are playing fast and loose or thinking rigorously about their software. There simply isn't a "yeah this project is good to go" rubber stamp. Jepsen isn't Consumer Reports.
You don't audit a fuzzer to say "what if it runs the thing wrong". That's not the point of the fuzzer. The point is to do lots of weird stuff and check that the output of the system matches the expectation of what's produced. If the fuzzer outputs a result that's actually expected, then that's easily determined because you have to critically analyze what comes out of the tool in the first place.
But I would be shocked (and worried) if someone tried to use it as their primary database in production. It just doesn't have enough testing yet and is still missing some features.
Instead, I am promoting it as a tool to do tasks like data analysis and data cleaning. That way it gets a good workout without causing major problems if there is a bug.
Conveniently, we don't have to worry about the consistency properties of KeyDB, because we're not using KeyDB distributed, and never plan to do so. We were only using redis-cluster (again, on a single machine) to take advantage of all cores on a multicore machine, and to avoid long-running commands head-of-line blocking all other requests. KeyDB replaces that complex setup with one that's just a single process — and one that doesn't require clients to understand sharding, or create any barriers to using multi-key commands.
When you think about it, a single process on a single machine is a pretty "reliable backplane" as far as CAP theory goes. Its MVCC may very well break under Jepsen — hasn't been tested — but it'd be pretty hard to trigger that break, given the atomicity of the process. Whereas even if redis-cluster has a perfect Jepsen score, in practice the fact that it operates as many nodes communicating over sockets — and the fact that Redis is canonically a memory store, rather than canonically durable — means that redis-cluster can get into data-losing situations in practice for all sorts of silly reasons, like one node on the box getting OOMed, restarting, and finding that it now doesn't have enough memory to reload its AOF file.
Scaling starts being a real issue with 10,000+ users. Pretty straight forward to write a server on rust with a single machine capable of handling around 5,000 users, assuming stateless requests.
Maybe you were making a joke and I missed it.
It’s a pretty well documented fact SV startups tend to spend a lot of money on over engineering and making technology decisions based on what’s flash-in-pan popular rather than longevity. Any delta on stability you simply make up with sweat and don’t tell anybody about.
Most startups ideas could be fully implemented in cgi-bin gateway scripts in a few days, but that’s not ‘sexy’. Part of it is a mating dance to VCs: the more hip and bleeding edge you seem, the more competent you appear; despite the inverse is an actual reflection of reality. So my comment is in response to that running joke; in a way, a new unstable database that could disappear off the Internet within six months is a great technology to bass your entire start up on, given the above context.
* its been around 2 years since our last use as a paying customer. YMMV.
Now with Rust we can actually manage complexity from multiple threads (if that's even still needed when using an async/evented/eventloop/io_uring-based architecture).
Most developers cannot do multithreading correctly, and unless you're particularly good about it it's just going to introduce not only lots of bugs but also performance problems.
The only folks in that space that seem to do it well are ScyllaDB.
And sorry, but that is multithreading, there are several cores.
but how does this kind of multithreading (one thread per core) is better than proper multithreading (many threads per core)?
Why is it an anti pattern, this is news to me?
And setting up, say, one thread per HTTP request will likely be negligible because blocking I/O is where time is spent anyways..
And we have had non-blocking I/O for quite some time now.
Your I/O should only be done synchronously if it's non-blocking.
Now for disk I/O, it's a more muddy thing, it's actually quite different from networking since it's more transparently managed by the operating system.
Userland threads (or fibers, or stackful coroutines) do scale better though.
I’m not sure it’s valid to say that only SMT is “proper multithreading”, especially since multithreading as a concept predates it by quite a way.
SMT has a quite a few performance issues since resources such as the L1, L2, and branch predictor are shared between the threads, which can lead to contention that hurts the performance of all the SMT threads sharing a physical core.
SMP is no less “proper”, and as core counts have increased significantly on commodity CPUs, the use of spinning threads bound to a single core each has become a common paradigm.
Oversubscription without SMT (i.e. many threads per core) is possible, but unless you have a workload where each thread is I/O bound with a substantial amount of time spent blocking, the overhead of scheduling and context switching means throughput will likely decrease.
Of course it increases latency, since those resources are not fully exclusive to a particular thread anymore.
Whether or not it's a good thing depends on what you care about. You could also argue that a good program would be able to saturate a single superscalar core with a single thread and thus wouldn't benefit from SMT at all, but I think that would be hard to guarantee in practice.
Native multi-threading is used when you have functionality that already works on threads and you don't want to port it.
Multi-thread is not used in the hot path.
A single data-part/shard is served by a single thread.
All it takes is one critical section to not be protected (i.e. locked) to cause a bug. A series of tests can run hundreds of times correctly without detecting the problem. It is only when a context switch happens at a certain microsecond that the error is exposed.
I am a true believer in multithreading as my own code can see tremendous performance gains using it on the latest multi-core CPUs; but tread very carefully when programming in this manner.
B) there’s a lot of tricky stuff with indices on PG and you generally need a DB admin from day 1
C) your comment is probably more appropriate for either layered databases or new fangled stuff like time series or graph db’s etc
Sorry this is absolute nonsense. Any software engineer worth their salary should be comfortable working with RDBMS index concepts and interrogating their relational model to determine best practice and direction for table indexing.
It only really works well if the client can shard the redis command to the right process itself.
Honestly, redis makes pretty sane tradeoffs, it's not worth the added complexity to add multi-threading as it would almost certainly slow it down while it does locking, and redis isn't typically CPU bound (except potentially the LUA stuff, but that's up to the user), so being multi-threaded doesn't really help much.
If you need multi-threading, there are other solutions, but of course they are slower w.r.t latency and throughput, since that's the trade-off.
Some performance number here - https://www.dragonflydb.io/blog/scaling-performance-redis-vs...
For example, if you care most about latency, Redis is still the way to go, while DragonFly seems better at throughput. But, tradeoffs vs tradeoffs and all that yadda yadda.
DragonFly is better at latency too. The latency numbers they are showing are measured at the high throughput. If you were to reduce the throughput, the latency number would be even better. From the same post:
> This graph shows that the P99 latency of Dragonfly is only slightly higher than that of Redis, despite Dragonfly’s massive throughput increase – it's worth noting that if we were to reduce Dragonfly's throughput to match that of Redis, Dragonfly would have much lower P99 latency than Redis. This means that Dragonfly will give you significant improvements to your application performance.
It might be interesting to have, say, a readonly slave builtin as a second threat that might return outdated information, but I doubt how much use you would get out of it.
I am kinda struggling to come up with a scenario where a significant part of the computational need of you app was in Reddis.
It kind of rivals the KDE/Qt deal of "freely licensed when the company goes under" in its effects of the code eventually being community-maintainable once the company doesn't care for it anymore.
5 years is a bit much though.
It's not free software.
BSL-style licenses seem to be a popular choice for databases, thanks to AWS.
Dragonfly is source available which is a completely different thing.
I think the parallels to free software are markedly correct. They're just words after all. It will forever be used in ways incompatible with the OSI definition, showing up after every misuse to correct folks isn't helpful.
You meant free as in beer, right?
Don't blame it on me, that ship has sailed over two decades ago. That's why RMS didn't like the term in the first place. Even if I disagree with RMS on most things, I have to admit I'm 100% with him on this one. It's almost as if the term was coined to create this kind of confusion.
In my opinion, the mental gymnastics around the definition of "open source" led to abominations like CDDL, which was carefully and explicitly designed to make it impossible/impractical/illegal to properly integrate ZFS or DTrace with Linux. CDDL is perfectly "open source" by definition, but its primary purpose was to lock people out of actually using software licensed under it, unless they happen to be running Solaris.
In all this mess, I actually think BSL is cool. It's a legally binding vow to actually make a particular release free (as in freedom) down the line. They could have kept it proprietary (which I think is totally fair), or made vague promises instead.
And yet here we are, with DTrace (CDDL) shipping in macOS, ZFS having shipped in OS X for several releases, and FreeBSD shipping both. Even Windows (on the "insider" builds) has DTrace [1] _shipped by Microsoft_.
That makes any argument that you can't use any of this stuff unless using Solaris looking rather... wrong - and the idea that Sun lawyers would have overlooked FreeBSD, macOS or Windows if the goal were to restrict the software to be used in Solaris is laughable.
In the case of CDDL specifically, even RMS [2] refers to it as a "free software license", though not one which is GPL-compatible.
[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/d...
That's why I personally strongly prefer BSD systems (OpenBSD in particular) and permissively-licensed software.
> That makes any argument that you can't use any of this stuff unless using Solaris looking rather... wrong
The intent was to lock out Linux specifically, otherwise they would've used a more restrictive license.
> [...] and the idea that Sun lawyers would have overlooked [...]
You're not violating the CDDL by linking it with GPL-licensed software, you're violating the GPL. Which goes to show just how devious that move was: even if Sun went belly up with no lawyers left to lift a finger, relicensing Linux with a CDDL linking exception would still be a massive clusterfuck. So Ubuntu & whoever else is shipping zfs.ko is risking getting sued by any of the half a million people who have their code in the kernel.
> In the case of CDDL specifically, even RMS [2] refers to it as a "free software license", though not one which is GPL-compatible.
You can also license your software even more permissively, but hold a patent on it, and not grant a patent license to your users. It would technically be free, but still released with an intent of restricting the freedom of certain users.
That gave me a good laugh. Fantastic bit of insight. I will have to study this case further, thank you for the enlightenment. <3
"We use keydb at work, and I absolutely do NOT recommend it due to its extreme instability, in fact we're currently in the process of switching to dragonfly precisely due to keydb's instability."
Either they didn't even test their own product, lied entirely about the performance, or got the marketing department to write the copy without any input from the development department.
Do you think I also photoshopped this document? https://github.com/dragonflydb/dragonfly/blob/master/docs/me...
Yes, your results are either inaccurate or deceptive at best. I challenge you run to memcached, under all default settings, and Dragonfly, under all default settings, and memtier_benchmark, under all default settings. Performance is reproducibly orders of magnitude slower, and Dragonfly is also much less efficient--consuming more than double the CPU usage for the same workload.
We also created a test Dragonfly cluster mirroring a small percentage of production traffic in order to do a side-by-side comparison with Memcache. Dragonfly consumed 47% higher CPU usage and regressed P99 latency by 22%. Perhaps our workload is unique, but claiming Dragonfly outperforms Memcache the way you do in your marketing material is an outright lie.
It's often used as a cache because it does key-value storage in memory well
I consider it to be cache first, "db" second, with true definition of db first being something that can execute SQL or SQL like statements (such as Cassandra's CQL). It's the same reason I don't call Cassandra a cache, although it can achieve the same result.
true definition of db first being something that
can execute SQL or SQL like statements
Pedantic note: the term "database" existed long before the relational model or SQL existed. Many of the dominant databases of the 80s and 90s (dBase, etc) would not fit your invented definition.Additionally, a lot of "toy" databases like Access can execute SQL statements, so the ability to execute SQL statements isn't necessarily a great way to tell what's a "real" database.
In practical terms, I do agree with you -- if somebody in 2023 is referring to "the database" in their app they had darn well better be talking about something robust and ACID-compliant like Postgres or whatever.
Do you have an example of an use case for which using Redis as a database works significantly better than using say Postgres or MySQL?
You can also add your own data structures to Redis, not as a form of syntax sugar over KV pairs, but as a dynamic library that you can write in C/C++/Zig/Rust, where you have full control over the in-memory representation.
But that's also another feature AWS takes away from you if you buy elasticache :^)
Does redis do async operations? I'm not sure how that would work because it's known to be in memory. But I do know it persists to disk. So basically my question is:
Does almost absolutely every operation on a redis database happen serially? Maybe not every single operation, but in general.
Not sure about this that's why I'm asking here for a definitive concrete answer about this.