Reputation: 171
I'm looking to services or solutions for distributed rate limiter for an application I'm building. These applications are concurrent AWS lambda functions. The downstream API has a rate limit of 1000 transactions/min. This rate is shared among multiple applications. For my application, how would I go about developing a solution for this?
Upvotes: 8
Views: 4698
Reputation: 10175
I think that this is baseline architecture challenge more than a Lambda problem. However, I would recommend separating the code that handles the HTTP transaction from the code that sends the HTTP transactions to the downstream source through the use of an SQS queue or event bridge.
You can then implement a background service (Could be a lambda, Could be a Container) that will consume messages from the queue / event bridge to control the traffic flow and make sure that only 1000 requests per second are being pushed to the downstream source. Not a great engineering resort but it should help you in the short term.
Obviously, at some point you have to either scale the downstream service or migrate it to the cloud to ease the scaling and take advantage of the on-demand scaling features.
One more thing that you could look into is "Would it be better if the downstream source can pull data from me instead of me pushing data to them". This will allow you guys to preserve and guard the payloads from errors and let the downstream systems consume the messages at their own pace.
Upvotes: 0