How to maximize your Piwik server’s efficiency

Published: September 28, 2017 Updated: December 19, 2018 Author Category Product Best Practices

Piwik is one of the leading web analytics solutions. It is commonly used because it puts the user in full control.

Today we are going to look at ways of optimizing your Piwik instance. We will analyse how to enhance performance with tips about infrastructure, inbuilt settings, database and archiving processes.

If you are new to this topic, or you’re considering deployment of a Piwik platform for your own business or organisation, these tips will prove helpful to you.

Be in control of your own platform

As both analytics software and database packages are implemented onto your own web server, you are in direct control of your instance. You can access and customize it via the user interface and via APIs. The platform is easy to access, and even if you are a basic level user you won’t find it hard to create reports, search for accurate data, measure goals and conversions, and follow KPIs of your own choosing. For users that are already familiar with the platform, analyses can be evaluated based on different areas of their website. They can also collect all the information needed to extract data for customized user reports. This, as you can see, is full control. Improvement of your Piwik server efficiency can also be in your hands. Remember to be consistent and follow the routines that we detail below, because continuous perfect performance is the goal we’re aiming for.

1. Upgrade for significant performance growth

As soon as an upgrade of the Piwik PRO instance is available, a coordinator will send you a link with the appropriate package for you download. After the file has been downloaded successfully:

  • unpack the files
  • stop the tracker and enable maintenance mode
  • exchange the new file with the previously installed one
  • run the ./console core:update command
  • start the tracker and disable maintenance mode
  • replay logs previously obtained when the tracker was disabled
  • run core:archive to check if process works
  • after that check if data within your graphs has been updated

Optimize Piwik’s Performance Issues: A Free Guide

Learn how to boost Piwik’s reporting speed and strengthen web analytics data security:

Download FREE Guide

2. Don’t forget to delete old log files

You constantly analyse data, and the old data stays saved on the server even though you don’t need it anymore. Old log files also take up space and drain major resources. If you remember to delete your unneeded log files as well, you can enhance your Piwik server for better performance and speed. If you don’t want to be bothered deleting log files manually, choose the automatic deletion option (read more about deletion options in your user self-support guide under Analytics Settings). If you prefer to keep the data saved for a certain amount of days, or if not all rows of the logs need to be deleted, adjust the setup to your needs. If the data is archived (aggregated) and you have such reports in your database, it’s safe to remove the raw data, unless you want to create a new segment. New segments are always calculated based on the raw data. So, if it’s not available, it won’t be possible to calculate such reports.

Delete old visitor logs

3. Choose the right infrastructure and learn how to configure your server for an excellent setup

The Piwik PRO platform uses PHP, a general-purpose scripting language, for server-side development. Piwik supports many versions of PHP, but for great performance we recommend using at least version 5.6. You should also install extensions to PHP, such as PHO GD and php5-curl, php5-gd, php5-cli, php5-geoip. Additionally, it operates an open source database system – MySQL. Use MySQL version 5.6 or greater or MariaDB 10+ with a TokuDB engine. We also recommend using the web server Nginx, since it works better with static files. Regarding the different server configurations that you may apply, you should choose the option that complies with the traffic volume on your website. For example:

Version 1: fewer than 30,000 events per month occur on your website, your Piwik instance works on most hosting.
Version 2: fewer than 300,000 events per month, Piwik works on fast-shared hosting and virtual servers.
Version 3: more than 3 million events per month, which means you will need a virtual server or dedicated hosting.

Piwik PRO is designed to handle over 500 million page views or events per month. In some cases our platform can handle as much as 2 billion actions per month, but that comes with some limitations in report segmentation. In cases where the number of page views and events are this high, we recommend a server cluster. A server cluster is a collection of servers that communicate with one another in order to provide better service. The standard cluster setup that we recommend is:

  • one archiving server
  • two frontend servers
  • two DBs with master-master replication

4. Get in the habit of deleting older reports

Your Piwik instance lets you analyse data based on the information you collect. Once the data is extracted, the system drafts a report for you containing the necessary information. These reports are then stored. We chose this design for a simple reason – once you have access to the report, you don’t need to run the analysis every time, therefore you can experience performance improvement.

If you don’t need to check up on your older reports, you can simply click YES in the ‘Regularly delete old reports from the database’ box. This way you make more space within your database and have control of more of its capacity. All these options are highly customizable. You can specify with ease which reports should be erased and which saved for further analysis.

