Restart mysql to free the ram?


I have a site that does about 3 million page views per day, and I recently installed Matomo on another server to measure the site’s audience, in order to completely remove google analytics afterwards.

However I realize that although the server is powerful, the ram used does not cease increasing from day to day. The CPU is used at 10% on average and does not increase, but the ram can go from 10% to 50% in 5-6 days. I also realize that when I restart mysql, the ram used drops.

(on this capture, we go from 45% used ram to 17% after restarting mysql)

The server is as follows:

CPU : Intel Xeon-E 2136 - 6c/12t - 3,3 GHz/4,5 GHz
32 GB Ram

Do you recommend that I simply restart mysql once a month to free up the ram or is there a more optimized way to do this?

Small precision, the archives are executed in cron once per hour.

Thank you

Hi @Outline
Just to know, do you use Queued tracking plugin?

No I don’t use it because it seems that my server doesn’t have any trouble accepting/handling requests (in any case there are no errors in particular).

Maybe the Queued plugin can reduce MySQL memory use, as this allow to insert requests by batches…? Is it possible for you to try?

Okay I just installed it and activated it. I set it up for mysql, I filled in 8 workers and 25 requests that are processed in one batch. What do you think of this configuration ?

How many Matomo server do you have to track your 3M pages a day?

1 server:

CPU : Intel Xeon-E 2136 - 6c/12t - 3,3 GHz/4,5 GHz
32 GB Ram

For information, currently 20% of the RAM is used. I’ll watch for a few days

As your CPU is 6 cores, I would suggest use 6 queues…

If you have multiple CPUs available on your server you can add more workers. You can do this by going in the Piwik Admin interface to “Plugin Settings”. There will be a setting “Number of queue workers”. Increase this number to the number of CPUs you want to dedeciate for processing requests.
[From Queued Tracking plugin FAQ]

25 requests seems OK

Tell us (and mention myself) in a couple of day if yhe MySQL RAM is changing or not…

1 Like


Unfortunately the RAM keeps growing, 20% at the time I installed the Queued plugin, currently at 37% of the used RAM. Would you have another suggestion?

Another idea could be:

But I would not bet any penny on this… :thinking:

Maybe @innocraft has an idea?

@Outline Just to clarify:
The RAM is increasing on the Database host or on the application host?

If this is the RAM usage on the database host could you let us know what database server you’re using including the version number? For example if you’re using MariaDB there have recently been several updates that address memory leaks/ There is some discussion about this type of issue here:

1 Like


I’m using mariadb:
root@server:~# mysql -V
mysql Ver 15.1 Distrib 10.5.18-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper

I’m not sure I understand the question, but I would tend to say that the database is where the ram is used. I’ll let you judge for yourself via the following screen:

Thanks for your help guys

Would it at all be possible for you to test using a MySQL database server temporarily to see if the same issue is present? This is the second report of higher memory usage we’ve received in the last 12 months and in both cases the database server used was MariaDB.

It’s possible that certain queries used by Matomo might trigger a memory related bug that is present in MariaDB, the only way to confirm this is to either:

  • Switch to using MySQL or
  • Update to a much newer version of MariaDB and see if the same issue persists
1 Like

It seems that the RAM has stabilized at 45% of its usage, it doesn’t seem to go beyond that anymore. I’ll keep an eye on it for another 2 weeks to see if it stays stable, I’ll keep you posted.

Thanks for your answers