Support MariaDB/MySQL `NO_CACHE` flag for `filecache` SELECT queries
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- PHP
- Star
- 36.9k
- Fork
- 5.2k
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 713
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng việc xem xét các đường dẫn truy vấn SELECT của filecache và cấu hình config.php được đề cập trong issue; ví dụ getUserGroups() cho thấy hành vi bộ nhớ đệm truy vấn dự kiến. Xác nhận cách MariaDB/MySQL xử lý SQL_NO_CACHE đối với các truy vấn này, sau đó xác định việc hoàn thành là một triển khai có thể cấu hình, kèm theo việc xác thực hoặc các bài kiểm thử bao quát các truy vấn filecache tạo ra.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- mariadb, mysql, php
- Lĩnh vực
- backend, databases, performance
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100