I work on an application that communicates with multiple payment providers. Each provider has their own rate limit for us. We did not want to exhaust our rate limit with any of the payment providers, while also making the most of what limits we are allowed. We could afford to delay requests to the payment provider for a small amount of time, as bulk payments are processed offline as async jobs. Implementing a sliding log rate limiter with Redis and Golang
I work on an application that communicates with multiple payment providers. Each provider has their own rate limit for us. We did not want to exhaust our rate limit with any of the payment providers, while also making the most of what limits we are allowed. We could afford to delay requests to the payment provider for a small amount of time, as bulk payments are processed offline as async jobs.
During an average billing day, we run a large number of payments in a short span of time. Are we breaching our payment processors’ rate limits? Should we do something about that? I’ve heard about something called a rate limiter.
What is a rate limiter? A rate limiter caps the number of requests a sender can issue in a specific time window. It then blocks requests once the limit is reached.
Usually the rate limiter component is at the receiving system, but since we depend so heavily on third party processors, it also makes sense to accommodate the provider’s rate limit and control outbound requests so as to not get too many — or optimistically, even a single
We started designing the rate limiter with these requirements in mind:
Redis Lua scripting is the popularly recommended approach for handling transactions. Learn the common Lua Scripts error and how to handle for sentinel systems. Redis offers two mechanisms for handling transactions – MULTI/EXEC based transactions and Lua scripts evaluation. Redis Lua scripting is the recommended approach and is fairly popular in usage.
The world is moving towards a micro-service oriented Systems. It’s really important to prevent web services from attacks such as DOS(Denial of service). Rate limiting is generally put in place as a defensive measure for services. To protect services from excessive use whether intended or unintended. It also helps to ensure service availability to all the clients in a fair manner. Custom Rate Limiting in GoLang using Redis with Docker
Sometime ago for a project, I was looking for a good rate-limiting service. For the scope of that project, the service would run along a front proxy and would rate-limit requests to third party applications.
Golang Testing — Mocking Redis. I recently discovered how to mock Redis in my testing environments with little friction. When testing our applications we often have a lot of external dependencies, such as Redis. When testing we should try to mock this.
Golang Web Development is the new trend globally. Get all the details about the Golang development here. Hire Golang Developers.