DynamoDB Accelerator
(DAX)
Glen Arrowsmith Nov 2017 AWS Brisbane Meetup
twitter.com/garrows slides.com/glenarrowsmith/dax
What is it?
"Fully managed, in-memory cache for DynamoDB.
Reduces DynamoDB response times from milliseconds to microseconds."
-AWS Marketing Team
Obvious use case:
Already caching with memcache/etc
Unify your source of truth
Less management
Less code
"DynamoDB is fast enough already. I won't bother with DAX."
-You
How to
break
DynamoDB
Method 1
Scale up too fast
AKA, the slashdot effect
or the whatever kids use these days effect
Autoscaling
Autoscaling
Autoscaling
DAX could help you...
...maybe
Method 2
Hash hotspot
How DynamoDB Scales
🔥
Dynamo is sharded so inconistent reads mitigates the problem to an extent.
Getting started with DAX
Job done!
Nothing happened
"Using DAX is easy and requires no modification to your application logic, since DAX is compatible with existing DynamoDB API calls.
Â
DAX can be enabled with just a few clicks in the AWS Management Console or using the AWS SDK."
-AWS Marketing Team
const AmazonDaxClient = require('amazon-dax-client');
// Replace this ...
var ddb = new AWS.DynamoDB({region: region});
/// with this ...
var dax = new AmazonDaxClient({endpoints: [endpoint], region: region});
// If using AWS.DynamoDB.DocumentClient ...
var doc = new AWS.DynamoDB.DocumentClient({service: dax});
npm install --save amazon-dax-client
Give it a whirl
🤞
The DAX endpoint is in the VPC.
Error: NoRouteException: No endpoints available
Localhost: Use a VPN
Server: Move your servers to the VPC
With Dax 2.7ms
555% performance increase
40,000 Records
50 read/write capacity units/second
Read 10,000 unique records 4 times
T2.Micro
Without Dax 15ms
Read 1 item 10,000 times
0.98ms
1530%
How to waste your time with DAX
Write Heavy
It's got to go back to dynamo anyway
Effectively does nothing
Consistent Reads
It's got to go back to dynamo anyway
Uses read capacity
Small table?
Just use memoize
var memoize = require('memoizee');
getDynamoItemFast = memoize(
getDynamoItemById,
{
async: true,
maxAge: 10000,
preFetch: true
}
);
getDynamoItemFast(customerId, function(err, res) {
//Do stuff.
});
Where DAX really shines
- Data doesn't update often
- Large amount of data (greater than app server's RAM)
- Lambda (since you're paying for RAM per run)
- Non-shared memory languages (eg PHP)
Availablility
- North Virginia
- Oregon
- Northern California
- Ireland
- Tokyo
- Java
- JavaScript
Glen Arrowsmith Nov 2017 AWS Brisbane Meetup
twitter.com/garrows slides.com/glenarrowsmith/dax
Node.JS Full Stack Developer
Questions?
DynamoDB Accelerator (DAX)
By Glen Arrowsmith
DynamoDB Accelerator (DAX)
- 2,651