Skip to content

Conversation

ishaan-jaff
Copy link
Contributor

@ishaan-jaff ishaan-jaff commented Sep 29, 2025

[Fix] Parallel Request Limiter v3 - use well known redis cluster hashing algorithm

Fixes LIT-1133

Implements Redis cluster slot calculation in the parallel request limiter to ensure proper key grouping and prevent cross-slot operations in Redis cluster environments.

  • Prevents "CROSSSLOT" , "EVALSHA" errors by grouping keys correctly
  • Uses standard Redis cluster slot algorithm: CRC16(key) mod 16384
  • Only applies slot calculation when Redis cluster is detected

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix
✅ Test

Changes

Copy link

vercel bot commented Sep 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Sep 30, 2025 0:35am

@ishaan-jaff ishaan-jaff requested a review from Copilot September 30, 2025 00:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements Redis cluster compatibility for the parallel request limiter by using the standard Redis cluster slot calculation algorithm. The changes prevent CROSSSLOT and EVALSHA errors that occur when Redis operations span multiple cluster slots.

  • Implements CRC16-based slot calculation algorithm (CRC16(key) mod 16384) following Redis cluster standards
  • Adds cluster detection logic to apply slot grouping only when using Redis cluster
  • Updates key grouping strategy to use slot numbers instead of hash tags for cluster environments

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
litellm/proxy/hooks/parallel_request_limiter_v3.py Implements Redis cluster slot calculation and detection logic
tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py Updates tests to cover both regular Redis and cluster scenarios with proper mocking

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ishaan-jaff ishaan-jaff merged commit ebf72f5 into main Sep 30, 2025
43 of 50 checks passed
ishaan-jaff added a commit that referenced this pull request Sep 30, 2025
…ing algorithm (#15052)

* test_keyslot_for_redis_cluster

* fix _is_redis_cluster

* Update litellm/proxy/hooks/parallel_request_limiter_v3.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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