Reduce memory used by highlighted-diff-files:merge_request_diffs on Redis cache
Coming from the investigation in gitlab-com/gl-infra/scalability#1601 (comment 1015069256) we noticed that the highlight-diff-cache:
namespace consumed almost 5GB of memory at the time we sampled.
The cache is built from Gitlab::Diff::HighlightCache
and contains rendered HTML for diffs, including syntax highlighting.
This cache is shared across users, is being compressed before storing. So there's no obvious low hanging fruit by moving caching to the browser.
The TTL is set to 1 week, while the average idletime for the key is about 6 hours. So we often don't reuse these caches for quite a while.
The cache namespace highlighted-diff-files:merge_request_diffs/
accounted for about 12% of the memory usage of the total cache:
namespace
Some ideas:
- Perhaps we can reduce the TTL to a few hours to reduce the footprint?
- Can we add active invalidation of the cache when it becomes invalid?
- Store this kind of data elsewhere, perhaps in object storage?
Edited by Bob Van Landuyt