can you use dynamodb streams to have realtime triggers like firebase?

后端 未结 2 1607
-上瘾入骨i
-上瘾入骨i 2021-02-20 04:35

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?<

相关标签:
2条回答
  • 2021-02-20 05:00

    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.

    0 讨论(0)
  • 2021-02-20 05:03

    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).

    0 讨论(0)
提交回复
热议问题