Henrik
Henrik

Reputation: 43

Is DynamoDB streams the right option for this use case?

I have a DynamoDB table that contains key value pairs that will be read by a number of applications. On startup each application will read the entire table and cache it in-memory.

The problem I'm trying to solve is that of getting the applications to update their cache if one or more items in the DynamoDB table have been modified.

DynamoDB streams initially seemed to be the right approach to solving the problem. I have implemented the consumer using Kinesis Client Library (KCL) as recommended by AWS. While implementing it, however, I have encountered some problems that make me believe that I'm on the wrong track. Specifically:

I also implemented it using the low level API instead. That works fine when there's a single shard. My implementation doesn't handle re-sharding like KCL, however, so it's too fragile. It seems wrong to have to implement handling of re-sharding for the simple problem I'm trying to solve.

I'm beginning to consider other solutions like:

All solutions that I have considered so far have quite significant drawbacks. What am I missing?

Upvotes: 4

Views: 5001

Answers (2)

Roman Scher
Roman Scher

Reputation: 1492

Nowadays an AWS AppSync GraphQL API with subscriptions may be the simplest approach to power this type of application, with the least number of moving parts.

Whenever one of your applications starts up, it connects to your AppSync GraphQL API using the Amplify framework or AppSync SDK and subscribes to the updates its interested in. Then whenever an application updates information in the table via your GraphQL API, all your other applications will be notified of the change, along with the relevant changed data.

AppSync integrates well with DynamoDB out of the box, allowing you to generate DynamoDB tables with appropriate indexes alongside your GraphQL or generate GraphQL from your existing DynamoDB tables if you so choose. Amplify can even help you automatically generate an AppSync GraphQL API at a higher level with associated DynamoDB tables, indexes, entity relationships, and more like elasticsearch search capabilities by using their GraphQL transformers.

Upvotes: 0

John Jones
John Jones

Reputation: 2034

It depends on how your KCL is pushing to the dependent apps but I believe the SQS path is the correct choice.

  • You can add a presumably infinite number of consumers without being throttled.
  • When you do add another dependent app, it won't require changing your KCL to push to it, the new app will simply watch the SQS queue.
  • You gain the ability to monitor the queue when issues happen.
  • More moving parts to setup, but once you have the Streams -> SNS -> SQS pipe in place, it's basically bulletproof.

Just my 2¢.

Upvotes: 3

Related Questions