Delete old reports

Contact your Coordinator for more information

5. Shut them down if you don’t need them

Piwik was created to collect data. Collected data ought to be processed in real-time. What if you don’t need real-time data? Do you need constant updates? Real-time analysis updates your system every 150 seconds by default. However, to gain better performance you could also disable browser archiving and use a scheduled archiving process. To use a scheduled archiving process, visit General Settings in Piwik Settings and enable schedule archiving option.

6. Reduce URL Tracking

You track a lot of URL query parameters, but do you need to track them all? Start tracking visits to your webpage without tracking every random URL parameter such as the session ID. Log in as the Superuser, go to Settings > Manage Website Menu, and start editing and managing the parameters that can be excluded from URL tracking.

URL

7. Change your segmentation settings and revise your archiving processes

Archive data from segments based on raw data gathered from the last time the segment was modified and created. Rather than archive all your segments from beginning to end, your Piwik instance will only capture those that you updated. It will thus process all the data quicker and update only the newest information. If you choose not to set up automatic archiving, the archiving will only happen when a user requisitions the Piwik report. This might slow down the entire operation a bit, also spoiling the user experience. Therefore, use auto-archiving (set it up via cron job), which is designed to update reports at a specific time every hour. For even better performance, disable your browser archiving and real-time segments by adding below settings to your Piwik configuration file:

[General]
browser_archiving_disabled_enforce = 1
enable_create_realtime_segments = 0

8. About using Nginx

We mentioned in a previous section that we recommend Nginx as your Piwik server. A basic Apache server, for example, may not be able to handle a rise in traffic, where Nginx is more suitable for growing websites. Nginx does not contain .htaccess files, so you need to place all configuration data directly into the Nginx configuration file. If you decide to run Nginx on your Piwik instance, you can find the right configurations here.

9. If you’re aiming for ace performance, adjust your database

To boost your database, you can use tools such as:

  • MySQL tuner
  • MySQL Tuning Primer
  • Percona toolkit

Your SQL database can quickly grow to a large size. Normally it requires around 1 GB of storage for 5 million page views.

The InnoDB tables can also be tuned within the MySQL settings. For example, increase the innodb_buffer_pool_size (while making sure it fits within the allotted RAM), and also set the innodb_ ush_log_at_trx_commit=2; this greatly enhances tracker throughput, further boosting performance. The website mysql.com also has good advice, including ways to optimize InnoDB I/O performance, for example by enabling tables compression.

10. Create a good environment – Piwik on a dedicated server

If you encounter any kind of traffic problems within your Piwik infrastructure, we highly recommend conveying your Piwik installation to its own server. Assuming that you’re sharing a host, consider using a Virtual Private Server. In case you are working on the entire capacity of a core dedicated Piwik server, you may upgrade your server by adding better hardware.

11. Adding RAM is never a bad idea

Every server works better with additional RAM. If you are tracking many websites and many visitors activities, you should have at least 16GB of server memory. Your Piwik installation uses its memory not only to run analyses, but it also stores data temporarily during the archiving process. Try to find a VPS or a cloud storage service where you can adjust the available RAM to actions of your choosing.

12. Optimize your PHP cache code

For enhanced performance you could run a PHP cache such as APC or XCache. If you are using PHP version 5.5.0, this optimization is already added in the bundle.

Optimize Piwik’s Performance Issues: A Free Guide

Learn how to boost Piwik’s reporting speed and strengthen web analytics data security:

Download FREE Guide

13. Introduce a load balancer to your Piwik installation

As you are maybe already aware, a load balancer is a device that distributes traffic across several servers. Load balancers were designed to increase capacity. To introduce this option into your installation, follow the steps below:

  • synchronize the config/config.ini.php on all your servers
  • erase the content of the tmp/* folder
  • enable database sessions storage by triggering the session_save_handler variable in the config/config.ini.php file that you previously synchronised and if the mentioned variable is not in the file, you can just add it under the GENERAL section: just use command session_save_handler = dbtable

If your organization is already using our Piwik platform and you would like to learn more about efficiency and how to improve performance, please don’t hesitate to contact us. Also, if you are ready to take your web analytics to another level, feel free to…

Request a Demo

Author:

Anna Cederholm, Content Marketer

See more posts of this author
Free Guide: How to Handle Piwik’s Performance & Security Issues

Share