You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As documented in rbac.md docs, enabling the global roles for users, and enabling global roles for teams, both incur 1 additional query per request. This can be knocked down significantly by simply using the local redis cache, avoiding round-tripping to a database serving an entire cluster. Ping @john-westcott-iv
In AWX we have a simple decorator that stores the return value in the cache.
The use case of getting singleton permissions is a perfect use case for this because:
it will be called repeatedly for the same user - ideally, I imagine we will require the user primary key as the input argument
it will be used repeatedly by multiple uWSGI workers on the same node, meaning more workers will get more benefit from this
the output is trivially JSON serializable, which is just a set/list (I don't care) of strings
cache invalidation is rare, and only happens when membership in a system-wide role changes, and I would suggest it is sufficient to use a 5 to 60 second delay as a lazy solution
Note that Django does not offer this @memoize decorator. That's fine, since it's in AWX it is ours to adopt. We should move it into DAB utils, and have AWX import from there. The method is written in a very widely compatible way.
The text was updated successfully, but these errors were encountered:
As documented in
rbac.md
docs, enabling the global roles for users, and enabling global roles for teams, both incur 1 additional query per request. This can be knocked down significantly by simply using the local redis cache, avoiding round-tripping to a database serving an entire cluster. Ping @john-westcott-ivIn AWX we have a simple decorator that stores the return value in the cache.
https://github.com/ansible/awx/blob/8ff7260bc66f4de9aa177cb81ba83da3a2f53ec8/awx/main/utils/common.py#L171
Note that this uses
from django.core.cache import cache
which is the standard Django cache framework.https://docs.djangoproject.com/en/5.0/topics/cache/
The use case of getting singleton permissions is a perfect use case for this because:
Note that Django does not offer this
@memoize
decorator. That's fine, since it's in AWX it is ours to adopt. We should move it into DAB utils, and have AWX import from there. The method is written in a very widely compatible way.The text was updated successfully, but these errors were encountered: