DynamoDB Applied Design Patterns
Table of Contents
DynamoDB Applied Design Patterns
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Data Modeling with DynamoDB
Data model
Efficient use of primary keys
Basics of indexes
Default or primary indexes
Secondary indexes
DynamoDB data types
Summary
2. DynamoDB Interfaces
The management console
Managing the DynamoDB table
Managing DynamoDB table items
The Eclipse plugin
The command-line interface
Summary
3. Tools and Libraries of AWS DynamoDB
Creating your first SDK project
Java SDK operations
DynamoDB Local
Summary
4. Working with Secondary Indexes
Secondary indexes
Projection
Local secondary index
Global secondary index
Item sharding
Ideal item writing
Best practices with secondary indexes
Distributing the load by choosing the correct key
Making use of the sparse index
Using the global secondary index for quicker retrieval
Creating a read replica
Using indexes sparingly
Choosing projections carefully
Optimizing frequent queries to avoid fetches
Watching for expanding item collections
Summary
5. Query and Scan Operations in DynamoDB
Querying tables
Consistency
Exclusive start key
Scanning tables
Parallel scanning
Summary
6. Working with the DynamoDB API
Data format
HTTP requests
Request header
Request body
Response header
Error handling
Client-side error with status code 400 - retry not needed
AccessDeniedException
ConditionalCheckFailedException
IncompleteSignatureException
LimitExceededException
MissingAuthenticationTokenException
ResourceInUseException
ResourceNotFoundException
ValidationException
Client-side error with status code 400 - retry possible
ProvisionedThroughputExceededException
ItemCollectionSizeLimitExceededException
ThrottlingException
UnrecognizedClientException
Client-side error with status code 413
Server-side error with status code 500
InternalFailure and InternalServerError
ServiceUnavailableException
Error retry and exponential back off
Operations in DynamoDB
CreateTable
PutItem
UpdateItem
GetItem
Query
Scan
DeleteItem
DescribeTable
UpdateTable
DeleteTable
ListTables
BatchGetItem
BatchWriteItem
Summary
7. Distributed Locking with DynamoDB
Distributed locking
Solutions available to solve distributed writes
Java high-level API
Optimistic locking
Importance of distributed locking
Summary
8. DynamoDB with Redshift, Data Pipeline, and MapReduce
Loading data from DynamoDB into Redshift
Importing and exporting data between DynamoDB and S3
Creating Data Pipeline
Exporting, importing, querying, and joining tables using AWS MapReduce
Exporting data from DynamoDB to S3
Exporting the DynamoDB table to HDFS
Importing data to DynamoDB
Querying data in DynamoDB
Joining two DynamoDB tables
Summary
9. DynamoDB – Best Practices
DynamoDB use cases
Schema-less-ISH
Batch applications
Stating attributes using the :select option
Synchronization
Real-time problem statements and their solutions
Problem statement – 1
Solution
Problem statement – 2
Solution
Problem statement – 3
Solution
Problem Statement – 4
Solution
Problem statement – 5
Solution
AWS DynamoDB on mobile
Storing data in the table
Android
iOS
Updating a record
Android
iOS
Deleting a record
Android
iOS
Uniform workload
Time series tables
When to use and when not to use DynamoDB
Summary
A. Comparing DynamoDB
DynamoDB versus MongoDB
DynamoDB versus Cassandra
DynamoDB versus S3
DynamoDB versus Redis
Index
DynamoDB Applied Design Patterns
Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2014
Production reference: 1160914
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78355-189-7
www.packtpub.com
Authors
Uchit Vyas
Prabhakaran Kuppusamy
Reviewers
Hrijul Parekh
Akshay Surve
Riddhi Thaker
Commissioning Editor
Pramila Balan
Acquisition Editor
Nikhil Karkal
Content Development Editor
Adrian Raposo
Technical Editor
Veronica Fernandes
Copy Editors
Roshni Banerjee
Sarang Chari
Project Coordinator
Sanchita Mandal
Proofreaders
Sam Birch
Paul Hindle
Indexer
Rekha Nair
Graphics
Disha Haria
Abhinash Sahu
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
Uchit Vyas is an open source specialist and a hands-on Lead DevOps of Clogeny Technologies. He is responsible for the delivery of solutions, services, and product development. He explores new open source technologies and defines architecture, roadmaps, and best practices for enterprises. He has consulted and provi...