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

[Workspace] Optimize Performance by Caching Workspace Saved Objects During Permission Validation #7520

Closed
wanglam opened this issue Jul 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@wanglam
Copy link
Contributor

wanglam commented Jul 26, 2024

Is your feature request related to a problem? Please describe.

In the current implementation, when validating permissions for workspace saved objects, the system needs to call bulkGet for each workspace saved object to retrieve its permission information. This process results in numerous duplicate requests for the same workspace saved objects, leading to performance inefficiencies during the permission validation logic.

Describe the solution you'd like

To address this issue and improve performance, we propose implementing a caching mechanism for workspace saved objects during the permission validation process. By caching and reusing the bulkGet results within the same request, we can significantly reduce the number of redundant calls and optimize the permission validation logic.

The proposed solution involves the following three main changes:

  1. Add saved objects cache-related methods in the permission control client
  • Introduce the following methods in the permission control client:
    • cacheSavedObjects(request, savedObjects): This method will mark the provided saved objects as cacheable for the given request, meaning that the bulkGet results for these saved objects will be cached. The permission control client can then use the cached data instead of fetching it from the network.
    • clearSavedObjectsCache(request): This method will clear all cached saved objects for the given request.
    • isSavedObjectsCacheActive(request): This method will check if there are any existing cached saved objects for the given request.
  1. Cache workspace saved objects during bulk operations
  • Modify the workspace saved object client wrapper to call cacheSavedObjects with the saved objects' workspaces during bulkCreate, bulkUpdate, and bulkGet operations.
  • This change will ensure that the workspace information is cached during the same request, eliminating the need for duplicate bulkGet calls for workspaces.
  1. Clear saved objects cache before responding
  • Register a pre-response hook in the workspace plugin's permission setup logic.
  • Within the pre-response hook, call isSavedObjectsCacheActive to check if there are any cached saved objects.
  • If cached saved objects exist, call clearSavedObjectsCache to clear the cache before responding to the request.

By implementing this caching mechanism, we can significantly reduce the number of bulkGet calls made during the permission validation process, thereby improving performance and optimizing the overall system efficiency.

Describe alternatives you've considered

N/A

Additional context

#4944
#6051

@SuZhou-Joe
Copy link
Member

closes because of #7516

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

2 participants