Skip to main content

High performance, thread safe traversing tool for AWS DynamoDB

Project description

dynamodb-traverse

High performance, thread safe, hackable, general purpose traversing tool for AWS DynamoDB based on aioboto3.

Build Status Build Status

Why manually traverse dynamodb table?

There're tens of ways to consume dynamodb data, for example, dynamodb stream, emr dynamodb connector, kinesis stream... they are good for different use cases. Manual traverse has following benefits comparing to these solutions:

  • Deal with "small data"
  • Schema evolution, table migration
  • Custom TTL mechanism
  • Full control over offline traversing
  • Work with complicated nosql schema
  • Cross AWS account data replication/transformation

Irrelevant use cases

Since dynamodb-traverse is not native to AWS, do not use if your use cases like:

  • Real time streaming
  • Simple nosql schema that maps one primary key value to one sort key value
  • Big data (~TB) workload that requires dedicated emr clusters
  • Data backup

Installation/Uninstallation

Prerequisite: python 3.8+ and aioboto3>=6.4.1 (bleeding edge)

Run following command to install requirements:

$ pip install aioboto3

Next, install dynamodb-traverse by running:

$ pip install dynamodb-traverse

To uninstall dynamodb-traverse, run:

$ pip uninstall dynamodb-traverse

Setup

  • dynamodb-traverse by default looks at ~/.aws/credentials for profiles you specified in the client. Make sure you have created profile to access dynamodb.
  • You can specify audit log location when initializing client. By default it writes to /tmp/dynamodb_traverse_xxx.log.
  • We recommend using 35 as default scan batch size because of dynamodb limitations

Usage

See examples/traverse_source_table.py

create client

client = DynamoDBBase(
            queue=asyncio.Queue(loop=event_loop), 
            profile='string',
            log_file='string',
            local='boolean',
            **kwargs
         )

Parameters

  • queue (Queue) [REQUIRED] - (async) in memory buffer queue
    • event_loop (loop) [REQUIRED] - if use async queue, a loop need to be specified
  • profile (string) [REQUIRED] - name of aws profile to use, which is defined in .aws/credentials
  • local (boolean) [OPTIONAL] - a flag to indicate if it's local or prod env. Default to True.
  • kwargs [OPTIONAL] - check boto3 for advanced usage

traverse

 client.traverse(**{
       'producer': {
           'source': 'string',
           'TotalSegments': 'number',
           'Limit': 'number',
           'IndexName': 'string',
            **kwargs
        },
       'consumer': {
           'TotalSegments': 'number',
           'function': 'function_label',
           'timeout': 'number',
           'args': 'list',
        }
 })

Parameters

  • producer (hash) [REQUIRED] - a hash describing the producer thread

    • source (string) [REQUIRED] - name of the source table in dynamodb
    • TotalSegments (number) [REQUIRED] - same in boto3
    • Limit (number) [REQUIRED] - same in boto3
    • IndexName (string) [OPTIONAL] - name of the source table index. If specified, we are scanning data from target index, instead of full table.
    • kwargs (OPTIONAL) check boto3 for more advanced usage.
  • consumer (hash) [REQUIRED] - a hash describing the consumer thread

    • TotalSegments (number) - same in boto3
    • function (function_label) - pass a function to this consumer!
    • args (list) - pass a list of args to the function you just supplied. currently we only support position based args
    • timeout (number) - how many second should consumer wait if there's no work load available to it immediately

Benchmark (in progress)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dynamodb-traverse, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size dynamodb_traverse-0.1.4-py3-none-any.whl (13.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size dynamodb_traverse-0.1.4.tar.gz (9.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page