nextcloud / nextcloud/server

Support MariaDB/MySQL `NO_CACHE` flag for `filecache` SELECT queries

Abierto
#50,737 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

1. to develop enhancement feature: database performance 🚀
Lenguaje dominante
PHP
Estrellas
36.9k
Forks
5.2k
Merge medio
2 d 3 h
PR fusionados (30 d)
713

Descripción

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.

Image

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza revisando las rutas de consultas SELECT de filecache y la configuración de config.php mencionada en la issue; el ejemplo de getUserGroups() muestra el comportamiento previsto de la caché de consultas. Confirma cómo gestionan MariaDB/MySQL SQL_NO_CACHE para estas consultas y define la finalización como una implementación configurable con validación o pruebas que cubran las consultas de filecache resultantes.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
mariadb, mysql, php
Área
backend, databases, performance
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.