Analyzing DynamoDB metric on CloudWatch
It is very important to keep an eye on DynamoDB CloudWatch metrics in order to see the DynamoDB performance. CloudWatch provides real-time monitoring and alerting mechanisms to services provided by DynamoDB.
Getting ready
To get a better understanding of DynamoDB metrics, considering the fact that we don't have much of our data in our product table, go to the Query and Scan operations console and perform various Query and Scan operations back to back in order to get some metrics. Simply clicking on the Query and Scan buttons with some sample conditions will do the job for you.
Of course, in real time, in production systems, you would not need to do this as we will automatically have sufficient reads, writes, queries, and scans in progress.
How to do it…
Let's understand DynamoDB metrics on Cloudwatch:
- Go to the DynamoDB console, and click on the table whose metrics you would like to analyze. You will notice that the bottom frame will start showing some details about the table. It will have various tabs, such as Details, which will have the table details, Indexes, which will have details about the secondary indexes that we created in our table, Monitoring, which will have the details about the CloudWatch metrics that we would like to see in detail, and the last tab, Alarm Setup, which is used to set up various alarms in case you wish to get any:
- If you scroll down a bit, you will see various graphs, such as Read Capacity, Throttled Read Requests, Write Capacity, Throttled Write Requests, Read-Write Capacity for Global Secondary Indexes, that we created. It will also show you graphs related to Read/Write Latency and Query/Scan latency for a given time frame:
- You can also click on individual graphs to see the enlarged view. I have made a significant number of scans in the last hour; if I want to see how DynamoDB performed for a particular time frame, I need to click on the Scan Latency graph, which will open the enlarged view of the graph, as shown in the following screenshot:
The preceding graph tells us the average time taken by DynamoDB in milliseconds to perform the various scan operations.
- You can also change the Statistic drop-down value to select the various metrics. For example, if I want to see the exact time taken by each scan request over the last hour, it will show you the results immediately. I can also click on the data points on the graph to see the exact time. Here is an example of it:
Here, the graph tells us that the very first scan request took approximately 140 milliseconds to fetch the results, whereas the latency dropped in subsequent requests, and eventually, improved the performance.
How it works…
Almost every operation in Cloud is measured in terms of bytes read/written. CloudWatch keeps track of the requests that we make to DynamoDB and stores it in the internal data store. While generating the graphs, we will use these data points, which will help us analyze the performance.
There's more…
You can also analyze other CloudWatch metrics to better understand the DynamoDB behavior. These graphs will also help you decide upon the throughput values set for the tables and secondary indexes. If you see the consumed read/write capacity reaching the provisioned read/write capacity, then you can increase the provisioned throughput and vice versa.
Always look for consistent metrics; you might miss out on certain spikes because a lot of graphs give you an average of values over the last 5 minutes of time. For more detailed metrics, you can go to the CloudWatch console and look out for DynamoDB metrics at https://console.aws.amazon.com/cloudwatch/https://console.aws.amazon.com/cloudwatch/.