-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support better re-use of API key role caching #53939
Comments
Pinging @elastic/es-security (:Security/Authorization) |
Authorization is performed on each node. While we can reduce the size required by API key cache on each node by adding more nodes (with sticky sessions), the role cache on each node will likely need to cater for all keys. This is another reason that role cache could use further optimisation. |
A straightforward approach (and possibly minimum effort) is to cache a API key role by The current To ensure equality of two sets of role descriptors, it is necessary to compare every element of it to be sure. Other than comparing the Using either |
The caching of API key role is indexed by the role names and the key ID. Therefore, even when two keys have exactly the same set of role descriptors, their roles must be calculated separately and also counted as two independant cache item. In addition, a single key's role descriptors and and limiting role descriptors are also cached seperately. This means we need at least 2 caching slots for every API key.
When there is a large amount of API keys, we could face a role cache thrashing problem. The default cache size is 10k so that 5k keys will be able to saturate it. If any of the role descriptor includes a non-empty application privilege, it could further saturate the search thread pool, which in turns leads to an overloaded cluster.
It is reasonable to assume that most of the 5k keys share the same privilege definitions. Hence the caching problem can be improved if a Role built from the same set of role descriptors can be re-used. That is, despite different API key IDs and possibly different role descriptor names, if the content of a set of role descriptors are the same, we should be able to cach and re-use it.
The text was updated successfully, but these errors were encountered: