-
Notifications
You must be signed in to change notification settings - Fork 4k
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 growth of cache when auto eviction is disabled #34210
fix: infinite growth of cache when auto eviction is disabled #34210
Conversation
Thanks for the pull request, @regisb! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
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.
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. 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('*')]"
@robrap: I wanted to bring this to your attention. I don't think it will have a negative impact on you folks, but I'd like to go over your config on Monday if you have time. |
@ormsbee: I got your message, but haven’t gotten to this. Let’s coordinate in Slack. |
@robrap: Scheduled the meeting for tomorrow. Thank you! |
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('*')]"
Thank you for being on top of this Dave & Robert :) |
|
78185f6
to
dfa16b3
Compare
I have updated the commit message to include backward-compatible instructions, as well as the |
See discussion here: overhangio/tutor#984 This is a breaking change that will explicitely set the timeout of course structure cache entries to 1 week, instead of being unlimited. If you wish to revert to the former behaviour, you should set `course_structure_cache["TIMEOUT"] = None`. The course structure cache keys were previously set with an explicit timeout of `None` which was overriding the cache default timeout of 2h. This was OK in environments where the cache is configured with a maximum memory limit and an automatic key eviction strategy. But in others (such as Tutor), the course structure cache could grow infinitely. It was agreed that course structure cache keys should be long-lived but should respect the default cache structure timeout. Thus, we set here the TTL to 1 week. We can also configure Tutor to use a cache eviction policy. But that means we need to set a `maxmemory` value in Redis. It's not possible to set a value that will be appropriate for everyone: - if it's higher than the total memory (e.g: in small instances), server will crash before the cache is filled. - if it's too low (e.g: in large instances), the whole platform will abruptly slow down as many cache entries are suddenly evicted. That question of whether Tutor should define a cache eviction policy is still under discussion, but it can be resolved independently of this change.
dfa16b3
to
ad201cd
Compare
@regisb 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
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('*')]"
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('*')]"
Description
The course structure cache keys were previously set with an explicit timeout of
None
which was overriding the cache default timeout of 2h. This was OK in environments where the cache is configured with a maximum memory limit and an automatic key eviction strategy. But in others (such as Tutor), the course structure cache could grow infinitely.It was agreed that course structure cache keys should be long-lived but should respect the default cache structure timeout. Thus, we set here the TTL to 1 week.
We can also configure Tutor to use a cache eviction policy. But that means we need to set a
maxmemory
value in Redis. It's not possible to set a value that will be appropriate for everyone:That question of whether Tutor should define a cache eviction policy is still under discussion, but it can be resolved independently of this change.
Supporting information
See discussion here: overhangio/tutor#984
Testing instructions
Please provide detailed step-by-step instructions for testing this change.
Deadline
ASAP. We would like to backport this change in Tutor.