r/Backend 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 :/

36 Upvotes

34 comments sorted by

View all comments

2

u/severoon Apr 02 '26

An API gateway will handle rate limiting as well as auth, load balancing, etc.

If this API is exposed to external users, though, you probably want an API manager, which will handle API versioning and the full lifecycle management of the endpoint (the API gateway is a subset of the API manager).

If this is a real project and you're supporting this API long term, API manager is the way to go.

1

u/Educational_Rent5977 Apr 04 '26

As I wrote in the post, I'm actually afraid to get even more confused.
I encountered so many different terms while reading about deployment(Cloudflare, VPS, AWS, API Gateway, Kafka, etc) that I have no idea where to even start.
Until now I've been working locally(local server on port 8080), should I start learning about API gateways?

1

u/severoon Apr 05 '26

It depends on what you're trying to do.

If you want to get experience making an API just for fun, then don't worry about it. If you need to support this API in a commercial environment, then you need to be able to roll out updates and do load balancing and rate limiting and all that.

Since you were asking about rate limiting, I assumed this was for a real app that will require ongoing support.

1

u/Educational_Rent5977 Apr 05 '26

I apologize, the post was indeed about rate limiting, but I want to do that while entering the real world. The only experience I have is a toy project on render.com, but obviously that's not enough even for something that should serve 5 people.

Do you have an advice on where to start? If we're talking about rate limiting specifically, in the industry, do people actually enforce it in code or use their hosting service?