Support MariaDB/MySQL `NO_CACHE` flag for `filecache` SELECT queries
まだ誰も着手していません。
- 主要言語
- PHP
- スター
- 36.9k
- フォーク
- 5.2k
- 平均マージ
- 2日 3時間
- マージ済み PR(30日)
- 713
説明
Background
We're operating a Nextcloud server with up to 800 active users in the last 5 minutes. Recently, we have run into performance bottlenecks.
We found that while the CPU and available memory are not an issue, the load on the CPU was capped at around 25% (see Grafana screenshot in details). This resulted in a degraded user experience, for example waiting times of up to 30s when switching file directories.
When looking into the MariaDB process list, there were dozens or sometimes hundreds of SELECT and UPDATE statements waiting for the lock of the filecache table. With almost 1000 UPDATE queries per second, it seems that obtaining/switching the query cache mutex is the limiting factor holding back the system.
To alleviate the issue, we made the query cache optional with SET GLOBAL query_cache_type = 2;. This is obviously a bad idea in some or even many cases, as this increases the load on the database immediately. However, in our case the server had enough hardware reserves and the page load speed increased.
However, the CPU load increased more than is actually necessary, as we basically disabled the query cache for most if not all queries. We quickly fixed this by hardcoding a SELECT SQL_CACHE ... into the getUserGroups() method of the user_saml app, which immediately reduced about 50% of the CPU load (we have really a lot of users and groups).
Suggestion
A better approach than activating the query cache for each single query would be to use the SQL_NO_CACHE statement for SELECT queries in the filecache table with query_cache_type = 1;. This could be activated with a new entry in the config.php.
There is a caveat: we have not yet fully validated this finding. At this point it seems highly likely and I'm very much interested in feedback.
How to use GitHub
- Please use the 👍 reaction to show that you are interested into the same feature.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、filecache の SELECT クエリパスと、issue で言及されている config.php の設定を確認します。getUserGroups() の例は、意図されたクエリキャッシュの動作を示しています。次に、MariaDB/MySQL がこれらのクエリに対して SQL_NO_CACHE をどのように扱うかを確認し、完了条件を、結果として生成される filecache クエリを対象とする検証またはテストを備えた設定可能な実装として定義します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- mariadb, mysql, php
- 領域
- backend, databases, performance
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100