July 7 2023

The Inefficiency of WordPress Visit Counters Based on PHP and MySQL and the Effective Alternatives

Avoid slowing down or even crashing a WordPress site by using inefficient and non-performing visit counter functions.

WordPress, recognized as the most popular content management platform (CMS) globally, boasts a wide range of plugins designed to allow users to monitor and quantify the flow of visits to their websites. Despite the popularity of such tools, many plugins are built using PHP and MySQL, two technologies that, despite their ubiquity, can present their own set of efficiency and performance challenges, especially when there is a lot of network traffic.

Inefficiencies of Visit Counters based on PHP and MySQL

Visit counters in WordPress based on PHP and MySQL work by generating hundreds or thousands of PHP threads per second to manage visits and store this information in the database through INSERT or UPDATE operations. When traffic becomes heavy, this process can become problematic, resulting in server overload due to the constant creation of new PHP threads and database congestion.

PHP and MySQL are also not known for their performance in terms of speed and efficiency. Compared to more modern and agile technologies, such as Go and NodeJS, or NoSQL databases, such as REDIS or MongoDB, PHP and MySQL can be less performing, especially when it comes to managing a large number of concurrent requests.

The problem with the Post Views Counter plugin

Among the various WordPress plugins used to monitor site traffic, Post Views Counter is one that unfortunately stands out for its limitations rather than its strengths. Designed for sites with low traffic volume, its operation becomes problematic and inefficient when it has to handle a large number of visitors.

Post Views Counter is based on PHP and MySQL, two technologies that, as we have seen, can suffer in terms of efficiency and speed when faced with high traffic. Consequently, the use of this plugin can lead to server overload and database slowdown, due to the continuous INSERT and UPDATE operations required to record visits.

Post Views Counter

Making matters worse, Post Views Counter does not interact effectively with server-side caches like Varnish Cache or NGINX FastCGI Cache. In fact, it tends to bypass these caches, causing PHP code to be executed and the database to be accessed for each visit, a behavior that further reduces the site's speed and overall performance.

Given its design and limitations, Post Views Counter turns out to be an unsuitable plugin for sites with high volume of traffic. If used in such contexts, it should be immediately removed and replaced with a more performant and suitable alternative, such as the external services Google Analytics, Matomo or Jetpack. These not only avoid the problems associated with using PHP and MySQL, but also offer a number of additional features for more detailed and useful monitoring of site traffic.

Interaction with Server Side Caches and Consequential Problems

Another emerging issue is the interaction of many WordPress hit counter plugins with server-side caches, such as Varnish Cache or NGINX FastCGI Cache. These plugins tend to bypass these caches via AJAX calls to 'admin-ajax.php', thus defeating the effectiveness of a highly efficient page caching system like Varnish. As a result, every single visit could result in PHP code execution and database access, having a significant negative impact on site speed and overall performance.

The file admin-ajax.php is a crucial component of WordPress, often used to handle AJAX requests. Before we get into how it works, it's helpful to take a step back and understand what an AJAX call is.

AJAX, acronym for Asynchronous JavaScript and XML, is a web development technique that allows you to make changes to a web page without having to completely reload it. Using AJAX, a website can send and receive data from a server in the background (asynchronously), allowing parts of the page to be refreshed without disrupting the user experience.

In the context of WordPress, admin-ajax.php is the file that handles these AJAX calls. When a WordPress plugin or theme needs to perform an AJAX function, the request is sent to admin-ajax.php, which handles the request and sends a response. This process can be used for a variety of functions, such as uploading new posts, counting visits, updating comments, and many more.

Despite its usefulness, admin-ajax.php can present problems. One of the most notable is that AJAX calls bypass server-side caches like Varnish Cache or NGINX FastCGI Cache by default. This means that each AJAX request executes PHP code and accesses the database, even if the requested data hasn't changed. This behavior can cause server overload and site slowdown, especially with a high volume of traffic or a large number of AJAX requests.

Also, the fact that admin-ajax.php both used for both front-end and back-end side requests can lead to performance issues, since all AJAX requests must go through the same trigger point, regardless of their complexity or purpose .

In conclusion, despite being a fundamental component of WordPress, admin-ajax.php has limitations that can have a significant impact on site performance. It is important to take this into account when developing or choosing a WordPress plugin or theme, and look for solutions that minimize the use of AJAX calls or handle them more efficiently.

Unwanted Side Effects

Issues associated with using PHP and MySQL-based visitor counting plugins can trigger a number of undesirable side effects, including increased server load, server crashes, and subsequent service outages, not to mention inevitable negative impact on the user experience and visibility of the site on search engines. These consequences can be exacerbated in situations of high web traffic, with the need to handle a massive number of requests simultaneously.

One of the most common problems in this situation is the increased load on the server. With an increasing number of requests to handle, PHP and MySQL can find themselves under pressure, having to work harder to manage the flow of data. This can lead to excessive consumption of server resources, making the entire system slower and potentially unstable.

