Mysql connection pooling/persistent connections with php-fpm

Is it possible to enable persistent connections and connection pooling with Nextcloud as described on PHP: Connections - Manual

I notice that I get warnings on reaching max connections on my mariadb instance while browsing my Nextcloud, especially during thumbnail creation.

Nextcloud 24.0.4
PHP 8.1.8
Gentoo Linux Kernel 5.19.2

I found another thread from 2017 with the same question, but for PostgreSQL: Persistent database (postgresql) connections

I did a very simple PR that may interest you: Expose Doctrine support for persistent connections in PDO in Nextcloud settings
The DBAL used by nextcloud have pooling/persistent connection support. Nextcloud actually don’t set that parameter, this patch just expose the parameter in config.php

I use this modification on my own server, so do a few friend of mine. ATM, nothing weird happened.

1 Like

Thanks! Have you made any benchmarks or comparisons against the default settings?

Kinda, it’s in no way a proper benchmark, but I see connect:db consistently going from 3ms to 0.3ms while using the profiler app


The profiler induces a latency in everything so I guess prod env won’t see that much of a difference. Unless it’s a very busy instance ?
It should be noted : my instance is using postgress, wich have a more important connexion cost than mysql. So your instance may not see the same benefit.

The main difference I see, while the instance is under heavy load, is on the postgres process, using less cpu.

I need to setup a proper benchmarking system but i’m not sure how.