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

GridField actions cause heavy sessions, data is never cleaned up #8589

Closed
2 tasks done
Cheddam opened this issue Nov 9, 2018 · 2 comments
Closed
2 tasks done

GridField actions cause heavy sessions, data is never cleaned up #8589

Cheddam opened this issue Nov 9, 2018 · 2 comments

Comments

@Cheddam
Copy link
Member

Cheddam commented Nov 9, 2018

Affected Version

Tested against SilverStripe 4.3.x-dev

Description

GridField makes use of the session to store parameters required to trigger each action available on the grid (including a set of keys for the actions on each grid item). This works simply and effectively in basic use-cases, and if you use a traditional single-server hosting environment, you'd likely never notice any problems.

However, with the combination of two increasingly common factors, we quickly see issues with this approach:

  • The Queued Jobs module, which has a ModelAdmin that contains a significant number of GridField Actions
  • A cloud-based hosting environment with multiple web servers, utilising DynamoDB for session storage - which has limited Read / Write capacity that is measured both in the number and size of requests.

Loading the Queued Jobs ModelAdmin when at least a page worth of jobs exist stores approximately 40 session keys in my testing, weighing roughly 5kb. This may seem small, but it means a user who visits this interface once during their session will consume ~5 write units in DynamoDB on every request until they log out. With more complex projects that utilise a range of GridFields, this number will rise further.

We could improve this in one of two ways:

  • Ensure keys are purged once they are no longer relevant (i.e. once the user navigates to another interface)
  • Shift away from use of the session to store this data entirely (any reason we can't send it down to the user? CSRF concerns?)

The former is lower effort, and would be a big improvement - not significantly improving peak usage, but at least mitigating the general impact.

Steps to Reproduce

  • Install symbiote/silverstripe-queuedjobs
  • Create enough jobs to fill a page of the QueuedJobs ModelAdmin interface
  • Visit the ModelAdmin and observe excessive session use
  • Navigate around the CMS and observe the gf_ session keys are never cleared

Related PRs

@Cheddam
Copy link
Member Author

Cheddam commented Nov 14, 2018

Another example:

Elemental uses a GridField to render the UI for editing blocks on a page. Each PageEdit view loaded by a user will write a set of gf_ keys to the session. On a site with a large number of pages and blocks, it's possible to reach a session size of 100KB+ - which makes scaling DynamoDB to work around the issue prohibitively expensive, and would likely also have a performance impact even in traditional hosting environment configurations.

@maxime-rainville
Copy link
Contributor

All the PRs have been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants