perf: add local in-memory cache for session-end jobs#207
Open
ayushjhanwar-png wants to merge 1 commit into
Open
perf: add local in-memory cache for session-end jobs#207ayushjhanwar-png wants to merge 1 commit into
ayushjhanwar-png wants to merge 1 commit into
Conversation
Replace per-event Redis lookups (HGETALL + getState) with a local Map cache in the worker pod. GroupMQ's deterministic SHA1 sharding guarantees the same deviceId always routes to the same pod, making the local cache safe. - Cache session-end Job objects after creation and on Redis fallback hit - Skip Redis on cache hit, only call changeDelay to reset the timer - Invalidate cache when session-end job fires - Add periodic cleanup (60s sweep) and bounded size (50K max entries) - Add tests for cache hit, cache miss, and cache invalidation Expected impact: ~66% reduction in session-related Redis commands (from ~30K to ~10K calls/sec at 10K events/sec).
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.
Replace per-event Redis lookups (HGETALL + getState) with a local Map cache in the worker pod. GroupMQ's deterministic SHA1 sharding guarantees the same deviceId always routes to the same pod, making the local cache safe.
Expected impact: ~66% reduction in session-related Redis commands (from ~30K to ~10K calls/sec at 10K events/sec).