3 ms·
FoundationDB does have impressive performance, but implementing compound operations like INCR, APPEND, etc. would require at least an additional network round t
by atombender 4y ago
FoundationDB does have impressive performance, but implementing compound operations like INCR, APPEND, etc. would require at least an additional network round trip between the client and the server.
For example, INCR would require one read followed by one write of the new value, and of course this will result in very inefficient mutation range conflicts (which must be retried for another couple of round trips) if you have frequent updates of the same keys in multiple concurrent transactions.
- sorenbs 4y agoFDB supports atomic operations that you can use to implement at least some of this very easily in a way that avoids the extra round trip and conflicts: https://apple.github.io/foundationdb/developer-guide.html#atomic-operations https://apple.github.io/foundationdb/developer-guide.html#at...
- spullara 4y agoFDB also supports some atomic operations that may decrease the number of roundtrips and remove conflicts: https://apple.github.io/foundationdb/api-python.html#api-python-transaction-atomic-operations https://apple.github.io/foundationdb/api-python.html#api-pyt... That said, I still don't think that it is necessarily the perfect match for implementing some of the Redis data structures.
- atombender 4y agoI had completely forgotten about those built-in ones. Right, so some operations can be made fully atomic server-side, but there are still a bunch of ops (append, pubsub, set commands such as SADD, etc.) that would need round trips.
- spullara 4y agoSADD wouldn't need a round trip since it is idempotent. You would just do a blind set which doesn't even require a transaction in FDB. Likewise, most of the other ones can be reframed / designed to not require round trips. I would still not use it as the backend unless I already had FDB in my solution and this was just an additional database type that I needed without ultimate performance as the constraint.
- atombender 4y agoSADD needs to return a value indicating whether the member was added or not, so I don't think you could avoid a round trip, since FDB doesn't have a "set if not exists".
- spullara 4y agoAh, I see. Bummer. Even if it had a set if not exists you would still need a transaction for it.