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

MM-58729: Improve proxy cache configuration #788

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

agnivade
Copy link
Member

@agnivade agnivade commented Aug 26, 2024

Tested with various combinations of settings. None of them showed a major improvement. Therefore, settled on the very basic changes.

Full thread here: https://community.mattermost.com/core/pl/rjbg3yr3mfrrfrcq7zk3eo6gky

https://mattermost.atlassian.net/browse/MM-58729
https://mattermost.atlassian.net/browse/MM-59871

@agnivade agnivade added the 2: Dev Review Requires review by a core committer label Aug 26, 2024
@agnivade agnivade changed the title proxy cache MM-58729: Improve proxy cache configuration Aug 26, 2024
Copy link
Member

@agarciamontoro agarciamontoro 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 investigation! I wonder that given that none showed improvements, do we want/need to change them? I'm ok with the change of proxy_cache_lock_timeout, since we wanted to make timeouts easier to debug, but what about proxy_cache_min_uses? I'm not opposed to it, but I'm not entirely sure of the benefit.

@agnivade
Copy link
Member Author

The benefit of min_uses would be that it populates the cache faster, and avoids an extra request to the server. At high scales, this should make a difference. Feels like a safe optimization IMO, but only 1/5.

Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

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

Thanks. Have you had a chance to review the proxy_cache_path directive as well?

I noticed the below comment seems somewhat inaccurate:

cacheSize = "16g" // Ideally we'd like half of the total server mem. But the mem consumption rarely exceeds 10G
// from my tests. So there's no point stretching it further.

As far as I understand, max_size controls disk space, not memory. It's also not really required given:

When the size is exceeded or there is not enough free space, it removes the least recently used data.

Another thing to check is whether we have eliminated the [alert] 3892#3892: could not allocate node in cache keys zone "mattermost_cache" log.

Tangential, but it would be great to look into cache instrumentation and get something to show on Grafana. Could be an interesting side project (OSF) or help wanted.

Resources:

https://blog.nginx.org/blog/nginx-caching-guide
https://www.f5.com/company/blog/nginx/nginx-high-performance-caching

@@ -195,9 +195,10 @@ proxy_pass http://backend;
const nginxCacheCommonConfig = `
proxy_cache mattermost_cache;
proxy_cache_revalidate on;
proxy_cache_min_uses 2;
proxy_cache_min_uses 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am supportive of this change (caching slightly more aggressively) especially since it's nginx's default.

@agnivade
Copy link
Member Author

Another thing to check is whether we have eliminated the [alert] 3892#3892: could not allocate node in cache keys zone "mattermost_cache" log.

Ahh, yes I missed to check that. Looks like I need to run more tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants