"For larger XenForo installations, it can be advantageous to define a cache in order to save on processing time and database queries.
XenForo has the ability to store and retrieve various data from a cache, which can be configured in your src/config.php file"
It might help .. but it could be due to processes getting "stuck", and not closing sockets to db.
Nice find, I'll look into this.