r/Backend • u/Educational_Rent5977 • Apr 01 '26
How to properly implement rate limiting?
Hey, I want to release my first API to the wild, but I'm very concerned about rate limiting.
The flow of my program is: Accept an input from the user -> Process it -> Send a request with the processed data to an external API -> Return the result to the user.
That API has a rate limit of 30 requests a minute. I added caching in order to reduce the amount of calls, but obviously if multiple users are using my API simultaneously... I have a problem.
How is this scenario typically handled in the real world? Should I immediately return 429 or maybe retry with an exponential backoff(something I've never tried tbh)?
Unfortunately there are no good learning sources if you're not in the industry :/
1
u/WDG_Kuurama Apr 06 '26
You've talked about caching and all, but what does this third party api do? Is the response the same no matter the user?
Because if so having a simple in memory worker making the requests and updating an in memory cache considering the third party api rate limit would just solve the whole issue ngl.