Repository navigation
perf(api): cache the database statistics for the monitoring api and the page - #1233
Open
karlitschek wants to merge 1 commit into
Open
karlitschek wants to merge 1 commit into
karlitschek wants to merge 1 commit into
Conversation
karlitschek
force-pushed
the
feat/os-status-collector
branch
2 times, most recently
from
October 25, 2026 19:19
6d327c2 to
34014ec
Compare
karlitschek
force-pushed
the
perf/api-statistics-cache
branch
from
October 25, 2026 19:25
0d7e87b to
3f289d1
Compare
The OCS info endpoint and the admin page's /data each ran about 25 database queries on every call: storage and user counts, ten share counts, eight active-user windows, and the database version and size, which on MySQL is SHOW TABLE STATUS and on PostgreSQL pg_database_size(). Monitoring systems scrape the endpoint every 15 to 60 seconds, so these queries ran thousands of times a day for values that change on a scale of minutes. StatisticsCache computes that block once and keeps it in the distributed cache under one key, which both callers read, so they never compute it twice. The block is stored as JSON with zero fractions preserved, so a float such as size_appdata_storage keeps its type on the Redis backend too and callers get exactly what a fresh computation returns. The lifetime comes from the new app config key statistics_cache_ttl: 300 seconds by default, clamped to 0..3600, with 0 turning the cache off. CPU, memory, PHP, PHP-FPM, OPcache and the web server stay live. The skipApps, skipUpdate and skipOs parts are outside the cached block and keep their own behaviour, so the cache needs no per-parameter keys. The statistics queries themselves are unchanged. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Frank Karlitschek <[email protected]>
karlitschek
force-pushed
the
perf/api-statistics-cache
branch
from
October 25, 2026 19:45
3f289d1 to
8ff02b5
Compare
karlitschek
marked this pull request as ready for review
October 25, 2026 20:25
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.
Based on
feat/os-status-collector(#1214).AI disclosure: this change was written with Claude Code (claude-opus-5-5) and is to be reviewed by the author before it leaves draft; every commit carries an
Assisted-bytrailer.🤖 Generated with Claude Code