Skip to content

perf: add local in-memory cache for session-end jobs#207

Open
ayushjhanwar-png wants to merge 1 commit into
mainfrom
perf/local-session-cache
Open

perf: add local in-memory cache for session-end jobs#207
ayushjhanwar-png wants to merge 1 commit into
mainfrom
perf/local-session-cache

Conversation

@ayushjhanwar-png

Copy link
Copy Markdown

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).

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant