Skip to content

Fix RedisSharedStorage failing under load with redis-py 8 - #4185

Open
T4rk1n wants to merge 2 commits into
devfrom
fix/redis-async-pool-limit
Open

T4rk1n wants to merge 2 commits into
devfrom
fix/redis-async-pool-limit

Conversation

@T4rk1n

@T4rk1n T4rk1n commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

With redis-py 8, RedisSharedStorage streaming callbacks fail under load with MaxConnectionsError: Too many connections.

redis-py 8 lowered a pool's default max_connections from 2**31 to 100 and raises once all 100 are busy. Dash built each event loop's async client with defaults, so a burst of pumps publishing at once failed. The pump's terminal done frame most likely failed the same way, so the browser waited until it timed out. With 4 uvicorn workers at 2000 streaming browsers, 7% of streams failed. On redis-py 5.2.1 the same run had no errors.

The async client now uses a BlockingConnectionPool of 100 connections that waits up to 20 s for a free one. This covers both the url path and the passed-client path. Redis still sees a bounded number of connections per worker. A 400-connection pool gave no measurable gain on the same load.

Load test (4 uvicorn workers, redis-py 8.1.0, 20 frames per stream): no errors at 2000 or 4000 browsers.

Test: test_async_burst_larger_than_the_pool_waits_for_connections in tests/shared_storage/test_redis_backend.py runs 500 concurrent async calls through the url and passed-client paths. It fails without the fix.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Dash performance benchmarks

⚠️ regressions to review

scenario metric p90 (ms) median growth baseline p90 note
⚠️ initial_render_small render_ms 126.3 78.0 0.65x 104.0 1.5x baseline (norm)
✅ callback_chain chain_ms 375.8 360.4 0.88x 499.1
✅ callback_chain graph_ms 1.8 1.8 1.0x 2.4
✅ callback_fanout fanout_ms 71.2 66.2 0.91x 92.5
✅ deep_nesting render_ms 47.4 43.4 0.97x 56.8
✅ full_children_replace replace_ms 155.2 92.6 3.06x -
✅ initial_render_large render_ms 511.2 457.7 0.93x 694.4
✅ patch_append_nested append_ms 117.4 79.8 2.36x 192.3
✅ patch_append_toplevel append_ms 117.9 93.7 2.6x 140.2
✅ patch_scalar_update_large update_ms 148.5 138.4 0.96x 202.9
✅ rerender_existing_subtree rerender_ms 121.5 99.1 0.92x -
✅ wildcard_all_resolve wildcard_ms 242.6 230.7 0.94x 313.6
✅ wildcard_all_resolve graph_ms 0.7 0.7 1.0x 1.3

growth = late-third / early-third per-op time; ~1 is flat, a large value means the per-op cost scales with accumulated state.

machine scale vs baseline: 0.81x - divided out of the baseline ratios so they compare like for like (the absolute warn/fail ceilings are left un-scaled); calibrated on initial_render_small.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants