-
Notifications
You must be signed in to change notification settings - Fork 155
Add rate limiting that respect retry-after and TorBox specific limits #895
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
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
|
I checked over this change, it won't actually solve the problem unfortunately. Two main issues:
Because the cooldown on createtorrent/createusenet can be in the range of an hour or more, using the HTTPClient to queue and handle that may not be the best way to go anyway unless also implementing a BulkHead policy based on the Max Concurrent downloads. |
|
I've taken the Retry-After and resiliency parts of this change into #912 . Once asylumexp/TorBox.NET#5 is merged I'll look at retry handling the ACTIVE_LIMIT rates for TorBox. |
User description
Ran into issues with adding loads of content to be downloaded by rdt-client, constantly seeing on active torrents that rate limit exceeded.
This has been completely vibe coded, but it built and I deployed a docker image at colinajd/rdt-client and am currently using it and all functionality seems to be working as expected.
Please review if you think this is a worthwhile attempt at resolving the specific rate limiting issue/ TorBox use case
PR Type
Enhancement
Description
Implement TorBox-specific rate limiting with sliding window algorithm
Add per-second and per-minute/hour limits for create torrent operations
Migrate from Polly to Microsoft.Extensions.Http.Resilience for retry handling
Support Retry-After header parsing for server-provided delay preferences
Create separate HTTP clients for general and torrent creation requests
Diagram Walkthrough
File Walkthrough
DiConfig.cs
Implement TorBox rate limiting and retry strategyserver/RdtClient.Service/DiConfig.cs
SlidingWindowRateLimiterinstances for TorBox ratelimiting (5/sec general, 10/min and 60/hour for create torrent)
Microsoft.Extensions.Http.Resilience framework
exponential backoff with jitter
RD_CLIENT,TORBOX_CLIENT, andTORBOX_CLIENT_CREATETORRENTwith appropriate resilience handlersPolly.Extensions.Http
TorBoxTorrentClient.cs
Route torrent creation through rate-limited clientserver/RdtClient.Service/Services/TorrentClients/TorBoxTorrentClient.cs
GetClient()method to accept optional client name parameterfor selecting appropriate HTTP client
AddMagnet()to useTORBOX_CLIENT_CREATETORRENTclient fortorrent creation requests
AddFile()to useTORBOX_CLIENT_CREATETORRENTclient fortorrent creation requests
TORBOX_CLIENTwhenno client specified