Skip to content
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

OPA HTTP server: Add cache control config options #6628

Open
philipaconrad opened this issue Mar 13, 2024 · 1 comment
Open

OPA HTTP server: Add cache control config options #6628

philipaconrad opened this issue Mar 13, 2024 · 1 comment

Comments

@philipaconrad
Copy link
Contributor

What is the underlying problem you're trying to solve?

The OPA HTTP server currently caches only the most recent 100 queries. This works great for many small workloads, but can result in degraded performance in more complex authz scenarios, such as when more than 100 common query types are sent to the same OPA instance in a short time frame.

The problem I'd like to see solved is the current lack of control over the request cache.

Describe the ideal solution

Ideally, I'd like to see a few configuration knobs exposed to the user, which could be provided as part of an OPA config.yaml file.

Properties that I'd expect might be useful to control:

  • Number of cache entries ("cache size")
  • Max memory?
    • There is precedent for a memory cap in the decision logger plugin, where the cache attempts to stay within a certain size limit.
  • Cache eviction/replacement strategy
    • Currently: Least-Recently Used (LRU)
    • See the Wikipedia page on Cache Replacement Policies for more ideas!
    • TTLs for cache entries would be a bit more work, but could be a fantastic way to keep cache sizes down across time. (Infrequently-used entries would expire, and automatically get evicted instead of lingering around in memory.)

Describe a "Good Enough" solution

Control of the number of cache entries would be a great start, and having maybe 2-3 different cache eviction strategies to pick from would be incredible. 🙂

Additional Context

@johanfylling
Copy link
Contributor

An additional eviction strategy that comes to mind would be to prioritize evicting quick-running queries 🤔; keeping the more expensive (time-wise) results.
This would of course need to be tempered by some other strategy, so we don't end up with a cache full of one-shots.

@ashutosh-narkar ashutosh-narkar added this to Backlog in Open Policy Agent via automation Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Open Policy Agent
  
Backlog
Development

No branches or pull requests

2 participants