How to configure Matomo for speed

Configure Matomo for speed

Configure your server for speed

Use case: a Matomo user reported to us tracking 6.5 Million pages in March 2013, with PHP having only 512M of memory. The following recommendations help configure a server for maximum speed:

  • Hosting Matomo on a powerful dedicated server is recommended when tracking medium to high traffic websites of more than 1 million pageviews per month.
  • The server(s) you need (and CPU, RAM, Disk) depend on how many pageviews you are tracking each month. Whether you are tracking 1 million pageviews or less, 10 million pageviews, 100 million pageviews, or even more, you can find our basic recommendations of server sizing in the Matomo Server Requirements user guide.
  • Matomo (php/Mysql) will benefit from significant RAM memory on the server: 1GB memory being the minimum recommended for Matomo to process reports on very large websites, the more RAM the better!
  • Use PHP7, and the latest available stable version. (PHP7 brings huge performance improvements over PHP5)
  • It is critical to use a PHP cache for high performance. Fortunately, PHP5 and newer versions such as PHP 7 come with this PHP cache included by default.
  • It is recommended to use light web servers such as Nginx or lighttpd which can be faster and more efficient alternatives to Apache or IIS
  • Do not use Matomo on a shared/cluster/network filesystem such as NFS or glusterfs. Network filesystems are slower, and will create a big overhead on top of Matomo. Please use standard filesystems for all Matomo files.
  • For advanced users, you can setup Matomo to work in a load balanced environment and use multiple servers behind a load balancer.
  • Tracker API: if you manage a high traffic Matomo server, you can easily setup Matomo Tracking API to use a Redis datastore for extremely fast and scalable Tracking API requests. Learn more about our QueuedTracking plugin in How do I configure Matomo to use Redis for better scalability?
  • Tracker API: if the ‘Provider’ plugin is activated in your Matomo, the Internet provider by doing a reverse DNS lookup which adds a few milliseconds overhead. To track your visitors’ ISPs it will be faster to use either MaxMind’s ISP or Organization. Read more about installing them here. Alternatively, for optimal performance you may disable the ‘Provider’ plugin (the plugin is disabled by default for all new users since Matomo 2.15.0) and skip the potentially slow reverse DNS lookup.
  • Learn how to setup reliable Matomo tracking for high traffic websites, using the asynchronous access logs bulk loading (advanced users only).

Configure your database server for speed

Matomo performance are heavily tied to Mysql database server performance as all Matomo data is stored and aggregated using Mysql queries.

  • When possible, use Solid-state drives (SSDs) as they are often faster.
  • A rough estimate of Matomo Mysql database size usage is approximately 1GB for every 5M page views. If your website tracks 100k page views per day (3M pages per month), you can expect a DB size of ~ 7GB after 1 year.An important factor for achieving good performance is to keep the number of unique URLs tracked low. Please make sure you setup ignored URL parameters you do not wish to count in the URL (such as session ID parameters). The less unique URLs tracked in Matomo the better!
  • We recommend to use Mysql Tuning Primer or Mysql Tuner tools which will suggest optimal Mysql settings.
  • We now use Mysql Innodb tables by default (instead of Myisam) which leads to more reliability. Performance can be improved by tuning Mysql innodb settings. You may increase innodb_buffer_pool_size option as long as it fits into the RAM, which will improve general Matomo performance. We recommend to set innodb_buffer_pool_size to at least 80% of the RAM available to MySQL (and even a higher ratio if you have more than 8G of RAM).
  • In MySQL configuration you may also set innodb_flush_log_at_trx_commit=2 (reference), which will increase the tracker throughput significantly.
  • See also optimizing Innodb I/O on mysql.com.
  • We recommend to configure MySQL and point the tmpdir to a filesystem in the RAM for example using tmpfs, instead using a tmp directory on the disk. As MySQL uses tmpdir to create and store temporary datasets, it brings additional speed when only the RAM needs to be used.
  • If you have limited database space, it may help to delete old logs, for example visitor logs older than 6 months. It helps keep the database size more manageable.
  • If your website tracks 100M+ pages per month, Matomo may start to reach php memory limits or other mysql or hardware limitations.
  • There have also been a few Matomo users tracking more than a billion pageviews over several months. If you need help, get in touch with Matomo experts.
  • The official Matomo Analytics cloud service can support high traffic Matomo servers up to 500 Million actions tracked per month.

Optimise your website tracking for speed

Resources