Which can cause "too many database connections"

My Wordpress site received a "database connection error message."

My host informed me that this is because my โ€œuserโ€ had too many database connections that were opened right away. This caused an error, causing additional connections, and therefore massage.

This has been fixed by killing connections to locked databases. There were several connections that copied data to temporary tables, but the deadlock was caused by a large set of queries waiting for a single update.

Can someone explain to me how this could happen and how to avoid it?

(ps: this WP installation contains more than 2000 messages)

+3
source share
5 answers

In a shared hosting environment, this behavior will happen sooner or later as your blog starts to see more traffic - features that you talked about, for example, they may be related to poorly written WordPress plugins (to ensure efficiency, make sure all your plugins are updated along with the core of WordPress).

You can also consider WP Super Cache if you haven't already.

+4
source

, , WP - . WP , 2000 . SQL- phpmyadmin, . , 75% . , WP .

DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'

, , phpmyadmin, , :

OPTIMIZE TABLE wp_posts;

post/page, wp-config.php, :

define ('WP_POST_REVISIONS', FALSE);

, :

define('WP_POST_REVISIONS', 3);

MySQL, MySQL , GitHub - major/MySQLTuner-perl.

+6

, ,

MySQL , ( PHP).

MySQL max_connections , .

+2

wordpress , DB:

-, , , . , , .

, , , ( , , ), SELECT, NOLOCK, .

SO

+1

Too many database connections can occur when you have too many database connections (obviously), that is, there are more people doing queries on your site at a time than the maximum allowable connections. How many connections does the mysql server allow?

Are you using mysql_pconnect () or just mysql_connect ()? With the first, the connection will remain open longer, and you cannot force it to close.

+1
source

Source: https://habr.com/ru/post/1768799/


All Articles