Counting pageviews on high-traffic cached sites

Our site is quite high traffic and we use both nginx and w3 total cache to handle the load. We’ve previously been using wp-postviews to count the page views, but it seems to be locking the postmeta table now, and often doesnt count views at all. It’s unreliable at best.

Can anyone suggest a way for us to count page views and put them into the DB, or any specific workable solutions?

My initial thoughts are to have the view count done via javascript to update a separate database, then a cron job at the end of each day to merge the results, but I’m not sure where to start.

Thanks in advance

3 Answers
3

It really depends what you need to view counts for – if it’s just for seeing traffic stats, then use Google Analytics or any number of javascript tracker based analytics tools.

If you need integration of page view counts and the ability to do things like order post by views, then you can either

  • spend some time optimising your database – some options and things to consider
    • more memory for MySQL
    • change the postmeta table to be InnoDB
    • get a separate database server
    • make sure you’ve tuned your MySQL settings (use mysqltuner as a starting point)

OR

  • Use something like Piwik and spend time integrating it (it has a decent API) with WordPress.

Leave a Comment