authzed/spicedb
# spicedb
s
Hi Guys πŸ™‚ I am quite new in spicedb and have some questions regarding lookup resources. In my system, there are about 1,5 million users. 99% of these have access to just a few number of resources (documents, other users, etc.), for them lookup resources works fine. But I have a few users (the admins), which can access all or nearly all resources in my database. These users cause a lot of trouble when calling lookup resources to often (the calls run in timeouts and are slowing down the db so much by using all its cpu, that all other calls are affected by that). I already read through some discord conversations and saw that I am not the only one with this problem (https://github.com/authzed/spicedb/issues/1317 and https://authzed.com/docs/spicedb/modeling/protecting-a-list-endpoint#the-problem-statement). 1.) Does the limit in the endpoint have any effect on performance? I tried to log the produced sqls (which are taking super long to run in my postgres db because the number of affected rows is so huge) and there is no limit in these, is it correct to assume that using a limit of 10 instead of 100 will not make a huge difference for the db? 2.) At the moment, we are blocking away lookup resource calls from users with too powerful permissions. Besides of bulk checking random resources until we find enough resources the user has access to, MaterializeApi could be a solution for us. Are there any numbers regarding performance for this? Is it performant enough for a system with so many users and millions of resources? We are a little scared to use this because of money and early access πŸ˜… 3.) Would a different db (for example cockroach db instead of postgres) make a difference? Thank you so much for your good work!
y
1. are you saying that the queries generated by a call that has an
optional_limit
set don't have any `LIMIT`s on them? that's surprising to me. we do know that with the current implementation of lookupresources, there are limitations to how much an
optional_limit
can reduce the required work; we have a new iteration of the implementation that should improve that but we're still ironing out some bugs. 1. materialize is impressively fast (imo) if you fit within its scaling boundaries and are willing to tolerate its update lag (think on the order of 5s). it does have some limitations around intersections, exclusions, and wildcards, so it's going to depend on y'all's schema to some degree. if you're interested in talking to someone about it i can help you set up a meeting. 1. probably not. unbounded LRs with large numbers of reachable permissions will always perform poorly. we ran into a similar issue at my old company as well. the first iteration of our schema connected every resource to a
platform
object and then had a permission path that ran through that object, and admins had the same issue of LRs trying to return the world. what we ended up doing was forcing admins to impersonate end users and/or elevate their permissions on a particular resource rather than treating it as something where they could see everything. another approach that we considered that may work for you is to have two permission paths on the list endpoint - one asking whether the user is an admin, in which case return everything, and then the normal one that uses LR.
j
for #1, LR2 (current LR) does not pass limits to the underlying SQL queries, as it won't know how many it needs to walk until it finds results. LR3 (currently being tested) doesn't set limits, but highly limits concurrency when a
limit
is specified, drastically reducing overhead
s
Hello πŸ™‚ Thank you both very much!! Regarding #1, that was my guess aswell why no limit is used, good to know that the guess was right πŸ˜† That there is a LR3 being in development is very good to know, I am looking forward to test it when it is out 😍 Regarding #2, that sounds great! We are not completely sure IF we need this pre computation at all, because in our usecase, lookup resources is mainly used to prefill some dropdowns with data. for most of the users, this works fine (because the amount of resources is so small for them), the problem are the admins. Their statements slow down our db. But prefilling the dropdowns with 100 random resources, when the user has access to millions, doesnt make much sense to me. Do I understand it correctly, that you have to store our data in the cloud and use your service for the precalculation?or is it possible to run the precalculation in one of our services and just use the api methods for that? Thanks @yetitwo for the offer ❀️I will discuss it with my team πŸ™‚ Regarding #3, sad but to be expected πŸ₯²Using a different api (or calculation method) for admin users would be our approach as well. at the moment, we are just blocking them away, but using authz/bulk check over some random resources could be a solution as well for us. Again, thank you both so much ❀️
y
> Do I understand it correctly, that you have to store our data in the cloud and use your service for the precalculation? yes, Materialize is a part of our Dedicated offering, and ideally will be coming soon to our Cloud offering.
43 Views