Skip to content

feat(grpc): add BBR-based adaptive rate limiting middleware for gRPC#1732

Merged
gaius-qi merged 5 commits intomainfrom
feature/middleware
Mar 17, 2026
Merged

feat(grpc): add BBR-based adaptive rate limiting middleware for gRPC#1732
gaius-qi merged 5 commits intomainfrom
feature/middleware

Conversation

@gaius-qi
Copy link
Copy Markdown
Member

@gaius-qi gaius-qi commented Mar 17, 2026

Description

This pull request introduces an adaptive rate limiting feature based on a BBR-inspired algorithm for gRPC download and upload servers, and synchronizes workspace dependencies across the project. The most important changes are the addition of the BBRConfig and its integration into server configuration, implementation of the BBR middleware for gRPC, and updates to dependency versions for improved consistency and compatibility.

Adaptive Rate Limiting for gRPC Servers

  • Added BBRConfig struct for adaptive rate limiting configuration to dragonfly-client-config/src/dfdaemon.rs, including default values and integration into the Server struct and its Default implementation. This enables dynamic request shedding based on CPU and memory usage. [1] [2] [3]
  • Implemented serialization, deserialization, and default logic for BBRConfig in dragonfly-client-util/src/ratelimiter/bbr.rs, along with helper functions for default values. Added debug logging for cooldown periods. [1] [2] [3] [4]

Middleware Integration

  • Integrated the BBR rate limiter middleware (BBRLayer) into both download and upload gRPC servers (dragonfly-client/src/grpc/dfdaemon_download.rs and dragonfly-client/src/grpc/dfdaemon_upload.rs), including struct changes and service builder layering. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Dependency Synchronization

  • Updated workspace package version and dependency versions in Cargo.toml files across the project to ensure consistency, including strict version pinning for several crates (e.g., dragonfly-client, tonic, opentelemetry, tower, console-subscriber, etc.). [1] [2] [3] [4] [5] [6]

Codebase Maintenance

  • Minor refactor in dragonfly-client/src/grpc/manager.rs for improved readability and import clarity.

Related Issue

Motivation and Context

Screenshots (if appropriate)

@gaius-qi gaius-qi added this to the v2.5.0 milestone Mar 17, 2026
@gaius-qi gaius-qi self-assigned this Mar 17, 2026
@gaius-qi gaius-qi added the enhancement New feature or request label Mar 17, 2026
…ddleware

Signed-off-by: Gaius <gaius.qi@gmail.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 48.52941% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.87%. Comparing base (b44f9a8) to head (f939e56).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dragonfly-client/src/grpc/middleware.rs 25.80% 23 Missing ⚠️
dragonfly-client/src/bin/dfdaemon/main.rs 0.00% 5 Missing ⚠️
dragonfly-client/src/grpc/dfdaemon_download.rs 0.00% 3 Missing ⚠️
dragonfly-client/src/grpc/dfdaemon_upload.rs 0.00% 3 Missing ⚠️
dragonfly-client-util/src/ratelimiter/bbr.rs 96.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1732      +/-   ##
==========================================
+ Coverage   46.53%   46.87%   +0.33%     
==========================================
  Files          86       87       +1     
  Lines       24749    24811      +62     
==========================================
+ Hits        11517    11629     +112     
+ Misses      13232    13182      -50     
Files with missing lines Coverage Δ
dragonfly-client-config/src/dfdaemon.rs 89.31% <100.00%> (+0.01%) ⬆️
dragonfly-client/src/grpc/manager.rs 22.07% <ø> (ø)
dragonfly-client/src/grpc/mod.rs 0.00% <ø> (ø)
dragonfly-client-util/src/ratelimiter/bbr.rs 79.80% <96.00%> (+15.38%) ⬆️
dragonfly-client/src/grpc/dfdaemon_download.rs 5.03% <0.00%> (-0.02%) ⬇️
dragonfly-client/src/grpc/dfdaemon_upload.rs 0.00% <0.00%> (ø)
dragonfly-client/src/bin/dfdaemon/main.rs 0.00% <0.00%> (ø)
dragonfly-client/src/grpc/middleware.rs 25.80% <25.80%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gaius-qi gaius-qi enabled auto-merge (squash) March 17, 2026 12:30
@gaius-qi gaius-qi merged commit 9d9b5ec into main Mar 17, 2026
7 checks passed
@gaius-qi gaius-qi deleted the feature/middleware branch March 17, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants