← All messages

Counting visitors without writing a row

The heartbeat of visitors measured what a visit is worth: time on a page while it is visible, the page that came next, where the visitor came from. It also wrote two rows for every beat, from PHP, to a table each app had to point at a database. An app on SQLite did not count, and an app whose database was away for a minute lost that minute of visitors.

The page still sends the same beats at the same moments, with the same fields, plus an event and the version of the protocol. Only the destination changed: a GET to /.phlo/beat/1 with the fields in the query, the last one on leaving with keepalive. The web server answers it itself with 204 and keeps it in its access log. No PHP runs and nothing is written, so every app measures, whatever its database.

The counting moved to the place that sees every server: the Phlo Dashboard reads the log when someone looks or a hub polls, from where it got last time, a bounded batch at a time, and keeps its counts and its position in one transaction. The same log tells a visitor who pinged, and so ran the page, from a client that never pinged, a bot by its user agent and a datacenter by its address, and it gives the errors and the slow pages of a site without a line of extra code. The country comes from the lists of the internet registries, on the server itself; no address goes to a lookup service.

The price is a web server that keeps the contract of docs/visitors.md of the engine. The dashboard ships it for Caddy as one snippet; a server without it passes every ping to the app and counts nothing.

We use essential cookies to make this site work. With your permission we also use analytics to improve the site.