I have a service (deployed on ECS) that needs to listen and react to inserts on DynamoDB table.
Currently I am reading the table every second, but I would like to lower the latency. Is there a way I can subscribe to changes in DynamoDB and be notified (via websockets, long polling or similar mechanism) when some record is inserted?
I have checked out DynamoDB Streams, but I couldn't find a way to subscribe to the changes there either. There is a JS project that does something similar, but it
has a "interval to poll"
setting...
Is it possible to listen for changes without polling? If yes, how?
It seems it is not possible. This video explains the concepts very nicely, and it turns out that even Lambda doesn't really get "triggered" - it polls the DynamoDB streams every 250 ms.
If a delay of 1/4 s is not a problem, one could setup events to traverse like this:
DynamoDB => DynamoDB Streams => Lambda => IOT => your app (via MQTT client or websockets)
Seems a bit convoluted though. Still, I would love to be proven wrong on this, so please comment if I'm missing something.