What are Best Practices for Using Amazon DynamoDB?

Carvia Tech | July 26, 2018 | 2 min read | 45 views | Amazon DynamoDB


Best Practices

  1. Amazon DynamoDB is good fit for NoSql kind of data, if you have lot of relationships between different entities, then better off using MySql or RDBMS.

  2. Do not use transactions that span across tables in Amazon DynamoDB, if there is any such strong need, then better use a RDBMS. You can achieve some sort of eventual consistency can be achieved in DynamoDB using SQS.

  3. Correctly model your domain objects using Hash Key, Range Key, Local Secondary Index and Global Secondary Indexes.

  4. Use Auto Scaling option of Amazon DynamoDB to dynamically increase provisioned throughput as the need arises.

  5. Use atomic update operations to update shared records from multiple threads, this will save some cost and resources.

  6. For handling spike in write operations, user some kind of Queue (either Amazon SQS or Redis), this will not only bring resiliency to the system but also reduce the cost.

  7. Use Spring Retry to handle write failures. Spring retry gives flexibility of exponential backoff, which could be quite helpful under heavy load conditions.

How not to use DynamoDB

  1. Amazon DynamoDB is not a single fit for all your database needs. Use it only when you can afford the budget and requirements fit into NoSql world.

  2. If your application has strong transcational needs as well as NoSql needs, better to use RDBMS for transactional work and NoSql for everything else. In microservices architecture, for example, you can partition the application into multiple microservices and then each microservice can pick either NoSql or RDBMS as per its business requirement.

  3. Do not model data into dynamoDB from object relational mindset as we do it in RDBMS. Denormalizing data is the key concept in NoSql world. For example, if you want to store Tags with an Article, put them all into one object, one table rather than creating separate table for Article and Tags.


Top articles in this category:
  1. How to implement Atomic Counters in DynamoDB for high throughput
  2. Scan all records of a Amazon DynamoDB table using a Java Code
  3. Amazon DynamoDB Java Interview Questions
  4. How will you ensure that no two threads update the same db record in parallel in amazon DynamoDB
  5. How to automatically Retry DynamoDB Write on ProvisionedThroughputExceededException
  6. What is Eventual Consistency in DynamoDB?
  7. What are Conditional Writes in AWS DynamoDB


Find more on this topic:
NoSQL image
NoSQL

No SQL design and development - Amazon DynamoDB, MongoDB, MySQL document DB.

Last updated 1 week ago


Recommended books for interview preparation:

This website uses cookies to ensure you get the best experience on our website. more info