spicedb icon indicating copy to clipboard operation
spicedb copied to clipboard

Open Question: feasibility of datastore using dynamodb

Open imacks opened this issue 2 years ago • 20 comments
trafficstars

I'm looking for your thoughts on implementating a database backend for authzed in dynamodb. Zenzibar paper did specifically say that it is using spanner, but it reads like it is really zookie that plays the important role of guaranteeing causal acl. I don't have any concrete code right now, but my feeling is that it may be possible to design the db with mostly eventual consistency, with small amount of strong consistency parts. The caveat would be that eval node answers may be different from each other, abit only for a short period after write. This should be alright in real life use cases. Most IAM from big cloud providers are not strongly consistent.

Is there any technical difficulty I have overlooked?

imacks avatar Jan 03 '23 06:01 imacks

@imacks The biggest open question is handling of zedtokens and "full consistency": if a zedtoken is provided, or full consistency is required, SpiceDB is required to honor that request by the client. Thus, there must either be a way in DynamoDB to request the fully consistent updates that have been applied or SpiceDB will have to wait until it can guarantee that the updates have been applied.

So long as this is doable (or it is acceptable to wait), I would imagine implementation should be fairly straightforward

josephschorr avatar Jan 03 '23 16:01 josephschorr

Where strong consistency is required, we can use conditional writes and strongly consistent reads. Having said that, the biggest advantage I hope from DynamoDB backend is better latency as things scale up, which suggests an eventual consistency model.

imacks avatar Jan 03 '23 18:01 imacks

Yeah, strong consistency will only be required when requested by the client. If the ZedToken's requirements are already met by the eventual consistency at the time of the call, or if minimize_latency is requested (which is the default), then eventual consistency is fine

josephschorr avatar Jan 03 '23 18:01 josephschorr

Tks for the tip. I will try my hands on making a POC and then circle back. Cheers!

imacks avatar Jan 04 '23 04:01 imacks

@imacks any progress? Quite curious :)

josephschorr avatar Jan 23 '23 22:01 josephschorr

@imacks Ping!

josephschorr avatar Sep 20 '23 21:09 josephschorr

@josephschorr Apologies for the slow response. Day job busy busy yada yada (@~@) ...

Progress report: (1) dynamodb datastore prototype is mostly working, but still lots of unit tests missing. I suspect there is also room for improvement, e.g. by avoiding transactions in some cases. (2) I'm also working on a cassandra datastore that is looking promising performance-wise. For Cassandra, adhering to the DataStore interface has proved to be challenging. I will update you on this point in a separate issue once I feel ready to commit.

imacks avatar Sep 22 '23 15:09 imacks

@imacks Sounds great! Let us know if we can help in any way

josephschorr avatar Sep 22 '23 17:09 josephschorr

@imacks Would you be willing to share your progress? I'm quite curious :)

josephschorr avatar Dec 13 '23 19:12 josephschorr

I just wanted to follow up on this thread as we've seen requests for DynamoDB usage in multi-region SpiceDB deployments.

DynamoDB can be used to implement a datastore for single-region deployment, but in a multi-region DynamoDB configuration, writes across regions are replicated in an eventually consistent, asynchronous fashion. This means requests with a full_consistency ZedToken in this configuration would produce incorrect results.

jzelinskie avatar Dec 13 '23 21:12 jzelinskie

@imacks Checking in again to see if you have anything you'd mind sharing :)

josephschorr avatar Mar 15 '24 03:03 josephschorr

I have quite a bit of experience with Dynamodb and Go. Also we have written a go lib around making working with Dynamo much easier. We were thinking to make it open source. @imacks happy to help with anything you need.

Edit: @imacks did you implemented the single table design? Also unable to find any feature branch around this.

gsingh-ds avatar Apr 18 '24 06:04 gsingh-ds