Hi, at sennder we are currently thinking about overhauling our first and super simple way of using snapshot tokens to improve the system performance.
In this thread I will describe the improvement proposal and kindly ask to provide feedback.
First let's create a simple pseudo schema.
entity user {} # no relations nor attributes on user
entity organization {
relation role_1 @user
relation role_2 @user
relation role_3 @user
permission role_based_permission_1 = role_1
permission role_based_permission_2 = role_2 or role_3
}
entity chartering_office {
relation role_1 @user
relation role_2 @user
}
entity carrier {
relation chartering_office @chartering_office
relation admin @user
attribute att_1
action traversal_permission_1 = chartering_office.role_1 or chartering_office.role_2
action attribute_permission_1 = admin not att_1
}
Our schema is way larger but these are the permission types we are using.
- Writing permission data
In our system all the writes go through a single set of kafka consumers that consume various topics and based on the consumed data write permission tuples and attributes to permify. A single consumed message may result in > 1 tuple/attribute write in permify.
Once the data is written in permify, we have a bunch of snap_tokens. We store them all in redis, one token per affected entity, under following keys:
- permify:snap:tenant:{entity_type_1}:{entity_id_1} = {token_1}
- permify:snap:tenant:{entity_type_2}:{entity_id_2} = {token_2}
- permify:snap:tenant:{entity_type_3}:{entity_id_3} = {token_3}
etc.
There is no TTL.
[continued in comments due to message length limit]