MySQL Max Connections

mariadbMySQLPHPphp-fpmWordpress

If "max_connections" is set to "75", does this mean 75 people at most can access the database until the connection is closed? On a WordPress website, when a visitor loads the website does that make a MySQL connection? If so, does it close immediately after?

If the WordPress website doesn't allow commenting or posting/uploading of any kind, are there any database connections needed? Or only to pull the WordPress initially? Does ach page require a new connection?

If I run 3 WordPress Websites on a single VPS, the max_connections variable globally covers the 3 databases, correct? To clarify, all the databases together have a total of 75 connections combined, not 75 each, right?

Are there variables that are dependent or must be changed when adjusting the max_connections variable?

Best Answer

  1. Yes, 75 connections means 75 people can do something with the website at the same time. This isn't 75 people viewing the site, it's 75 people actively requesting pages, which could be 10 times more. You can reduce this by caching the web page, in Wordpress, at the web server layer, or in a content distribution network.
  2. Yes, each view of a page uses database connection, unless you use caching as described above.
  3. Yes, the limit is on all connections to the database, not each wordpress instance.
  4. Nothing mandatory that I know about, but for optimisation maybe there are other tweaks that can be done. Documentation link.

The caching I described varies based on your web server, if you want to cache at that layer. For Nginx there's a great article on microcaching here, you can just extend the caching time. There will be plenty of article on caching with Apache.

Caching at the CDN layer is more dangerous. You don't want logged in user pages to be served to anonymous users or vice versa, so proceed with caution and research.

Related Topic