aws-appsync-community icon indicating copy to clipboard operation
aws-appsync-community copied to clipboard

DynamoDB Resolvers cannot know how many RCU/WCU an operation has consumed

Open cespin opened this issue 3 years ago • 2 comments

The DynamoDB APIs accept the parameter "ReturnConsumedCapacity". When passed the result includes the consumed capacity units of the executed operation.

With that it is possible to associate "a cost" with a specific access pattern. This is ideal when trying to figure out what needs to be optimized in order to reduce the WCU/RCU.

When hitting DynamoDB directly from a Lambda function I always pass this parameter and then attach the result to an embedded CloudWatch metric. This is a recommendation comming directly from Rick Houlihan during one of his Re:Invent sessions.

A cannot do this with AppSync currently. There is not way to pass the "ReturnConsumedCapacity" to DynamoDB.

If it were possible to pass this parameter I would rely in a pipeline resolver in order to execute the DynamoDB operation and then notify to something else what the consumed units of the operation were.

cespin avatar May 21 '21 02:05 cespin

Thinking about this a bit more, it would be ideal if AppSync pushed a metric to CloudWatch about the WCU/RCU consumed by each resolver by default.

cespin avatar Jun 18 '21 02:06 cespin

I found a way to do this my self at the cost of some compute time.

If DynamoDB is hit using an HTTP function resolver instead of the native AppSync one (see here) then the WCU/RCU may be requested and logged in a subsequent function in a pipeline resolver

cespin avatar Nov 18 '21 16:11 cespin