Skip to content

[Backend] Upgrade Redis Backend for Multi-Process / Distributed Environments #5

@Vishisht16

Description

@Vishisht16

🎯 Objective

Refactor the current Redis storage backend to properly support multi-process (e.g., multiple Uvicorn workers) and distributed environments using atomic operations or distributed locks.

💡 Why this matters

Currently, HumaneProxy supports Redis as a backend, but the rate-limiting and trajectory window logic relies on in-memory state or non-atomic Redis operations. If an enterprise deploys HumaneProxy behind a load balancer with 4 Gunicorn/Uvicorn workers, race conditions can occur in updating the session risk trajectory or rate limits. We need true distributed state handling.

✅ Acceptance Criteria

  • Review the current RedisBackend implementation in storage/.
  • Implement atomic operations for rate-limiting (e.g., using Redis INCR with EXPIRE natively, or a Lua script for sliding window rate limits).
  • Ensure the exponential time-decay trajectory window correctly appends and retrieves risk scores atomically across multiple workers.
  • Write a test case (or script) that simulates concurrent requests from multiple threads to ensure no race conditions occur.

📚 Resources

Metadata

Metadata

Assignees

Labels

backendIssues involving server-side logic, databases, or APIsenhancementNew feature or requestlevel:advancedRequires advanced implementation, bug fixing or refactoringtype:bugSmashes annoying bugstype:designDesign changes in codetype:docsDocumentation changetype:featureAdds a new featuretype:performanceFixes performance issuestype:refactorMultiple files refactored

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions