-
Notifications
You must be signed in to change notification settings - Fork 239
Adding rate limit functionality for ingress bandwidth and operations per second #2093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…to sourav/rateLimit
…to sourav/rateLimit
…to sourav/rateLimit
…to sourav/rateLimit
There was a problem hiding this 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-secandlimit-ops-per-secwith 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 |
| 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)") |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
Type of Change
Description
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:
limit-bytes-per-secandlimit-ops-per-sectoAzStorageOptionsand CLI flags, allowing users to set bandwidth and operation rate limits. Default is -1 (unlimited). (component/azstorage/config.go,component/azstorage/azstorage.go)component/azstorage/config.go,component/azstorage/connection.go)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)component/azstorage/utils.go)Supporting Changes:
Rangeandx-ms-rangeheaders, determining the size of download requests for bandwidth limiting. (component/azstorage/utils.go)golang.org/x/timefor rate limiting. (go.mod)NOTICE)How Has This Been Tested?
component/azstorage/config_test.go)component/azstorage/policies_test.go)component/azstorage/utils_test.go)Checklist