How I work
- 01Measure archiving, run times and load
- 02Plan the topology, scale vertically or horizontally
- 03Tune database and PHP
- 04Slim down segments, reports and analyses
Typical causes when Matomo is slow
- Archiving runs in the browser instead of via cron
- Too many segments are processed in real time
- Raw data is kept forever
- Database and PHP are not sized for the traffic
- Tracking, archiving and reports share a single server
Scaling Matomo: topology and servers
The right infrastructure depends on traffic, the number of sites and your availability requirements. I plan with your IT team what goes where.
- Scale vertically More CPU and memory where it helps, usually the database first
- Scale horizontally Several tracking servers behind a load balancer, tracking requests buffered in a queue (Queued Tracking with Redis or Valkey)
- Separate roles A dedicated archiving server, reports and UI separated from tracking
- Relieve the database A replica for read queries, backups without load on the primary
Absorbing traffic peaks with Queued Tracking
Campaigns, newsletters or press coverage can bring many times the usual tracking requests within minutes. With the Queued Tracking plugin, Matomo first only accepts them and puts them into a queue instead of writing every request to the database straight away. Tracking stays fast under load, and the database works through the requests at an even pace.
- Redis or Valkey Fast storage for the queue, separate from the Matomo database
- Dedicated workers Systemd services work through the queue continuously, with several workers in parallel if needed, instead of tying processing to individual tracking requests
- Monitoring Keeping an eye on the queue length so nothing piles up during a peak
As long as the workers keep up, the data reaches Matomo with hardly any delay.
Database and PHP
- MySQL or MariaDB InnoDB buffer pool and log sizes that fit the data, indexes, queries and table sizes reviewed, old raw data and archives cleaned up
- PHP A current version, OPcache, memory limit and run time for archiving, PHP-FPM pools sized for the load
- Archiving Via cron, with sensible intervals and parallel processes where the hardware allows
Analysis
Beyond the technology it is about the questions behind it: where do visitors drop off, which channels bring enquiries, which content works? Together with your team I build reports and dashboards that answer these questions.
