Skip to content

Conversation

@souravgupta-msft
Copy link
Member

@souravgupta-msft souravgupta-msft commented Jan 7, 2026

Type of Change

  • Bug fix
  • New feature
  • Code quality improvement
  • Other (describe):

Description

  • Feature / Bug Fix:

This PR introduces configurable rate limiting for Azure Storage operations, allowing users to limit ingress bandwidth (bytes downloaded per second) and operations per second. The changes include new configuration options, implementation of a rate limiting policy using golang.org/x/time/rate, integration with the storage pipeline, and comprehensive unit tests for the new functionality.

Rate Limiting Feature:

  • Added new configuration options limit-bytes-per-sec and limit-ops-per-sec to AzStorageOptions and CLI flags, allowing users to set bandwidth and operation rate limits. Default is -1 (unlimited). (component/azstorage/config.go, component/azstorage/azstorage.go)
  • Updated internal storage config to store these limits and propagate them during dynamic config parsing. (component/azstorage/config.go, component/azstorage/connection.go)
  • Implemented a new rate limiting policy using golang.org/x/time/rate, which enforces the configured limits for both bandwidth (on GET requests with range headers) and operation rate. (component/azstorage/policies.go)
  • Integrated the rate limiting policy into the Azure Storage client pipeline, applying it as a per-retry policy when limits are set. (component/azstorage/utils.go)

Supporting Changes:

  • Added a utility function to parse Range and x-ms-range headers, determining the size of download requests for bandwidth limiting. (component/azstorage/utils.go)
  • Updated dependencies to include golang.org/x/time for rate limiting. (go.mod)
  • Updated third-party notices to include the new dependency. (NOTICE)

How Has This Been Tested?

  • Added unit tests for config parsing and validation of rate limiting options. (component/azstorage/config_test.go)
  • Added comprehensive tests for the rate limiting policy, covering bandwidth and ops limits, no-limit scenarios, and header parsing. (component/azstorage/policies_test.go)
  • Added unit tests for the new range header parsing utility. (component/azstorage/utils_test.go)

Checklist

  • The purpose of this PR is explained in this or a referenced issue.
  • Tests are included and/or updated for code changes.
  • Documentation update required.
  • Updates to module CHANGELOG.md are included.
  • License headers are included in each file.

Copy link
Contributor

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 introduces configurable rate limiting for Azure Storage operations in Blobfuse2, allowing users to control both download bandwidth (bytes per second) and operation throughput (operations per second). The implementation uses the token bucket algorithm from golang.org/x/time/rate to enforce limits while allowing short bursts.

Key Changes:

  • Added configuration options limit-bytes-per-sec and limit-ops-per-sec with CLI flags and YAML support (default: -1 for unlimited)
  • Implemented rate limiting policy that enforces bandwidth limits on GET requests with Range headers and operation rate limits on all requests
  • Integrated rate limiting policy into the Azure Storage client pipeline as a per-retry policy

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
component/azstorage/azstorage.go Added CLI flags for limit-bytes-per-sec and limit-ops-per-sec configuration options
component/azstorage/config.go Added rate limiting configuration fields and parsing logic; updated logging to include new limits
component/azstorage/config_test.go Added unit tests for rate limit configuration parsing and validation
component/azstorage/connection.go Added limitBytesPerSec and limitOpsPerSec fields to AzStorageConfig struct
component/azstorage/policies.go Implemented rateLimitingPolicy with bandwidth and operations rate limiting using golang.org/x/time/rate
component/azstorage/policies_test.go Added comprehensive tests for rate limiting policy covering bandwidth limits, ops limits, and no-limit scenarios
component/azstorage/utils.go Added parseRangeHeader utility function; integrated rate limiting policy into client options
component/azstorage/utils_test.go Added unit tests for parseRangeHeader function with various Range header formats
go.mod Added golang.org/x/time v0.14.0 dependency
go.sum Updated checksums for golang.org/x/time dependency
NOTICE Added BSD-3-Clause license notice for golang.org/x/time

@vibhansa-msft vibhansa-msft linked an issue Jan 21, 2026 that may be closed by this pull request
capMbpsRead := config.AddInt64Flag("cap-mbps-read", -1, "Limit the throughput of downloads from your storage account. Value measured in megabits per second. Default is -1 (no limit)")
config.BindPFlag(compName+".cap-mbps-read", capMbpsRead)

capIOps := config.AddInt64Flag("cap-iops", -1, "Limit the total storage operations per second. Default is -1 (no limit)")
Copy link
Member

Choose a reason for hiding this comment

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

is cap-iops also related only to read ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it applies to all REST calls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Throttle max-concurrency if bandwidth limit is exceeded

5 participants