Many medium-high traffic websites successfully use Matomo to track and analyse their website behavior and performance. See this FAQ for general information about high traffic Matomo.
If you want to provide high reliability and better performance in your Matomo setup, you can load balance Matomo services on various servers. It is pretty easy to do so, but make sure you read the following documentation.
Matomo stores all tracking data, reports, users, settings, etc. in the shared mysql database. Matomo also needs to read/create files to store information, caches, temporary files:

  • config/config.ini.php is used by every request to Matomo. It contains db access, plugins enabled, various settings, etc. The file is only modified when the Super User changes some settings in the Admin interface (activating plugins, changing smtp settings, etc.). This file must be synchronized on every Matomo server.
  • tmp/* contains temporary and cached files such as: compiled templates, generated PDFs, tracking caches, etc. This directory tmp/ content can be safely deleted and Matomo (Piwik) will automatically recompile templates and recreate caches.
  • by default, Matomo uses file session storage, which are usually stored in tmp/sessions, or in the global sessions directory (see php.ini). There is a config setting to enable database session storage, see this faq

When Matomo is used behind a load balancer, here are the steps to follow:

  1. Synchronize config/config.ini.php on all servers – make sure the file config/config.ini.php is the same on all servers (using rsync for example).
  2. Upload all the Matomo files and all plugins to all servers, as it is important that all your servers run the same codebase with all features, including any free or premium plugin from the Marketplace.
  3. Enable database session storage (If you use 3.7.0 or later it should already be enabled by default)
  4. In your config.ini.php, below the section [General], add the following line: multi_server_environment=1. This setting lets Matomo know you’re using multiple servers and for example it will then not allow the installation of a plugin via the UI (or the plugin would be only installed on one server), or it will not allow config file changes from the UI (as the config file would be updated on one server only).
  5. We highly recommend to enable SSL in Matomo
  6. When using the Queued Tracking plugin with Redis it’s recommended to enable session affinity or “sticky sessions” on your load balancer to ensure that all actions for a specific visitor go to the same backend server to be processed in the order that the tracking requests are received.

Matomo should then work as expected in a load balanced environment. For example, a common way to load balance Matomo on 3 servers: Load balancer in front of (2x) webservers which are tracking/querying the (1x) Master mysql DB server. For further optimization, a (1x) UI webserver can be added, to handle all API requests, UI requests, and run the cron archiving. This server can also be doubled and load balanced.

Typically, webserver boxes would be cheap to operate (trackers, frontends and archivers), and the Master DB server would be larger (eg. multiple cores, 16G memory, fast disk access), which could scale to a certain point (100M hits per month is achievable and some users even track around 1 billion hits per month). Get expert support and help from the Matomo team.

After Maintenance mode is enabled, index.php endpoint will continue return 200 as HTTP status code as response instead of 503.

Learn more: How to configure Matomo for speed.

If your load balancer is used as a SSL proxy, make sure to read our FAQ: How do I configure Matomo when the server is installed behind a proxy?

Previous FAQ: How do I make Matomo faster?