Matomo Load Balancing

Hi All,

Hope everyone is safe and well. I’ve got a few quick questions for those in the know which might hopefully save me a bit of bother as i’m about to setup Matomo in a load balanced environment

  1. The FAQ says to enable database storage. It looks like this has been enabled in Matomo by default since 3.8.0. However, i seem to have a lot of recent files in my \tmp\cache\tracker. Does this mean I don’t have this enabled? Is there a way I can check this?

  2. I have the Query Tracking plugin up and running in an isolated server - is this compatible with Load balancer, i.e can a load balanced webservers use the same Redis DB without issue?

EDIT - a bit more on 1) I received this error when opening matomo on my new load balanced webserver; does this mean that my my temp sessions are not being stored at the db level?

The directory “XXXXXXXXXXXX/tmp/cache/tracker/” is not writable.

Thanks All, stay safe


You can check your config.ini.php for a line called session_save_handler. If it isn’t set then the database is used by default. (In Matomo 4 that option is gone)

This only affects where sessions are stored. Matomo still stores other temporary things in the cache (e.g. information about marketplace plugins) which are stored in tmp/cache.

I can’t say much about load balancing as I have no experience with it.

1 Like

makes sense, thanks for the quick reply Lukas

Hi @Lukas ,

I’ve found a bit more about this which you may be able to help with! @matthieu wrote this on the github page, to be added to the FAQ

It mentions create a specific queue (or 2) per webserver and setting up a crontab to run on each server to run the server’s assigned queue (makes sense, essentially assigning queues per webserver to insert into the db) with the following command;

./console queuedtracking:process --queue-id=X

When activating ./console queuedtracking:process --queue-id=0 specifically for queue-id=0, it doesn’t work, i get this error

ERROR [2020-07-06 09:10:58] 4700 Uncaught exception: C:\inetpub\wwwroot\vendor\symfony\console\Symfony\Component\Console\Input\ArgvInput.php(242): The “–queue-id” option requires a value.

It works for fine for “./console queuedtracking:process --queue-id=1”

is this a known issue or am i doing something incorrectly?

Many Thanks!


For me both work (as I’d expect from the code)

➜  /var/www/matomo sudo -u www-data php7.3 /var/www/matomo/console queuedtracking:process --queue-id=0
Forcing queue ID: 0
Starting to process request sets, this can take a while

This worker finished queue processing with 0req/s (0 requests in 0.00 seconds)

➜  /var/www/matomo sudo -u www-data php7.3 /var/www/matomo/console queuedtracking:process --queue-id=1
Forcing queue ID: 1
Starting to process request sets, this can take a while

This worker finished queue processing with 0req/s (0 requests in 0.00 seconds)

Can you check if your shell is maybe modifying something and sending a different command (I also have to say I am not that familiar with Windows and Symphony Console that handles the command line arguments might be doing something weird)

Hey @Lukas, thanks for getting back mate.

Not sure how I would go about checking that but, I’ve just tried the command in Powershell as well as Windows Command Line and i’m getting the exact same error so i’m thinking it’s not the shell. It only happens on –queue-id=0, it is fine for –queue-id=1 etc

It might be something to do with this code in matomo;
Symfony could be equating the 0 passed through as boolean false, not an integer and throwing the RTE

    if (null === $value) {
        if ($option->isValueRequired()) {
            throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name));

Although i’m pretty thick and not a PHP man at all so could be completely wrong

Hi All,

If everyone else is stuck on this I’ve come around with a slightly cruder plan B

Basically i was worried that in a load balanced environment with 3 servers not talking to each other there may be inefficiencies when searching for the queue to process, maybe even enforcing a lock.

So basically rather than being able to assign a queue ID per server to process with ** queuedtracking:process --queue-id=xxx*, I’ve time banded the queuedtracking:process process to run every minute on different 20 second intervals per server. i.e 00:00:00 on server 1, 00:00:20 on server 2 and 00:00:40 on server 3.

Does the same job and shares around the burden - if anyone has any better ways, would love to hear it. I’m now up and running with matomo in a load balanced environment and feeling a large sense of relief - COVID spikes really pushed our incumbent setup to the limit!!