Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamodb Autoscaling not working fast enough

I'm running a simple api that gets an item from a dynamodb table on each call, I have auto scaling set to a minimum of 25 and a maximum of 10 000.

However if I send 15 000 requests with a tool like wrk or hey, I get about 1000 502s,

  • dynamodb's metrics show that reads are throttled
  • the scaling activities log on the table shows that the RCUs were scaled to 99 but not more than that
  • lambda logs show that the function starts to take longer, it usually takes about 20ms to run, but the function starts to run for 500.1500,3000 ms and start timing out (I'm assuming that's caused by the throttling)

Why isn't the autoscaling working better? It only scales upto 99RCUs but my max is 10, 000.

like image 721
Jonathan Avatar asked Nov 26 '17 13:11

Jonathan


People also ask

How fast is DynamoDB Autoscaling?

Provisioned Autoscaling Unlike on demand mode it operates on 1 minute average load and not peaks of 30 minutes time window — which means it both responds faster and does not does not overallocate as much.

How long does it take for DynamoDB to scale up?

DynamoDB auto scaling increases provisioned capacity when utilization exceeds 70 RCUs for at least two consecutive minutes. DynamoDB auto scaling decreases provisioned capacity when utilization is 20% or more below the target for 15 consecutive minutes (50 RCUs).

How can I tell if DynamoDB is throttling?

To find the most accessed and throttled items in your table, use the Amazon CloudWatch Contributor Insights. Amazon CloudWatch Contributor Insights is a diagnostic tool that provides a summarized view of your DynamoDB tables traffic trends and helps you identify the most frequently accessed partition keys.

Is DynamoDB automatically scalable?

If you use the AWS Management Console to create a table or a global secondary index, DynamoDB auto scaling is enabled by default. You can modify your auto scaling settings at any time. For more information, see Using the AWS Management Console with DynamoDB auto scaling.


2 Answers

We ran into the same problem when testing DynamoDB autoscaling for short amounts of time, and it turns out the problem is that the scaling events only happen after 5 minutes of elevated throughput (you can see this by inspecting the CloudWatch alarms the autoscaling sets up)

This excellent blog post helped us solve this by creating a Lambda that responds to the CloudWatch API events and improves the responsiveness of the alarms to one minute: https://hackernoon.com/the-problems-with-dynamodb-auto-scaling-and-how-it-might-be-improved-a92029c8c10b

like image 199
BenV Avatar answered Sep 20 '22 01:09

BenV


from: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.html

What you defined as "target utilization"?

Target utilization is the ratio of consumed capacity units to provisioned capacity units, expressed as a percentage. Application Auto Scaling uses its target tracking algorithm to ensure that the provisioned read capacity of ProductCatalog is adjusted as required so that utilization remains at or near 70 percent.

also, i think that the main reason that autoscale not works for you, is because your work might not stay elevated for a long time:

"DynamoDB auto scaling modifies provisioned throughput settings only when the actual workload stays elevated (or depressed) for a sustained period of several minutes"

DynamoDB auto scaling modifies provisioned throughput settings only when the actual workload stays elevated (or depressed) for a sustained period of several minutes. The Application Auto Scaling target tracking algorithm seeks to keep the target utilization at or near your chosen value over the long term. Sudden, short-duration spikes of activity are accommodated by the table's built-in burst capacity. For more information, see Use Burst Capacity Sparingly.

like image 32
Eyal Ch Avatar answered Sep 18 '22 01:09

Eyal Ch