Good news for everyone who have been over provisioning DynamomDB!
I published a plugin to remove all the overhead from the Auto Scaling configuration:
Nice add @sbstjn
Works great with one table.
Trying to use it with multiple tables, CloudFormation fails creating the CloudWatch alarms with the following Error:
An error occurred while provisioning your stack: TableReadScalingPolicymytable - Unable to create alarms for scaling policy TableReadScalingPolicymytable due to reason: Rate exceeded (Service: AmazonCloudWatch; Status Code: 400; Error Code: Throttling; Request ID: abababab-abab-abab-abab-abababababab).
Is there any way you can include DependsOn clauses in the CloudFormation template where each alarm depends on the previous alarm to override the default parallelism of CF attempting to create the CW alarms?
Just a thought.
But great work. Thanks!
thanks for trying out the plugin!
How many tables do you try to update? I just created five tables with Auto Scaling and everything works fine. Can you provide an example
serverless.yml so I can reproduce this?
It appears to work fine with one, but fails with any more than one.
Here is a gist of a simplified serverless project.
If you comment out tables 2-5 in the autoscale.yml it will deploy fine, but fail if you have more than 1 uncommented.
Hope it helps.
Thanks for the configuration files. I created a GitHub issue for this. Hopefully, I can find a solution for this soon.
I just released
v0.2.0 which should prevent this. But there is a breaking change in the configuration API. Would be awesome if you can try the new version and check if your configuration still fails.
Just gave it a go with the sample config I shared with you the other day and it all went smoothly.
Going to update the stack I’m working on at “DayJob01” and see how that goes…
Looks like I spoke too soon.
Worked well when creating the stack fresh. ie. Included the building of the Tables.
But Updating a stack to Add Autoscaling to a stack that already had the Tables created is falling over.
Here’s the error message from sls deploy:
An error occurred while provisioning your stack: TableReadScalingPolicyMyTable3 - Unable to create alarms for scaling policy TableReadScalingPolicyMyTable3 due to reason: Rate exceeded (Service: Amazon CloudWatch; Status Code: 400; Error Code: Throttling; Request ID: b5e3013a-6e33-11e7-9a26-596460447a11).
Getting a strange intermittent error:
Not sure if it’s in your code or in CF’s implementation of the scaling functionality.
An error occurred while provisioning your stack: AutoScalingTargetReadMyTable3 - Validation failed for resource: table/dev-table3, scalable dimension: dynamodb:table:ReadCapacityUnits. Reason: The security token included in the request is invalid..
And it’s random as to what element it fails on… Can be any of the 5 tables, and either Read or Write. and sometimes it actually succeeds.
Having another issue with trying to deploy to different stages as well. But still trying to nail down precisely where it’s happening. Will add that when I nail it down.
Based on the AWS docs I think the expired token is a general problem , but not directly related to the plugin. Maybe the CloudFormation deploy process takes too long, so a temporary token may expire?
I added more values to the
DependsOn list in an open Pull Request. Hopefully this will prevent the
Rate exceeded errors. Feel free to check out the branch or wait until a next release
Regarding the API rate error: I think you should request an inrease of the CloudWatch rate limit: http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html
The other issue I was trying to pin down.
Seems that the Role the plugin creates, ‘DynamoDBAutoscaleRole-< table>’ isn’t stage specific. so when trying to deploy to another stage, it burps trying to create a Role that already exists.
True. I will add the stage to the namings …
I installed the plugin and configured. When I deploy I do not get any errors but the auto scaling properties of the tables do not change. I am trying to set auto scaling for two tables and there are no indexes. Any ideas?
Did you include the following in your serverless.yml?:
plugins: - serverless-dynamodb-autoscaling
I only ask because I ran into this at first as well.
Hope it helps.
An error occurred: irhbackendTableScalingPolicyReadSponsorshipsDbThorndikeUseast1 - Unable to create alarms for scaling policy irhbackendTableScalingPolicyReadSponsorshipsDbThorndikeUseast1 due to reason: Rate exceeded (Service: AmazonCloudWatch; Status Code: 400; Error Code: Throttling; Request ID: dad4cc23-d376-11e7-842b-a3d7d952d5ce).
Looks like the dependencies you currently have are all logical dependencies … I think you need illogical dependencies, i.e. dependencies to the other scaling policies and scaleable targets being created simultaneously, because those are the ones that add up to the rate limit.
When executing sls package I have this error:
Serverless plugin “serverless-dynamodb-autoscaling” initialization errored: Unexpected token …
It is strange because the only things I did was
$ npm install serverless-dynamodb-autoscaling
├── firstname.lastname@example.org (email@example.com, firstname.lastname@example.org, email@example.com)
to the serverless.yml file.
Adding this configuration doesn’t solve the problem:
- table: applicationsTable # DynamoDB Resource
index: # List or single index name
minimum: 1 # Minimum read capacity
maximum: 5 # Maximum read capacity
usage: 0.75 # Targeted usage percentage
minimum: 1 # Minimum write capacity
maximum: 5 # Maximum write capacity
usage: 0.5 # Targeted usage percentage
Do you have any idea what might cause this error?