Serverless pattern for a throttled consumer

0

I have an API that uses a leaky bucket algo for token restoration.

What's a good serverless pattern for being able to consume the API in the most efficient way, while maximizing the use of allocated tokens?

Ideally, I want to have an SQS that we can then process in a throttled way.

Currently, we just execute Lambda on schedule and read from the queue, but this results in unnecessary executions when the queue is empty.

Thanks.

1개 답변
0

If I understand correctly what you are asking, maybe you can store the amount of bucket tokens in a DynamoDB table and use DynamoDB Streams to invoke a Lambda every time it changes.

profile pictureAWS
전문가
Uri
답변함 2년 전
  • It's the same number of tokens every minute. Once we exhaust the tokens, we cannot process the jobs anymore, and need to wait until the minute runs out. Then try again. So we have to execute the Lambda once a minute. But then 15 days of the month, we have no jobs, because the batch is a monthly job, and it takes 14 days to complete. So then for the other half of the month, we keep executing Lambda which isn't doing anything. Just checks the queue and exits.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