Skip to content

per PDS backfill ratelimiting#1322

Open
whyrusleeping wants to merge 1 commit intomainfrom
feat/rate-limit-backfill
Open

per PDS backfill ratelimiting#1322
whyrusleeping wants to merge 1 commit intomainfrom
feat/rate-limit-backfill

Conversation

@whyrusleeping
Copy link
Collaborator

A global rate limit is a little bad, so I added some retries on 429's, and also a per-PDS rate limiter

Copy link
Collaborator

@bnewbold bnewbold left a comment

Choose a reason for hiding this comment

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

left some comments.

overall seems relatively straight-forward and low-risk to merge 👍

NSIDFilter string
SyncRequestsPerSecond int
RelayHost string
// Per-PDS rate limit (requests per second per host). If 0, defaults to 2.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this logic is a bit weird to me, i'd expect the default to be 2, but 0 to mean no limit?

}

// Wait on global rate limiter
b.syncLimiter.Wait(ctx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should handle the possible err returned here (and two lines below). those would happen if the ctx is cancelled. otherwise the error will come from the client.Do(), and it would naively look like an HTTP request timeout.

return instrumentedReader, nil
}

resp.Body.Close()
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is the HTTP non-success status code path. I think you need to drain the body here, or the connection can't be reused (eg, HTTP/2), which is relevant b/c you're probably making many requests to a PDS, and there will be some suspended/deleted accounts.

could also be nice to fetch error response JSON body and log it or something. doesn't need to happen in this PR but a TODO comment would help track it.

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