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

Power local flag evaluation endpoint by RemoteConfig #27114

Open
benjackwhite opened this issue Dec 20, 2024 · 0 comments
Open

Power local flag evaluation endpoint by RemoteConfig #27114

benjackwhite opened this issue Dec 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@benjackwhite
Copy link
Contributor

Feature request

Is your feature request related to a problem?

Local evaluation hits our API hard (or can do) and it only does two things:

  1. Checks the api token for access
  2. Responds with all enabled flags

We don't need to be doing 1000s of DB calls all the time for this. I'm describing the normal "put a cache on it" catch all to public endpoints but I think we are in a really strong place to do this now

Describe the solution you'd like

This feels simple enough that we could move this to our RemoteConfig approach.

  1. Have the RemoteConfig model be responsible for listening to Flag changes, serializing the local flag payload and wriitng it to the "store" (redis currently)
  2. Write to the store directly or indirectly a hash of all API keys that have access to this resource for quick lookup
  3. Modify the endpoint to do this quick lookup rather than our standard, DB heavy checks, returning 404 or 401 by default if not found

This still means django is being hit but with almost no load on our DB (it only needs the very available redis).

I think we could even discuss going one step further... Make a new rust service that is a simple "public-api-gateway". It can then do this redis lookup for us, leaving django as our nice, easy to manage business-logic application but having a protective layer of rust for handling the hard-to-scale high-throughput API side that django fails at.

I'd also advocate for nodejs as a good option here too but given we have a lot of ready-to-go code via capture, it likely wouldn't be super hard to get something up and running.

Additional context

Finally - everything I've said is equally true for surveys 🤷

Debug info

- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]
@benjackwhite benjackwhite added the enhancement New feature or request label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant