awslabs / dynamodb-streams-kinesis-adapter

The Amazon DynamoDB Streams Adapter implements the Amazon Kinesis interface so that your application can use KCL to consume and process data from a DynamoDB stream.
Apache License 2.0
97 stars 37 forks source link

What is the cost for using DynamoDB Stream Kinesis Adapter + Kinesis Client Library to read DDB Stream #47

Open RuiZhang2 opened 2 years ago

RuiZhang2 commented 2 years ago

Quote from DDB Pricing for On-Demand Capacity: DynamoDB charges for reading data from DynamoDB Streams in read request units. Each GetRecords API call is billed as a streams read request unit and returns up to 1 MB of data from DynamoDB Streams. Streams read request units are unique from read requests on your DynamoDB table. You are not charged for GetRecords API calls invoked by AWS Lambda as part of DynamoDB triggers. You also are not charged for GetRecords API calls invoked by DynamoDB global tables.

It seems like 1 GetRecords API = 1 read request unit. Since after switching to adapter and KCL library, there is no GetRecords API call at all. How can we know the number of read units we make? Can you share more details how to calculate the cost on README?

pingleig commented 2 years ago

The adapter still call GetRecords under the hood (see code snippet at the end). There is CloudWatch metrics on GetRecords calls, in console you can find it by click table name and the monitoring tab.

If you want to avoid calling GetRecord you should use https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/kds.html in this case, you will use KCL directly without this adapter because you are calling Kinesis API directly. Changes in DynamoDB table are sent to Kinesis by DynamoDB service, though the order guarantee in DDB stream is not preserved in Kinesis stream and the cost model is different.

https://github.com/awslabs/dynamodb-streams-kinesis-adapter/blob/528d2be70825b1d9ebecb5b048e73c30280ac5fa/src/main/java/com/amazonaws/services/dynamodbv2/streamsadapter/AmazonDynamoDBStreamsAdapterClient.java#L436-L467

amdhing commented 2 years ago

The adapter makes GetRecords calls. You can identify the number of GetRecords calls made by your consumer applications towards a DynamoDB Stream by checking the SampleCount statistic for SuccessfulRequestLatency CloudWatch metric associated for the DynamoDB Stream.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/metrics-dimensions.html#SuccessfulRequestLatency

It may not be possible to identify calls made on a per consumer application level in-case multiple distinct consumer applications are consuming from the same stream.