Piwik is outage when we encounter MySQL connection problem

Hi, Sir,

After search on Google and this forum, we still cannot have any idea;
therefore, we ask for help here.

Our Piwik version is 2.16.1 and the peak visits is 213,292 per day.
We found that when we encounter the following problems, our Piwik server cannot reply to clients’ requests any more.
What we can do is to kill MySQL process and then restart MySQL service because service restart doesn’t work at that time.
After restart MySQL service, Piwik comes back to normal again.
Do you have any suggestion?

[problem 1] Error in Piwik (tracker): Error query: SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query In query: SELECT visit_last_action_time, visit_first_action_time, idvisitor, idvisit, user_id, visit_exit_idaction_u…
[problem 2] Error in Piwik (tracker): SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘’ (111)

Alex Kan

provide additional information about the system (version) and database (version, engine). If possible database logs and a list of processes (‘show processlist’ command) from the database at the time when the problem occurs.

Hi, jlubzinski,

Thanks for your response.
Our MySQL innodb_version is 5.5.47 and it’s built on Ubuntu 14.04.4 LTS.
It has only several connections (fewer than 10) at normal time.
However, when we encounter the problems mentioned above, all the connections are occupied and we cannot login MySQL.
Now we try to set max connections to 500 and watch it.

Try to see also the cpu usage and disk utilization.

It is OK when the problem occurred.

Ok, processlist and engine innodb status would be useful for further analysis. You can also use pt-stalk as a deamon to gather information.

Please see our official performance recommendations guide: How to configure Piwik for speed - Analytics Platform - Matomo

we mention there a very useful plugin, see: http://plugins.piwik.org/QueuedTracking

Hi, Matthieu,

Thanks a lot for your suggestion.
We will try it.