#Hitting many 429's despite using ratelimiter

1 messages · Page 1 of 1 (latest)

celest pagoda
#

neuroWaveA Hello, I was redirected here by @elder charm after posting in the discord api server.
I'm using twilight_http with the InMemoryRatelimter, but I keep getting hit with 429's which I'd like to avoid. This is on the /users/{user.id} endpoint, and I'm just using it to fetch known valid users.
To try and avoid this, I've tried:

  • resyncing my clock
  • making sure nothing else is using the same discord token.
# TYPE discord_api_requests counter
discord_api_requests{status="200"} 3229
discord_api_requests{status="429"} 839

(metrics from my backend, showing the response code counts)
Is there a better option than just retrying when I hit a 429? I'd really like to avoid them in the first place.

n.b. I can share my source code if helpful, but its basically just calling Client::user a bunch, concurrently

maiden moon
elder charm
#

Also if you are doing them parallel you might run into sending off your request before you have gotten the ratelimits header because we are quite optimistic there

celest pagoda
celest pagoda
elder charm
#

It is something to try out if it is not too hard to change to.

#

We have some discussion about rewriting the ratelimiter, but that is probably not going to be done too soon.

celest pagoda
#

👍 I'll give it a shot, though probably won't be able to let you know if it's working for a while

#

yeah that's fair enough, ratelimiting is a pain

maiden moon
celest pagoda
#

the ratelimits I'm hitting don't seem to be global ones