perf: configurable guest-user + nav-tree cache TTLs (longer defaults) to let Aurora idle under scrapes#2
Open
jee7s wants to merge 1 commit into
Conversation
…faults) Two periodic DB reads fire on anonymous/crawler page views, both *under* Aurora Serverless v2's idle/pause window, so they keep the cluster awake during scrapes: - the guest user was reloaded from the DB every 1 minute (hardcoded) - the sidebar nav tree was cached for only 300s (5 min) Make both configurable and default them to 1 hour, so they no longer pin the DB awake under sustained anonymous traffic (1h >> the 8-min pause window) and the DB can idle between refreshes. Cuts guest-reload queries ~60x and nav queries ~12x on scrape traffic. Both stay correct: changing group permissions force-refreshes the guest user immediately (flushGuestUser), and the admin "Flush Cache" clears the nav cache. Env knobs (with defaults): AUTH_GUEST_CACHE_TTL=3600, NAV_CACHE_TTL=3600.
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
Targets
fix/session-store-cleanup-interval. That branch lets the wiki's DB connections drain so Aurora Serverless v2 can auto-pause when idle. But two periodic DB reads still fire on anonymous / crawler page views — and both are shorter than the 8-min pause window, so a search-engine scrape keeps the cluster awake (and billing ACUs):getGuestUser, auth.js)getTree, navigation.js)With both at 1h (≫ the 8-min pause window), they no longer pin the DB awake under sustained anonymous traffic — the DB can idle/pause between refreshes. Cuts guest-reload queries ~60× and nav queries ~12× on scrape traffic.
(Page content is already DB-free on repeat hits via the existing disk page cache; the remaining scrape→DB drivers were these two periodic refreshes — this closes them.)
Changes
auth.js: guestcacheExpirationnowplus({ seconds: WIKI.config.auth.guestCacheTTL })instead of a hardcoded 1 minute.navigation.js: nav cache TTL nowWIKI.config.nav.cacheTTLinstead of300.server/app/data.yml(auth.guestCacheTTL: 3600,nav.cacheTTL: 3600), env mapping indev/build/config.yml(AUTH_GUEST_CACHE_TTL,NAV_CACHE_TTL), docs inconfig.sample.yml.Correctness
flushGuestUser(setscacheExpirationto the past), forcing a reload regardless of TTL.nav:sidebar:*on demand.Note (multi-instance)
These caches are per-process; before running wiki at >1 task, back them with Redis / broadcast invalidation (out of scope here, single-task today).
🤖 Generated with Claude Code