HollaHoop

Redis: shared rate limiting and hot-read cache for API and MCP

FeatureShipped· by Elsama· 2 months ago

Context: API and MCP rate limiting is currently in-memory per pm2 process, so limits are roughly 2x intended and reset on every deploy. Public pages and hot queries hit Postgres directly.

Scope:

  • Add a Redis client with graceful in-memory fallback when REDIS_URL is unset or unreachable.
  • Move the REST rate limiter (src/lib/api/rest.ts) to Redis atomic INCR + TTL, shared across instances.
  • Extend rate limiting to the MCP endpoint (tools/call) with a batch-size cap.
  • Add a small cache helper for hot reads (status lists, project settings, public board payloads) with TTL + invalidation.

Infra: Redis LXC at 192.168.1.239:6379 (LAN). Requires a firewall allow from the prod VM 192.168.1.172 and REDIS_URL in /opt/hollahoop/.env. Rotate the Redis password before go-live.

Done when: limits are exact across both pm2 instances and survive a deploy; cache has TTL and invalidation; the app falls back cleanly when REDIS_URL is absent. Backs the broader abuse-hardening cards for API and MCP.

Comments (1)

  • Elsama· 2 months ago

    PR ready for review: https://github.com/El-SaMa/hollahoop/pull/47

    Optional Redis-backed shared rate limiting and hot-read cache for REST API + MCP. Env via REDIS_URL or REDIS_HOST/PORT/PASSWORD; fail-open to in-memory when unset or on error. No migration needed.

    Verified: 526 vitest passed, build, tsc, eslint.

Join the discussion

Sign in to leave a comment on this thread.

HollahoopGet yours