feat: add backend caching for AMT API endpoints#768
Open
nmgaston wants to merge 28 commits into
Open
Conversation
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.
Summary
Adds backend caching for AMT API endpoints using robfig/go-cache to dramatically reduce latency and backend load for repeated requests within short time windows.
Problem
When users interact with the KVM interface or monitor device status, the frontend makes repeated API calls to fetch power state, features, and KVM display settings. Each call requires a round-trip to the AMT firmware, adding 150-500ms latency per request.
Solution
Implements thread-safe in-memory caching using robfig/go-cache with TTL-based expiration:
Performance Impact
Testing with real AMT device (GUID: d0c96538-9e19-4bc0-9d73-8864e641f77f):
Response time improvement: 25-164x faster for cached requests
Without cache: ~1.15s per request (1150ms)
Cold cache (first call): ~170ms
Warm cache (subsequent calls): 7-45µs (microseconds!)
Backend load reduction: ~67% fewer AMT API calls
Cache efficiency: ~100% hit rate within TTL window
Implementation Details
ttl: 0in config.yml to disable caching entirely?refresh=truequery parameter to skip cache and fetch live dataConfiguration
Security
ttl: 5 minutes (prevents excessive stale data retention)powerstate_ttl: 1 minute (limits power state staleness)Testing