Hi, I am adding spring cloud gateway as a gateway application for my system. There are features that I need to include in this gateway and throttling ( rate-limiting ) is one of them. Currently, the spring cloud gateway provides default Redis-reactive implementation (https://cloud.spring.io/spring-cloud-static/spring-cloud-gateway/2.0.2.RELEASE/single/spring-cloud-gateway.html#_redis_ratelimiter) for throttling which uses LUA script in the Redis server.
I am already using aerospike for storing data in one of my products and want to use aerospike as a rate-limiter (throttling) for APIs.
Requirement:
An API call comes to the gateway server. Gateway server invokes aerospike to get the counter against a key (this key can be a String like user-id). Aerospike returns the counter after incrementing it by one. This counter is cleared every minute/hour.
A user is allowed to make a request say 1000 times to the gateway application and once this limit exceeded gateway will send back the ‘Too Many Requests’ error. After one minute this counter is reset to 0. The user can start making a request since the counter is reset for that minute.