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

implement caching for feature flag #2190

Open
danoswaltCL opened this issue Jan 31, 2025 · 3 comments
Open

implement caching for feature flag #2190

danoswaltCL opened this issue Jan 31, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@danoswaltCL
Copy link
Collaborator

danoswaltCL commented Jan 31, 2025

Times from load tests were okay, but could be better, this could still creep up on us as a performance issue as more flags are added. I propose we cache the this.featureFlagRepository.getFlagsFromContext(context); call.

Requirements:

  • Investigate caching for getting all feature flags.
  • Clear cache on any change to the flags table, or segments associated with the flags.
  • Test with jmeter to compare (in local, and then in staging).
@danoswaltCL danoswaltCL added the enhancement New feature or request label Jan 31, 2025
@amurphy-cl amurphy-cl added this to the Program Increment PI15 milestone Feb 4, 2025
@VivekFitkariwala
Copy link
Collaborator

Another small optimisation is not to wait for exposure to get saved.

@danoswaltCL
Copy link
Collaborator Author

@VivekFitkariwala so just remove the await here, yes, fire and forget it? That may worth testing in isolation to see the impact, that may be the safest thing to try actually if we want to squeeze in a hotfix....
@bcb37 thoughts?

try {
      await this.dataSource.transaction(async (transactionalEntityManager) => {
        const exposureRepo = transactionalEntityManager.getRepository(FeatureFlagExposure);
        const exposuresToSave = includedFeatureFlags.map((flag) => ({
          featureFlag: flag,
          experimentUser: experimentUserDoc,
        }));
        if (exposuresToSave.length > 0) {
          await exposureRepo.save(exposuresToSave);
        }
      });
    }

@danoswaltCL
Copy link
Collaborator Author

This is what we looked like during a pretty high load. They are looking at performance issues in the Mathia release and delaying release, I don't want to be blamed, they like to point at UpGrade. If we cache these feature flag SELECTs, we have big $$ savings:

Image

@danoswaltCL danoswaltCL self-assigned this Feb 4, 2025
@kawcl kawcl moved this to In Progress in UpGrade Project Feb 5, 2025
@kawcl kawcl moved this from In Progress to Done in UpGrade Project Feb 10, 2025
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
Status: Done
Development

No branches or pull requests

3 participants