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

Fix some caching issues in the CMS #6697

Merged
merged 2 commits into from
Sep 4, 2020
Merged

Fix some caching issues in the CMS #6697

merged 2 commits into from
Sep 4, 2020

Conversation

dandrabik
Copy link
Member

WHAT

In the CMS, we have some queries that are taking a very long time and some caches that are never getting set because the payload is too large.

WHY

Generally, fast, cached things are good.

Also, multiple long-running queries at once that miss a cache and take longer than 5 seconds could cause the wave of ActiveRecord - could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use that we saw earlier in the day. A class full of students starting the same activity at the same time would create the conditions to make this possible. Trying this fix before adjusting the connection pool size.

HOW

  1. For responses_for_questions cache the ids instead of the results, since the results are too large for some questions
  2. For the multiple_choice_options optimize the queries.
  3. For both, expire the cache less frequently, and only delete it when necessary.

Screenshots

Memcache error
Screen Shot 2020-09-03 at 6 51 59 PM

Screen Shot 2020-09-03 at 6 50 52 PM
Screen Shot 2020-09-03 at 6 51 14 PM

PR Checklist Your Answer
Have you added and/or updated tests? (No, should be the same business logic as before, so tests should cover.)
Have you deployed to Staging? (Not yet, deploying now)
Self-Review: Have you done an initial self-review of the code below on Github? Yes
Design Review: If applicable, have you compared the coded design to the mockups? (N/A )

Copy link
Contributor

@cissyxyu cissyxyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments!

