{"id":1601,"date":"2026-11-04T08:24:03","date_gmt":"2026-11-04T08:24:03","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1601"},"modified":"2026-11-04T08:24:03","modified_gmt":"2026-11-04T08:24:03","slug":"self-hosted-analytics-on-a-vps","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/","title":{"rendered":"Running Self-Hosted Analytics on a VPS"},"content":{"rendered":"<p><strong>TL;DR \/ Summary:<\/strong> A privacy-friendly analytics tool on a VPS needs almost no resources, but it does need a retention policy. Left alone, a visit table grows until the disk fills and the database slows to a crawl.<\/p>\n<h2>The workload is smaller than you think<\/h2>\n<p>Self-hosted analytics without cookies stores far less than a traditional platform. There is no cross-site tracking, no long user history, and often no personal data at all\u2014just page views, referrers, and coarse device information.<\/p>\n<p>That means the database is small and the queries are simple aggregates. A single vCPU and 1 GB of RAM handles a site with tens of thousands of monthly visits comfortably.<\/p>\n<p>The resource risk is not traffic spikes. It is unbounded growth combined with a reporting query that scans a large table.<\/p>\n<h2>A realistic specification<\/h2>\n<p>One vCPU, 1 GB RAM, 25 GB SSD is ample for a single site. If you run several sites on one instance, the limit is usually disk rather than CPU.<\/p>\n<p>Memory matters more than CPU because the database will cache indexes and query results. Below 1 GB, the database starts evicting cache and aggregate queries become noticeably slower.<\/p>\n<ul>\n<li><strong>CPU<\/strong> \u2014 1 vCPU is enough; analytics is mostly idle<\/li>\n<li><strong>RAM<\/strong> \u2014 1 GB minimum, 2 GB comfortable for multiple sites<\/li>\n<li><strong>Disk<\/strong> \u2014 25 GB, with retention configured from day one<\/li>\n<li><strong>Bandwidth<\/strong> \u2014 modest; the tracking script is tiny<\/li>\n<\/ul>\n<p>Do not size for the marketing page&#8217;s claimed capacity. Size for your actual traffic and let retention control growth.<\/p>\n<h3>The tracking script cost<\/h3>\n<p>Privacy-friendly analytics scripts are usually a few kilobytes, served from your own domain. That is both a performance benefit and a privacy benefit, since there is no third-party request.<\/p>\n<p>Serve it with a long cache lifetime and compression. It is the single most requested asset on every page, so caching it properly reduces load more than any server tuning.<\/p>\n<h2>Retention is the whole game<\/h2>\n<p>Raw visit data has diminishing value over time. You need recent detail and long-term aggregates, not three years of individual page views.<\/p>\n<p>Set raw retention to something like ninety days and keep monthly aggregates indefinitely. Most tools support this split natively; where they do not, a scheduled job can summarise and delete.<\/p>\n<p>Check the retention setting after every upgrade. A reset during an update is a quiet way for the table to start growing again.<\/p>\n<blockquote><p>Retention is not a storage decision. It is a performance decision.<\/p><\/blockquote>\n<h2>Backups and their real value<\/h2>\n<p>Analytics data is less critical than transactional data, but a year of history is still worth keeping. A nightly dump retained for a fortnight, plus a monthly archive, is sufficient.<\/p>\n<p>The monthly archive can be compressed aggressively. Aggregate data compresses well, and it is the part you are most likely to want in two years.<\/p>\n<p>Store one archive off the server. A backup on the same disk is not a backup, and analytics is exactly the kind of low-priority data that gets forgotten until the disk fails.<\/p>\n<h2>Running it behind a reverse proxy<\/h2>\n<p>If you already run a reverse proxy for other services, put analytics behind it rather than exposing a second public port. One entry point is easier to secure and easier to monitor.<\/p>\n<p>Forward the real client IP correctly. Analytics that logs the proxy&#8217;s address instead of the visitor&#8217;s produces useless geography and useless referrer data.<\/p>\n<p>Check that the forwarded headers are trusted only from the proxy. A misconfigured header allows anyone to spoof their address, which corrupts the data.<\/p>\n<h2>Preventing bot pollution<\/h2>\n<p>Bot traffic inflates numbers and hides real trends. Most privacy-friendly tools filter common crawlers by user agent, and that catches the majority.<\/p>\n<p>Add a filter for requests without a referrer from your own pages if the tool supports it. Direct hits with no session are usually bots.<\/p>\n<p>Review the top referrers monthly. A sudden spike from an unexpected source is almost always a scraper, and filtering it changes the picture significantly.<\/p>\n<h2>What to monitor<\/h2>\n<p>Watch three things: disk usage, database size, and the time taken by your main dashboard query. Those three reveal most problems before users notice slow pages.<\/p>\n<p>Set a disk alert at eighty percent. Analytics is the service most likely to fill a disk silently, because it grows without any human action.<\/p>\n<p>Log rotation matters too. Application logs on a low-traffic service can still grow over months if nothing prunes them.<\/p>\n<h2>Is it worth self-hosting<\/h2>\n<p>For a single site, a hosted analytics service is often cheaper in time. Self-hosting makes sense when you run several sites, want full data ownership, or need to avoid third-party scripts for compliance reasons.<\/p>\n<p>If those reasons apply, a modest instance from <a href=\"https:\/\/virtualserversvps.com\/\">virtual servers VPS<\/a> is more than enough capacity, and the operational work is a few hours a year.<\/p>\n<p>The service is genuinely low-maintenance once retention is configured. The mistake is treating it as set-and-forget before setting the one thing that controls its long-term size.<\/p>\n<h2>Aggregating for long-term trends<\/h2>\n<p>Raw pages are useful for a month and useless for a year. Aggregate into daily or weekly totals and keep those indefinitely; they are small and they answer the questions people actually ask.<\/p>\n<p>Aggregation also removes personal data from the long-term set, which simplifies any privacy obligations the site may have.<\/p>\n<p>Schedule the aggregation before the deletion, in that order. A job that deletes first and aggregates second loses the data it was meant to summarise.<\/p>\n<h3>Dashboards that stay fast<\/h3>\n<p>Point dashboards at aggregates rather than raw tables. A dashboard querying a year of raw rows will be slow on a small box, and slow dashboards stop being used.<\/p>\n<p>Cache the expensive dashboard query for a few minutes. Analytics does not need to be real-time, and a five-minute cache removes most of the load.<\/p>\n<p>Review the dashboard monthly and delete panels nobody reads. Every unused panel is a query that still runs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR \/ Summary: A privacy-friendly analytics tool on a VPS needs almost no resources, but it does need a retention policy. Left alone, a visit table grows until the disk&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1601","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Running Self-Hosted Analytics on a VPS - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"TL;DR \/ Summary: A privacy-friendly analytics tool on a VPS needs almost no resources, but it does need a retention policy. Left alone, a visit table\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running Self-Hosted Analytics on a VPS\" \/>\n<meta property=\"og:description\" content=\"Running Self-Hosted Analytics on a VPS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-04T08:24:03+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/\",\"name\":\"Running Self-Hosted Analytics on a VPS - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-11-04T08:24:03+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"TL;DR \/ Summary: A privacy-friendly analytics tool on a VPS needs almost no resources, but it does need a retention policy. Left alone, a visit table\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Running Self-Hosted Analytics on a VPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Running Self-Hosted Analytics on a VPS - Virtual Servers VPS Blog","description":"TL;DR \/ Summary: A privacy-friendly analytics tool on a VPS needs almost no resources, but it does need a retention policy. Left alone, a visit table","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/","og_locale":"en_US","og_type":"article","og_title":"Running Self-Hosted Analytics on a VPS","og_description":"Running Self-Hosted Analytics on a VPS","og_url":"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-11-04T08:24:03+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/","url":"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/","name":"Running Self-Hosted Analytics on a VPS - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-11-04T08:24:03+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"TL;DR \/ Summary: A privacy-friendly analytics tool on a VPS needs almost no resources, but it does need a retention policy. Left alone, a visit table","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/self-hosted-analytics-on-a-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Running Self-Hosted Analytics on a VPS"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=1601"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1601\/revisions"}],"predecessor-version":[{"id":1602,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1601\/revisions\/1602"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}