amazon-dynamodb

Topics related to amazon-dynamodb:

Getting started with amazon-dynamodb

This section provides an overview of what amazon-dynamodb is, and why a developer might want to use it.

It should also mention any large subjects within amazon-dynamodb, and link out to the related topics. Since the Documentation for amazon-dynamodb is new, you may need to create initial versions of those related topics.

Using AWS DynamoDb with the AWS .NET SDK

Amazon DynamoDB is a fast NoSQL database service offered by Amazon Web Services (AWS). DynamoDB can be invoked from .NET applications by using the AWS SDK for .NET. The SDK provides three different models for communicating with DynamoDB. This topic is introduces the various APIs in each model.

The Models

The SDK provides three ways of communicating with DynamoDB. Each one offers tradeoffs between control and ease of use. See the AWS .NET SDK Reference for details on the APIs below.

  • Low-level: Amazon.DynamoDBv2 namespace — This is a thin wrapper over the DynamoDB service calls. It matches all the service features. You can reference the service documentation to learn more about each individual operation.

  • Document Model: Amazon.DynamoDBv2.DocumentModel namespace — This is a model that provides a simpler interface for dealing with data. DynamoDB tables are represented by Table objects, while individual rows of data are represented by Document objects. Conversion of .NET objects to DynamoDB data is automatic for basic types.

  • Object Persistence Model: Amazon.DynamoDBv2.DataModel namespace — This set of APIs allow you to store and load .NET objects in DynamoDB. Objects must be marked up to configure the target table and the hash/range keys. DynamoDBContext acts on marked up objects. It is used to store and load DynamoDB data, or to retrieve .NET objects from a query or scan operation. Basic data types are automatically converted to DynamoDB data and converters allow arbitrary types to be stored in DynamoDB.

The three models provide different approaches to working with the service. While the low-level approach requires more client-side code — the user must convert .NET types such as numbers and dates to DynamoDB-supported strings — it provides access to all service features. By comparison, the Object Persistence Model approach makes it easier to use the service—since the user is for the most part working with familiar .NET objects—but does not provide all the functionality. For example, it is not possible to make conditional Put calls with the Object Persistence Model.

Learn more about working AWS using the .NET SDK in the .NET SDK Developer Guide.

Note: This topic was adapted with permission from a blog post originally published on the AWS .NET SDK blog.

How to insert data into table using DynamoDb?

How to create a DynamoDB Table

Batch Operations: Things to know

Good to know about Batch operations

  1. Batch operation doesn't minimize the HTTP request count, rather it has more features to handle when we receive a throttling error. To put it simple, each record that we insert into dynamo db will consume one http request.
  2. Sound implementation of batch operation is to first to cache data temporarily and once we have the threshold number, ie 25, is the correct time to fire a batch request.
  3. Any request that fails due to throttling will be retried between(500-999 ) milliseconds, as recommended by Amazon best practices.

Dynamodb delete data over time

My use case: removing old data from dynamodb using a date attribute.

Important things to know:

  • You can't query a table with using only range key attribute (date for example).
  • You can only query a table using hash or hash+range key.
  • You can't query a table using a hash key with '<' / '>' operations, only '='.

Possible Solutions:

  • Scanning the whole table - this could be very costly
  • My chosen solution - Defining an index with range key for the date and with a hash key that would be pretty decent such as the day of year.

Eventually batch delete the result set.

Notes: Building the entity I was using the amazon dynamo annotations. I was using DynamoDBQueryExpression to query, getting the result page with the defined Class object.