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: infinite cache growth #1001

Merged
merged 1 commit into from
Feb 19, 2024
Merged

fix: infinite cache growth #1001

merged 1 commit into from
Feb 19, 2024

Conversation

regisb
Copy link
Contributor

@regisb regisb commented Feb 8, 2024

See the discussion here: #984
And the upstream PR here: openedx/edx-platform#34210

The tl;dr is that the Redis course structure cache was growing without bounds. While the upstream fix should resolve that issue, we decided that Tutor should have a maxmemory limit and an eviction policy set for operational safety.

tutor local run cms ./manage.py cms shell -c "from django.core.cache import caches; c = caches['course_structure_cache']; [c.expire(key, 604800) for key in c.keys('*')]"

FYI @Ian2012 @ormsbee

@regisb regisb force-pushed the regisb/infinite-course-cache branch 2 times, most recently from ca27b13 to 1ec9b00 Compare February 13, 2024 07:59
@regisb
Copy link
Contributor Author

regisb commented Feb 14, 2024

Let's wait until the upstream PR is merged, then update the commit sha1 in the dockerfile.

See the discussion here: #984
And the upstream PR here: openedx/edx-platform#34210

The tl;dr is that the Redis course structure cache was growing without
bounds. While the upstream fix should resolve that issue, we decided
that Tutor should have a maxmemory limit and an eviction policy set for
operational safety.

Thus, Redis now has a 4gb maxmemory. If you need more memory on your
instance, you should implement the "redis-conf" patch.

To manually expire existing keys, run:

    tutor local run cms ./manage.py cms shell -c "from django.core.cache import caches; c = caches['course_structure_cache']; [c.expire(key, 604800) for key in c.keys('*')]"
@regisb regisb force-pushed the regisb/infinite-course-cache branch from 1ec9b00 to ad6eaff Compare February 19, 2024 08:17
@regisb regisb merged commit 59b1987 into master Feb 19, 2024
1 check passed
@regisb regisb deleted the regisb/infinite-course-cache branch February 19, 2024 08:43
@VirtualDiegox
Copy link

@regisb just to be sure, this fix should be set also in the k8s templates? specifically in volumes.yml? I faced the same issue and i had to resize the vpc manually before running the command to expire the existing keys

@regisb
Copy link
Contributor Author

regisb commented Feb 20, 2024

@VirtualDiegox As far as I know, this fix does not require any change made to volumes.yml. Well, we could increase the volume size to 4GB, but that would not be required by this change. Did you have something else in mind?

@VirtualDiegox
Copy link

@regisb With this fix the maxmemory parameter for redis is 4gb, but i don't know if the policy (LRU) apply if the volume size is smaller than the maxmemory parameter, in a k8s environment if the volume storage for redis is full, the platform just collapses with 500 errors because it is not able to create new session keys, so i think it should be consistent in the volume declaration or it could be a configuration parameter (4gb by default for example) that overrides the size required for redis in both files (redis.conf and volumes.yml)

@regisb
Copy link
Contributor Author

regisb commented Feb 21, 2024

@VirtualDiegox I'm wondering if you are facing the issue that we actually solved here. I.e: the infinite growth of the course structure cache. How much space is your Redis instance using after you clear the course structure cache?

@VirtualDiegox
Copy link

@regisb Yes I think i was facing that issue too, but our environment it's based on the k8s deployment, that's why I asked if the volume size in the k8s template should be increased too, right now our Redis volume is 4gb. The command to clear the course structure cache doesn't work if the space of the volume is full, so I solved it temporarily with a plugin that addionally to the changes that you made, create a new volume with 4gb instead of 1gb and override the redis deployment in order to use it. If you are wondering why create new volume instead of modifying the existing one it is due permissions issues in the cluster.

@regisb
Copy link
Contributor Author

regisb commented Feb 27, 2024

Right, I understand. But after you clear the course structure cache, how much memory is your Redis volume using, out of the 4GB maximum space?

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

Successfully merging this pull request may close these issues.

3 participants