Looking through the new dynamodb streams feature, can you use it to do real-time push scenarios like a chat room? Or can you only poll the streams api to get periodic updates?
It seems like the only examples show dynamodb connected to a kinesis stream to make it real time push rather than through polling.
Taking the chat room example even further, can you call the dynamodb streams api "GetRecords" with a filter clause so that you only get the records for a specific hash or range?
What is a "ShardIterator?" Reading through the documentation, it's unclear what it's specifically used for.
The events generated by DynamoDB Streams are near-real-time but not real-time.
Amazon DynamoDB is integrated with AWS Lambda so that you can create triggers—pieces of code that automatically respond to events in DynamoDB Streams. With triggers, you can build applications that react to data modifications in DynamoDB tables.
A DynamoDB stream is an ordered flow of information about changes to items in a DynamoDB table. When you enable a stream on a table, DynamoDB captures information about every modification to data items in the table.
With DynamoDB Streams, you can trigger a Lambda function to perform additional work each time a DynamoDB table is updated. Lambda reads records from the stream and invokes your function synchronously with an event that contains stream records.
Now that AWS IoT is available, you could do DynamoDB Streams > Lambda > AWS IoT > Browser over MQTT or Websockets. This works both ways - with the return path being simpler as AWS IoT can post to Dynamodb directly.
Lambda receives a list of records from Dynamodb Streams and you can loop over the list and publish data to appropriate clients using MQTT topics structured per chat or user (/chat/{uuid} or /chat/joe).
DynamoDB Streams are very, very similar to Kinesis but technically different things. They use similar APIs and their client libraries are related as well, but they are different.
It sounds like you are waiting a client (ex: browser) running on a client to receive a notification that a record changed in real time. This is not what DynamoDB Streams provides.
DynamoDB Streams are more like the NoSQL+clouds approach to database triggers.
It would be possible to build something similar to Firebase using DynamoDB + DynamoDB Streams + Lambda + some type of web socket server. Using this approach you could have writes to your DynamoDB database notify a Lambda function that would notify a web socket server that clients are connected to in real time. This means DynamoDB Streams + Lambda really isn't doing the heavy lifting for this use case as you would need to run your own web sockets server on EC2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With