Giter Club home page Giter Club logo

efficientdynamodb's Introduction

EfficientDynamoDb

.NET Core NuGet Version

EfficientDynamoDb is a high-performance C# library for DynamoDb with a huge focus on efficient resources utilization. Due to DynamoDb extreme scaling capabilities it is very important for backend services to not waste valuable CPU time on unmarshalling responses. EfficientDynamoDb is capable of zero allocation deserialization. In general it allocates up to 26X less memory and is up to 21X faster than official .NET AWS SDK.

Benchmarks

Comparison with official DynamoDb SDK for .NET

|          Method | Items |         Mean |      Error |     StdDev |  Gen 0 |  Gen 1 | Gen 2 |  Allocated |
|---------------- |------ |-------------:|-----------:|-----------:|-------:|-------:|------:|-----------:|
|    EfficientDdb |    10 |      79.1 us |     0.8 us |     0.7 us |    4.3 |      - |     - |    18.2 KB |
|     aws-sdk-net |    10 |     620.8 us |     7.2 us |     6.0 us |   85.9 |   18.5 |     - |   352.3 KB |
|                 |       |              |            |            |        |        |       |            |
|    EfficientDdb |   100 |     484.1 us |     1.7 us |     1.6 us |   29.2 |    5.8 |     - |   120.8 KB |
|     aws-sdk-net |   100 |   6,127.1 us |   120.6 us |   148.1 us |  500.0 |  250.0 |     - |  3066.6 KB |
|                 |       |              |            |            |        |        |       |            |
|    EfficientDdb |  1000 |   4,733.0 us |    24.2 us |    22.7 us |  195.3 |   93.7 |     - |  1147.5 KB |
|     aws-sdk-net |  1000 |  99,438.8 us | 1,951.4 us | 3,518.9 us | 5200.0 | 1600.0 | 600.0 | 30177.0 KB |

Every benchmark simulates QUERY request to DynamoDb that return responses with number of items specified in Items column. All network calls are excluded and data is served from memory to eliminate network inconsistency in benchmarks. Entity contains various data types including lists, hashsets, strings, etc.

Configuration

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19041.685 (2004/?/20H1)
Intel Core i7-8550U CPU 1.80GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.1.110
  [Host]     : .NET Core 3.1.10 (CoreCLR 4.700.20.51601, CoreFX 4.700.20.51901), X64 RyuJIT
  DefaultJob : .NET Core 3.1.10 (CoreCLR 4.700.20.51601, CoreFX 4.700.20.51901), X64 RyuJIT

Introduction

EfficientDynamoDb has two types of API: high-level and low-level. High-level API, in most cases, is on-par with low-level in terms of raw processing speed and requires fewer memory allocations. It is recommended to use the high-level API in most cases unless you're sure about what you do.

GetItem

Retrieves a single item.

var user = await _context.GetItemAsync<UserEntity>("qwerty", "1234");

Query

Retrieves a list of items that match key and filter conditions.

var items = await _context.Query<UserEntity>()
    .WithKeyExpression(Condition<UserEntity>.On(x => x.Username).EqualsTo("qwerty"))
    .WithFilterExpression(Condition<UserEntity>.On(x => x.Age).GreaterThanOrEqualsTo(18))
    .ToListAsync();

UpdateItem

Edits an existing item's attributes or adds a new item to the table if it does not already exist.

await ddbContext.UpdateItem<UserEntity>()
    .WithPrimaryKey("partitionKey", "sortKey")
    .On(x => x.FirstName).Assign("John")
    .On(x => x.LastName).Assign("Doe")
    .ExecuteAsync();

TransactWriteItems

Atomically applies one of four operations per item within the same AWS account and Region.

await context.TransactWrite()
    .WithItems(
        Transact.PutItem(new UserEmailEntity("[email protected]")),
        Transact.ConditionCheck<UserEntity>()
            .WithPrimaryKey("partitionKey", "sortKey")
            .WithCondition(Condition<UserEntity>.On(x => x.Verified).EqualsTo(false))
    )
    .ExecuteAsync();

Visit our website for a complete operations list.

Compatibility with official AWS SDK for .NET

EfficientDynamoDb API is quite similar to the official DynamoDB SDK for .NET, so migration should be relatively easy. The most significant differences are described in the compatibility guide.

efficientdynamodb's People

Contributors

lezzi avatar firenero avatar dependabot[bot] avatar markpflug avatar brewneaux avatar zbyszekpy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.