Does XF 2.3 require a higher MySQL maxconnections setting?

NealC

Well-known member
Been running XF 2.2 for. years with no issue. Just upgraded 3 sites to XF 2.3.6 and now when posting I occasionally get an Oops... error and finally learned to check the console and see the error is about MySQL max connections. I've also seen the site go down once for a MySQL error, never had that in 2.2. My max connections was set to 500 which I have now increased.

Is there a problem with XF 2.3.x either using more connections than before or not releasing them? I host my own web and MySQL servers (physical servers) which are plenty powerful in storage, ram, processors, etc. Ubuntu Server 24.04 on all.

What is the recommended maxconnections for MySQL for XF 2.3?
 
Last edited:
I doubt XF 2.3 is any worse than 2.2 in this regard. It will largely come down to spikes in traffic - you're probably getting a lot more bot traffic than you have previously, I've noticed a significant increase in recent months.

Either way - every connection uses a bunch of RAM - my current config reports usage of 1.9M per thread/connection. Did you look at the error and see what it actually said? Was it an Out of Memory (OOM) error or a "too many connections" error? Because the way to resolve each of those is very very different.

I run my sites as lean as possible when it comes to MySQL - allocating sufficient RAM to InnoDB data pool to ensure it is fully held in RAM, but limiting the number of connections to ensure that we're not using more RAM than required.

I use mysqltuner to keep track of the maximum number of connections actually used and ensure that my max used is set such that we are never at more than 80% of my maximum number of possible connections.

One of my sites is currently at 62 connection out of a max 100
The other is currently at 67 out of a max 70 - I'm just about to change that to 85 max connections.

Unless you are running an extremely busy site, you probably don't need as many connections as you think you do.

Either way - there is no recommended value for XF - the appropriate value will depend entirely on your own setup and the traffic patterns to your site. I suggest you gather some kind of metrics (eg mysqltuner) to keep track of what is actually being used on your site - and adjust accordingly.
 
Server error log
  • XF\Db\Exception: Too many connections
  • src/XF/Db/Mysqli/Adapter.php:172
  • Generated by: Unknown account
  • Jun 22, 2025 at 8:02 PM

Stack trace​

#0 src/XF/Db/Mysqli/Adapter.php(31): XF\Db\Mysqli\Adapter->makeConnection(Array)
#1 src/XF/Db/AbstractAdapter.php(62): XF\Db\Mysqli\Adapter->getConnection()
#2 src/XF/Db/Mysqli/Adapter.php(116): XF\Db\AbstractAdapter->connect()
#3 src/XF/Db/AbstractAdapter.php(518): XF\Db\Mysqli\Adapter->escapeString('https://flighti...')
#4 src/XF/Mvc/Entity/Finder.php(341): XF\Db\AbstractAdapter->quote('https://flighti...')
#5 src/XF/Mvc/Entity/Finder.php(151): XF\Mvc\Entity\Finder->buildCondition('old_url', '=')
#6 src/addons/Andy/RedirectManager/XF/Mvc/Dispatcher.php(21): XF\Mvc\Entity\Finder->where('old_url', 'https://flighti...')
#7 src/XF/Mvc/Dispatcher.php(55): Andy\RedirectManager\XF\Mvc\Dispatcher->route('threads/america...')
#8 src/XF/App.php(2826): XF\Mvc\Dispatcher->run()
#9 src/XF.php(806): XF\App->run()
#10 index.php(23): XF::runApp('XF\\Pub\\App')
#11 {main}

Request state​

array(4) {
["url"] => string(48) "/threads/american-eagle.29593/reply?quote=291448"
["referrer"] => bool(false)
["_GET"] => array(1) {
["quote"] => string(6) "291448"
}
["_POST"] => array(0) {
}
}
 
It's worth running some analytics - because if your database server is actually running slow and queries are taking a relatively long time to complete, then the thread running those queries won't be available to take on a new query and you'll need more connections to handle the load.

What value do you have set for innodb_buffer_pool_size and what is your actual InnoDB usage?
 
I've done some tuning and things are fine since. This just started with xf 2.3. It's odd how many connections are used.
 
Back
Top Bottom