Hey! I've read through a few old treads
# spicedb
t
Hey! I've read through a few old treads regarding whether to use SpiceDB as the source of truth for relationships or sync from another database. There seems to be some conflicting advice and recommendations. Currently we use SpiceDB as the source of truth for a lot of relationships and use Lookup* when we want for example a list endpoint that lists the users "viewable" resources. But with filtering and pagination, it sometimes feels like a struggle going through SpiceDB for this. There are also some details around consistency when writing to both the application's main database and SpiceDB that are not 100% straight forward I think. Just wondered what's the current thinking around these things?
y
it depends on your use case and the UI you need to drive
at my old company we had a table of role assignments that we wanted to show users as a part of an admin UI
and we originally drove it out of SpiceDB using a bunch of Lookup* requests
and it performed poorly and resulted in a lot of datastore load for SpiceDB
as well as being unable to filter/sort/paginate easily because SpiceDB isn't built or optimized for that
we ended up creating an admin service backed by a normal postgres instance that synced its changes into SpiceDB with a kafka consumer, and that made for a better UI and we tolerated the delay between a write to that database and the corresponding change being reflected in SpiceDB
one of the reasons you might want to keep things in SpiceDB is to avoid the dual-write problem or avoid needing to account for eventual consistency in your UI flows
so there are tradeoffs
t
Thanks for the response! I don't think we're very sensitive to new enemy, so I guess you could prevent most eventual consistency issues by optimistically writing to spicedb after app commit. Accepting that it might fail, but have some other process syncing to ensure eventual consistency.
y
yeah
as far as that goes, i wrote a blog post that discusses different ways to solve the dual-write problem: https://authzed.com/blog/the-dual-write-problem
t
Thanks I'll check it out!
10 Views