How to configure Matomo to handle unexpected peak in traffic?
There may be scenarios where you may have a peak in traffic, during these times there may be many concurrent requests which in turn cause the database to quickly overloaded.
To ensure reliability for high traffic Matomo during peaks of traffic, it is critical to use our Queued Tracking plugin to store all incoming requests into a queue, to make it possible to process requests faster in bulk asynchronously.
Please follow these steps:
- Get QueuedTracking from the Marketplace
- Activate the QueuedTracking plugin in « Matomo Administration > Plugins «
- Under « Matomo Administration > System > General Settings > QueuedTracking »
- Select Backend = MySQL Select Number of Queue workers = 1
- Select Number of requests that are processed in one batch = 50
- Disable the setting Process during tracking request
-
Then setup a cronjob that executes the command
./console queuedtracking:process
every minute, for example:MAILTO=your-email@company.com #Process tracking requests from the queue * * * * * php /path/to/matomo/console queuedtracking:process --no-ansi >/dev/null 2>&1
Then to check this is working, you can keep track of the queue and see how big it is by executing the command:
./console queuedtracking:monitor
This will show the current state of the queue. In traffic peak time the queue will grow 1,000 or 10,000 requests or more, but usually the queue should be around 0-150 requests.
For any bug report or feature request, please post them in the plugin’s issue tracker.