We only support geohash precisions in
# spicedb
s
We only support geohash precisions in the range of 3–5, which means a user can be granted a role on
u8v
,
u8vv
, or
u8vvk
. Whenever the object is accessed, the authorization check is performed by taking the object's geohash, truncating it to precisions 3, 4, and 5, and executing
CheckBulkPermissions
on these geohashes. So for example, if the object's geohash is
ubd7gj1yev
, the check will be performed against [
ubd7g
,
ubd7
,
ubd
]. This effectively triples the number of checks. Another approach is to skip different precisions and use only the most precise one (which is 5 in our case). This way, larger geohashes will be broken down into smaller ones at runtime, and grants will be created for each of them. The number of stored relations will increase dramatically - instead of creating a single grant for
u8v
, 1024 (32×32) will be created for its constituents (
u8v**
). I want to keep the
CheckPermission
/
CheckBulkPermissions
latency to the minimum because they are going to be in the hot path for thousands of users accessing hundreds of objects.
y
are those the leaf resources? one thing to note is that in the current implementation of bulkcheck, a group of checks that have the same subject, permission, and object type (and only vary on the object ID), those checks get batched at the datastore level, so it's a bit more work but not the same amount of work as doing three separate checks. i'd also consider caching behavior - it sounds like there's more potential for cache hits if you're allowing the user to grant on the larger blocks.
s
> are those the leaf resources? Indeed, geohashes are the leaf resources as for the bulk check - I'd be doing
core/user:{userId}#view_objects@core/geohash:ubd7g
core/user:{userId}#view_objects@core/geohash:ubd7
core/user:{userId}#view_objects@core/geohash:ubd
If one of the checks is successful - access to the object with geohash
ubd7gj1yev
is authorized. If I understood you correctly, these checks will be batched on the datastore level and can be considered optimal? > i'd also consider caching behavior - it sounds like there's more potential for cache hits if you're allowing the user to grant on the larger blocks. Riiiight, because of the TinyLFU and the maximum number of items it can hold.
y
> these checks will be batched on the datastore level and can be considered optimal the checks will be batched on the datastore level; i hesitate to say that they can be considered optimal because there's a whole lot of variables that go into how a particular workload behaves. this sounds like a sane starting place to me, though.
s
I see. Thanks for the insight.
10 Views