How to auto scale Amazon DynamoDB throughput?
How to auto scale Amazon DynamoDB throughput?
Amazon DynamoDB doesn?t provide inbuild capabilities to auto tune throughput based on Dynamic Load. It provide API to increase or Decrease throughput. Customers are being charges hourly basis for provisioned read & write throughput.
What are the different ways to alter throughput of dynamodb and achieve cost saving benefits ?
Answer by Chris for How to auto scale Amazon DynamoDB throughput?
You can manage throughput programmatically through the updateTable API or manually through the console.
There's also tools like Dynamic DynamoDB, though you could roll your own version as well: you'd use the updateTable API and have some background process running to detect those circumstances and call updateTable as necessary.
Some things to watch out for when changing the scale of DynamoDB:
- You get billed for allocated throughput, whether you're actually using it or not.
- Wen you scale up, Dynamo may allocate new partitions for you - but it won't remove them when it scales down. This can result in unexpected hot hash key problem where you have a lot of partitions but very low throughput on each of them.
Answer by johnz for How to auto scale Amazon DynamoDB throughput?
The answer from Chris is an accurate answer. Just to add a few points from prior experience using DynamoDB ?
The situation with DynamoDB is different from EC2. The elastic compute service has an API supported directly as a web service by Amazon to allow you to program how to scale up or down according some logic such as how much demand exists. You program this by defining a monitoring threshold and automatically triggering creation or deletion of instances in a group.
Data servers do not work in the same way with triggers to adjust their capacity. But the capacity of DynamoDB is very flexible and may be controlled as Chris has pointed out. The API to provide this is good enough to make one off changes. Or equivalent manual changes from the console.
The different language bindings to program create and update actions with DynamoDB is here ?
http://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html
The important operation to modify capacity is here ?
http://docs.aws.amazon.com/cli/latest/reference/dynamodb/update-table.html
So this gives you the ability to make an increase or decrease in the ReadCapacityUnits or WriteCapacityUnits of ProvisionedThroughput.
Which is fine for a predicted or one-off change. But that is not the same thing as a flexibility tool to allow you to trigger the change automatically.
Programmatically, what you are most likely to want to do is to adjust capacity in response to change in utilization in the preceding time interval. In particular you may need to scale up rapidly in response to a surge in demand by defining an appropriate time slot and a lower and upper threshold to trigger.
A more complete solution to achieve this is described here ?
https://aws.amazon.com/blogs/aws/auto-scale-dynamodb-with-dynamic-dynamodb/
The solution is maintained by Sebastian Dahlgren and may be found with all instructions at ?
https://github.com/sebdah/dynamic-dynamodb
I see that the current release is 1.18.5 which is more recent than when I last used it.
Judging from earlier releases it is simple to configure by means of a dynamodb.conf properties style file ?
Having provided credentials and region, the most crucial settings are
- check-interval ? to test throughput in seconds
- min-provisioned-reads, max-provisioned-reads; reads-upper-threshold, reads-lower-threshold; increase-reads-with, decrease-reads-with ? These are all percentages
- min-provisioned-writes, max-provisioned-writes; writes-upper-threshold, writes-lower-threshold; increase-writes-with, decrease-writes-with ? These are all percentages
Is this information up to date?
Well if you look at http://aws.amazon.com/new/ you will see just one additional recent change affecting DynamoDB which affects the documents stored. The entry for Dynamic DynamoDB is the last published entry dealing with scaling actions. So this is the best maintained DynamoDB automatic scaling capability at this time.
Answer by kartik for How to auto scale Amazon DynamoDB throughput?
Guidelines for DynamoDB Auto Scaling Script :
Customers are being charged on hourly basis for provisioned read & write throughput. Below is Amazon Dynamo DB Pricing for EU (Ireland Region).
? Write Throughput: $0.00735 per hour for every 10 units of Write Capacity ? Read Throughput: $0.00735 per hour for every 50 units of Read Capacity
Amazon Dynamo DB doesn?t provide in-build capabilities to auto tune throughput based on Dynamic Load. It provides API to increase or Decrease throughput with some restrictions like throughput can be decreased twice in a day and increased any time in a day.
What will be the monthly bill of a Production Table for fixed read capacity 2,000 read/second and 2,000 write/second for 24 hours?
Calculation: $0.00735 X 24hrs X 200 X 30days {write cost for month} + $0.00735X 24hrs X 40 X 30 days {read cost for month} = 1058.4+ 211.68 = Fixed 1270 $/month.
Guidelines for writing utility {amazon supported programming languages} which adjust throughput of table and
(A) Initial Value: Basically, here you have to watch and decide read & write throughput for table as an initialization value after analyzing average usage considering 15 days or 1 month load and add X% extra for read and Y% extra for write on the top to withstand unexpected load. Initial read/write throughput = calculate read throughput based on average usage +X {read} % or Y {write} % X & Y can be anything between 10% and 30% based on observation.
(B) Peak Load Shaping: Alert on tables can be set as when load reaches to 50% to 60 % of provisioned throughput, necessary action can be taken like calling throughput increment API to increase throughput anything between 30 % to 50% of provision throughput.*
(C) Manual Shaping: For known heavy load like batch load/festival season, throughput should be set manually to 200% - 300% extra of normal daily operations until load is complete* * Once business working hours or load is over. Throughput should reduce down to initial value.
Note: Reader can calculate monthly saving considering 1,000 read/write for 16 hrs. + 2,000 read/write for 8 hours, provided utility in place.
Answer by quodlibet for How to auto scale Amazon DynamoDB throughput?
Now that AWS has announced scheduled execution of lambda services, these seem a great fit to do time-based auto scaling. I wrote up an example of how to use this on medium. Example code is on github.
Answer by Robert Mao for How to auto scale Amazon DynamoDB throughput?
Jeff Bar recently wrote a blog in AWS official blog: "Auto Scale DynamoDB With Dynamic DynamoDB":
https://aws.amazon.com/blogs/aws/auto-scale-dynamodb-with-dynamic-dynamodb/
He introduced Dynamic DynamoDB, an open source tool built by independent developer to handle this automatically with CloudFormation template.
Answer by Buchi for How to auto scale Amazon DynamoDB throughput?
I think other answers have done a great job but I have a different approach to autoscale DynamoDB in an event driven fashion by leveraging CloudWatch alarms and DynamoDB's UpdateTable operation to change provisioned capacity. The following approach not only helps to reduce costs, but to scale up capacity for unexpected loads.
Summary:
Configure CloudWatch alarms on DynamoDB metrics to alert you based on thresholds and push the alerts to an SQS queue via SNS topic. A daemon process which polls SQS queue can process those alerts and change table provisioned capacity using DynamoDB's UpdateTable
operation and update CloudWatch alarm thresholds.
Detailed version:
Please be advised that this approach would require 1. Understanding of AWS services like CloudWatch, SNS, SQS 2. Good amount of time for implementing in your favorite programming language 3. Maintaining a daemon to process SQS messages and change the provisioned capacity.
One time setup:
- Create CloudWatch alarms on
ConsumedWriteCapacityUnits
andConsumedReadCapacityUnits
metrics of your DynamoDB table. You can use this documentation. - Configure the CloudWatch alarms to alert a SNS topic. Create an AWS SQS queue and subscribe the queue to receive alerts from SNS topic.
- Write a daemon in any programming language to poll SQS queue and process all alerts. AWS has SDKs in multiple languages so choosing any of those languages would avoid writing lot of code to communicate with AWS services.
Daemon algorithm:
- For every SQS message it receives, calculate the new provisioned capacity to be used and issue an
UpdateTable
operation with the new value. - Update the CloudWatch alarm with the new thresholds, if required.
You can use above approach to either scale up or down. For example, maintain CloudWatch alarm threshold at 80% of ProvisionedWriteCapacityUnits
and every time the usage crosses 80%, increase the capacity and set alarm threshold to 80% of new value. Similarly you can scale down when the consumption falls below x%.
Though this is the crux, there would be lot of points to be considered in a production quality solution.
- Understand about DynamoDB partitions and hot key problems.
- Be aware of all DynamoDB limits.
- Constraints on no.of scale downs per UTC day.
- Batching the multiple
UpdateTable
operations.
Finally, Neptune.io provides a packaged SaaS solution to autoscale DynamoDB by using this architecture. See http://blog.neptune.io/one-click-autoscaling-of-dynamodb/ and http://blog.neptune.io/dos-and-donts-of-dynamodb-autoscaling/ for some reading on that.
P.S: I work for Neptune. And, I can help you if you need more details of implementation.
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
Good explanation,thanks for writing,it is useful for so many developers
ReplyDeleteAWS Online Training