Repository navigation
Pulse Monitor: Cost page views nothing unless visitor counting is on - #1011
Merged
Merged
Conversation
OpenStation adds nothing to front-end pages, and the monitor now keeps
it that way on the server too. Front-end page views (visitors, bots)
are only counted when an administrator turns on the new `pulse_visitors`
extended option ("Count site visitors in the Pulse Monitor"), off by
default; until then a page view returns before anything is classified
or written, even with a monitor open. A front-end 5xx still beats.
When a request is recorded, the write no longer delays anyone or
weighs on the database:
- The recorder runs last on `shutdown` and closes the response first
(fastcgi_finish_request / litespeed_finish_request), filterable via
`openstation_pulse_finish_request`.
- With a persistent object cache the log lives in the cache and never
touches `wp_options`.
- Without one, ordinary traffic writes the log at most once a second
(autoloaded `openstation_pulse_gate`); failures and explicit events
(comments, logins, orders, publishing) always write.
New filter `openstation_pulse_count_visitors` overrides the option.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Failures are sampled like everything else (one log write a second at most), so the site-wide failure rate stays fair and a burst such as a login attack never becomes a write per request. Only comments, publishing and orders always write. - With a persistent object cache the one-second gate is an atomic `wp_cache_add`, so the requests in between never fetch the log. - The monitor no longer forces Heartbeat to 15 s: it keeps the user's own rate, since every tick is a full request to the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
We claim OpenStation adds no front-end performance penalty. The Pulse Monitor (#1006) bent that: while any admin had the wallpaper or widget open, every uncached front-end page view read and rewrote a ~26 KB
wp_optionsrow atshutdown. On a local site that added 6–7 ms to the end of each response, with all visitors contending on one row.What changes
Page views are opt-in. Front-end page views (
visitors,bots) are only counted when an administrator turns on Count site visitors in the Pulse Monitor:pulse_visitorsextended option, defaultfalse; filteropenstation_pulse_count_visitors.When something is recorded, nobody waits, and writes are rare and small:
shutdown(PHP_INT_MAX) and closes the response first withfastcgi_finish_request()/litespeed_finish_request(). Theopenstation_pulse_finish_requestfilter turns this off.openstation_pulse) and never touch the database. The gate is an atomicwp_cache_addwith a one-second TTL, so the requests in between never fetch the log.openstation_pulse_logoption. It is gated by a tiny autoloadedopenstation_pulse_gatetimestamp, which is free to check.Heartbeat. The monitor no longer forces Heartbeat to 15 s. It keeps the user's own Heartbeat rate (OpenStation settings, 15–60 s), since every tick is a full request to the server. A slower rate only means site-wide beats arrive later; the trace still replays them at their real spacing.
Docs:
pulse-monitor.md: cost model and delivery.hooks-reference.md: two new filters.data-model.md: gate option, cache location,pulse_visitors.Measured
wp-env (Apache + mod_php, so no early close), Twenty Twenty-One home page, 100 anonymous requests per run, two rounds. This ran before failures joined the sampling and the cache gate was added; neither changes the default path.
Testing
wp_optionsand the cache gate samples.tscclean, ESLint 0 errors, PHPCS clean.To try:
🤖 Generated with Claude Code