Reputation: 2269
I'm in the process of building a service on AWS that will run on several Lambda functions behind an API Gateway. The API Gateway will use a Lambda Authoriser to validate whether the API request can come through. I need a way to track the number of requests made based on some parameters of the request (two identifiers).
To do this I need to increment a count cheaply, efficiently and reliably against some key. What's an appropriate solution?
Options considered already
More specific details
I plan on making an API available and charging for X hundred requests per month for each client that is calling it. A user might have multiple clients - so Bob might have 10 clients with 400 requests per month for each of them. When one of the clients goes over 400 requests I would then block access until they added more credits.
Upvotes: 0
Views: 837
Reputation: 2269
Clearly I was failing to search for the right things earlier...
DynamoDB supports Atomic Counters which will increment a field without impacting any other attributes being updated.
Redis also looks like a good option to have higher speed and is probably cheaper for the use case as transaction volumes increase assuming the cluster stays quite small. The down side being the durability risks relating to Redis should the cluster go down.
Upvotes: 1