502 bad gateway nginx

In some cases, server overload can lead to a 500 type error, an HTTP status code indicating a general server failure. In particular, if you are using PHP-FPM (FastCGI Process Manager) to handle PHP requests, saturation of PHP FPM pools can cause a 500 error. This error is usually a sign that the server is struggling to handle the current workload .

Even a server crash is a possible consequence of these issues. In extreme circumstances, the high workload can bring the server to a complete stop, causing site downtime. Not only does this interrupt access to the site, but it can also have repercussions on the site's reputation and user trust.

Alternatives to Visit Counters based on PHP and MySQL

A possible remedy to these problems is to avoid the use of plugins that operate in the manner described above. A commonly employed feature at the theme level is the 'post_views_count()' function. This feature logs each visit to a specific post and updates a counter in the database. Although it may seem useful, it contributes to increase the load on the server and the database.

A more efficient strategy would be to rely on external services such as Google Analytics, Matomo or Jetpack. These services manage the counting of visits on separate servers, thus reducing the load on the website server.

The Potential of Jetpacks

Jetpack, one of the most reputable external services for managing and monitoring WordPress sites, stands out for its ability to handle a huge volume of traffic, peaking at hundreds of thousands of visitors per second without taxing the server hosting the site. But in addition to this amazing traffic management capability, Jetpack also boasts a wide range of features that allow detailed and precise monitoring of visits, making it an extremely useful tool for analyzing user trends and behaviors.

Jetpack Visit Counter functionality

Jetpack's visit counting functionality goes beyond simply providing a total number of visits. On the contrary, it offers a series of detailed statistics, providing a complete picture of site traffic and its trends.

Jetpack allows you to view daily, weekly, monthly and yearly statistics. This allows you to easily monitor traffic trends over time and to identify peak periods or possible decreases in visits. This information can be very useful for optimizing content or marketing strategies, for example choosing the best time to publish new posts or launch new campaigns.

But Jetpack goes further, offering the possibility to analyze visits to individual posts as well. This means that you can have an accurate picture of which contents are performing better, which ones are attracting more visitors and which ones could need improvement. This feature helps you understand which themes or topics are most popular with your visitors, allowing you to tailor your content strategy based on audience preferences.

In addition, Jetpack offers a geographic view of visits, allowing you to see where in the world visitors are coming from. This can be especially useful for targeting content or marketing campaigns towards specific geographic markets.

JetPack statistics Visitor counter


Visit counters based on PHP and MySQL, while common in WordPress, can cause a variety of problems, especially when there is high web traffic. Relying on external services such as Google Analytics, Matomo or Jetpack can not only solve these problems, but can also provide a number of additional features that improve the efficiency, performance and general management of the website. To ensure a smooth, fast and traffic-handling WordPress website, it is essential to make the right choices in terms of tools and technologies.

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.


Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.


Managed Server Srl is a leading Italian player in providing advanced GNU/Linux system solutions oriented towards high performance. With a low-cost and predictable subscription model, we ensure that our customers have access to advanced technologies in hosting, dedicated servers and cloud services. In addition to this, we offer systems consultancy on Linux systems and specialized maintenance in DBMS, IT Security, Cloud and much more. We stand out for our expertise in hosting leading Open Source CMS such as WordPress, WooCommerce, Drupal, Prestashop, Joomla, OpenCart and Magento, supported by a high-level support and consultancy service suitable for Public Administration, SMEs and any size.

Red Hat, Inc. owns the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. owns the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds holds the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt. Oracle Corporation owns the rights to Oracle®, MySQL®, and MyRocks®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; REDIS® is a registered trademark of Redis Labs Ltd. F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB. Adobe Inc. holds the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited. Automattic Inc. owns the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert holds the rights to Drupal®. Amazon Web Services, Inc. holds the rights to AWS®; Google LLC holds the rights to Google Cloud™ and Chrome™; Microsoft Corporation holds the rights to Microsoft®, Azure®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®. Apache® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group. CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV Hetzner Online GmbH owns the rights to Hetzner®; OVHcloud is a registered trademark of OVH Groupe SAS; cPanel®, LLC owns the rights to cPanel®; Plesk® is a registered trademark of Plesk International GmbH; Facebook, Inc. owns the rights to Facebook®. This site is not affiliated, sponsored or otherwise associated with any of the entities mentioned above and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. Any other trademarks mentioned belong to their registrants. MANAGED SERVER® is a trademark registered at European level by MANAGED SERVER SRL, Via Enzo Ferrari, 9, 62012 Civitanova Marche (MC), Italy.


Would you like to see how your WooCommerce runs on our systems without having to migrate anything? 

Enter the address of your WooCommerce site and you will get a navigable demonstration, without having to do absolutely anything and completely free.

No thanks, my customers prefer the slow site.
Back to top