MySQL number of threads_connected slow down my website

6.2k views Asked by At

I have an store running on Prestashop 1.5.4. I keep having a problem with the site behaviour.

Everytime i check this number

user@server:~$ mysql -se "show status like '%threads_connected%'"

If the number gets above 25, my site becomes really slow. Opening a page takes forever and page load can get as high as 1 - 2 minutes.

The only solution (temporary) is for me to restart the apache services.

I am pretty sure 25 is a pretty low number.

In case you need to know, i don't have direct access to my.ini nor to any access to MySQL Server Configuration. My database is stored in a shared (DBaSS).

I do however have full access to my webserver (apache2.conf, php.ini, www.example.com.conf)

A little info that might help:

-se "show variables like '%max%'"

Outputs:

Image 1 Image 2

I guess my question is how can i improve performance ? Can i improve this by limiting the number of "threads_connected" ?

footnote:

I am aware that there is probably a bad query somewhere in the code, however, at the moment i need a quick solution for this. As reviewing all queries can take some time.

EDIT #1

Perhaps this information might give some ideas

php.ini php.ini

EDIT #2 apache2.conf

1

There are 1 answers

4
Michael - sqlbot On BEST ANSWER

Can i improve this by limiting the number of "threads_connected"?

Absolutely not.

All you could do by limiting the number of connections would be to cause errors for users of your site, because their particular Apache process wouldn't be able to connect to the database.

The problem is not the number of threads connected. That is a symptom of the real problem, which is that you have one or more queries that perform poorly, or that you do not have enough memory for Apache to scale up when traffic gets heavy, forcing your machine into heavily swapping, and thereby slowing down Apache to the point that it keeps connections open longer.

I need a quick solution for this

Sorry... but there isn't another solution other than to find the actual problem and fix it.

More useful than the number of connections is what are these connections doing right now?

SHOW FULL PROCESSLIST; in MySQL will answer that question. If they are just sleeping, they aren't hurting anything on the MySQL side, and you may want to limit the number of Apache processes, but if that is a side effect of the level of site traffic, then your server may actually be too small, or you may need to disable HTTP keepalive, or tweak the timeout, if browser connections are holding open Apache children that are idle, consuming memory.