FingerLakesRunnersClub / Leaderboards

Leaderboards for the FLRC Challenge and Trail Circuit
https://fingerlakesrunners.org
GNU General Public License v3.0
0 stars 0 forks source link

HTTP 429 (Too Many Requests) against Discourse API when starting up a new app #146

Closed SteveDesmond-ca closed 1 year ago

SteveDesmond-ca commented 1 year ago

Steps to reproduce

  1. Start the 2022 Challenge leaderboard app locally
  2. Hit the front page twice, at least 10 (but less than 30) seconds apart

Expected behavior

Observed behavior

Notes As we get later into the challenge, once there are multiple pages of community posts per course, the Discourse API starts complaining that we're trying to download too much data too quickly. The DataService should be smarter about which pages to download -- it will always need the first page to get the number of posts in the topic, but we should be able to cache the "middle" pages. Alternatively, or maybe in addition, based on what type of throttle headers come back, we may be able to do some sort of async easing in the background (and just temporarily show outdated numbers)

adamengst commented 1 year ago

The Discourse team is also very responsive to suggestions, if it's something they're doing "wrong."

SteveDesmond-ca commented 1 year ago

I remember seeing something in the docs about the rate limit being configurable via code, I think it's more just that downloading 50 pages simultaneously is an edge case that's not supported with the default config.

SteveDesmond-ca commented 1 year ago

I think I figured it out: https://github.com/discourse/discourse/blob/fd718c1a421b9f0e447ae9c48eedb194a50f9c72/lib/middleware/request_tracker.rb#L10-L17

Will test tomorrow or this weekend and assuming it works this can be closed.

SteveDesmond-ca commented 1 year ago

This was resolved via Discourse config