@dandrabik dandrabik merged commit 6300755 into develop Sep 4, 2020
@delete-merged-branch delete-merged-branch bot deleted the cms_caching branch September 4, 2020 18:02
dandrabik added a commit that referenced this pull request Sep 4, 2020
Fix some caching issues in the CMS (#6697)
emilia-friedberg added a commit that referenced this pull request Sep 9, 2020
* Remove references to prefilledText in all LMS apps (#6693)

* remove prefill question

* new test snapshot

* Remove leftover unused write to Firebase (#6695)

* try committing everything but yarn lock

* put expose loader back because it turns out we do need that

* minor c hange so I can deploy again

* Add a "last_active" trait to Schools when syncing Vitally

This trait is calculated by the last time a student completed an activity assigned by a teacher at this school

* Remove an extraneous leftover line

* dumb

* add check for empty questions array (#6694)

* Fix some caching issues in the CMS (#6697)

* Fix some caching issues in the CMS

* Break out of module to ensure Response called.

* Be more specific with our `maximum` call to disambiguate

* remove commented out loaders

* Add analytics.group calls if current_user.school exists

* Tweak tests to account for in-memory vs in-db time precision

* Fix the two most common LessonsServer errors and add tests. (#6707)

* Install jest.

* Add tests for createSession

* Fix error with teacher_ids (#6710)

Co-authored-by: cissyxyu <57366100+cissyxyu@users.noreply.github.com>
Co-authored-by: Anathomical <thomas.robertson@quill.org>
Co-authored-by: Eric Adams <erictayloradams@gmail.com>
Co-authored-by: dandrabik <dandrabik@users.noreply.github.com>
emilia-friedberg added a commit that referenced this pull request Sep 9, 2020
* Remove references to prefilledText in all LMS apps (#6693)

* remove prefill question

* new test snapshot

* Remove leftover unused write to Firebase (#6695)

* try committing everything but yarn lock

* put expose loader back because it turns out we do need that

* minor c hange so I can deploy again

* Add a "last_active" trait to Schools when syncing Vitally

This trait is calculated by the last time a student completed an activity assigned by a teacher at this school

* Remove an extraneous leftover line

* dumb

* add check for empty questions array (#6694)

* Fix some caching issues in the CMS (#6697)

* Fix some caching issues in the CMS

* Break out of module to ensure Response called.

* Be more specific with our `maximum` call to disambiguate

* remove commented out loaders

* Add analytics.group calls if current_user.school exists

* Tweak tests to account for in-memory vs in-db time precision

* bunch of clean up in the webpack files

* run terser plugin in parallel

* start using the cache-loader for jsx and tsx files

* tiny change to deploy again

* get rid of cache-loader

* Fix the two most common LessonsServer errors and add tests. (#6707)

* Install jest.

* Add tests for createSession

* just remove sass-loader from evaluating .css files

* Fix error with teacher_ids (#6710)

* add the hard source webpack plugin

* re-install terser webpack plugin

* whitespace change to redeploy

* get rid of stuff that really isn't helping

Co-authored-by: cissyxyu <57366100+cissyxyu@users.noreply.github.com>
Co-authored-by: Anathomical <thomas.robertson@quill.org>
Co-authored-by: Eric Adams <erictayloradams@gmail.com>
Co-authored-by: dandrabik <dandrabik@users.noreply.github.com>
emilia-friedberg added a commit that referenced this pull request Sep 9, 2020
* try committing changes

* fix memory issue

* memory update for prod-cms call

* additional speed improvements for webpack (#6702)

* Remove references to prefilledText in all LMS apps (#6693)

* remove prefill question

* new test snapshot

* Remove leftover unused write to Firebase (#6695)

* try committing everything but yarn lock

* put expose loader back because it turns out we do need that

* minor c hange so I can deploy again

* Add a "last_active" trait to Schools when syncing Vitally

This trait is calculated by the last time a student completed an activity assigned by a teacher at this school

* Remove an extraneous leftover line

* dumb

* add check for empty questions array (#6694)

* Fix some caching issues in the CMS (#6697)

* Fix some caching issues in the CMS

* Break out of module to ensure Response called.

* Be more specific with our `maximum` call to disambiguate

* remove commented out loaders

* Add analytics.group calls if current_user.school exists

* Tweak tests to account for in-memory vs in-db time precision

* Fix the two most common LessonsServer errors and add tests. (#6707)

* Install jest.

* Add tests for createSession

* Fix error with teacher_ids (#6710)

Co-authored-by: cissyxyu <57366100+cissyxyu@users.noreply.github.com>
Co-authored-by: Anathomical <thomas.robertson@quill.org>
Co-authored-by: Eric Adams <erictayloradams@gmail.com>
Co-authored-by: dandrabik <dandrabik@users.noreply.github.com>

* final round of improvements to our current prod webpack build (#6713)

* Remove references to prefilledText in all LMS apps (#6693)

* remove prefill question

* new test snapshot

* Remove leftover unused write to Firebase (#6695)

* try committing everything but yarn lock

* put expose loader back because it turns out we do need that

* minor c hange so I can deploy again

* Add a "last_active" trait to Schools when syncing Vitally

This trait is calculated by the last time a student completed an activity assigned by a teacher at this school

* Remove an extraneous leftover line

* dumb

* add check for empty questions array (#6694)

* Fix some caching issues in the CMS (#6697)

* Fix some caching issues in the CMS

* Break out of module to ensure Response called.

* Be more specific with our `maximum` call to disambiguate

* remove commented out loaders

* Add analytics.group calls if current_user.school exists

* Tweak tests to account for in-memory vs in-db time precision

* bunch of clean up in the webpack files

* run terser plugin in parallel

* start using the cache-loader for jsx and tsx files

* tiny change to deploy again

* get rid of cache-loader

* Fix the two most common LessonsServer errors and add tests. (#6707)

* Install jest.

* Add tests for createSession

* just remove sass-loader from evaluating .css files

* Fix error with teacher_ids (#6710)

* add the hard source webpack plugin

* re-install terser webpack plugin

* whitespace change to redeploy

* get rid of stuff that really isn't helping

Co-authored-by: cissyxyu <57366100+cissyxyu@users.noreply.github.com>
Co-authored-by: Anathomical <thomas.robertson@quill.org>
Co-authored-by: Eric Adams <erictayloradams@gmail.com>
Co-authored-by: dandrabik <dandrabik@users.noreply.github.com>

Co-authored-by: cissyxyu <57366100+cissyxyu@users.noreply.github.com>
Co-authored-by: Anathomical <thomas.robertson@quill.org>
Co-authored-by: Eric Adams <erictayloradams@gmail.com>
Co-authored-by: dandrabik <dandrabik@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants