- Newest
- Most votes
- Most comments
Super interesting problem! To throw maybe a curveball at you but have you considered kinesis? I'm assuming each cord is a hex value. So you could use API gw to receive the state change and put it to a kinesis stream. At which point you could have lambda consumers that write to a store (maybe elasticache write-throughs and only persist state to a storage system every so often (sync every minute or so). Then for syncing changes between clients, you'd have a step in the lambda consumer that posts a websocket event back to the API gw for others to consume. Using kinesis also guarantees event ordering so people should be experiencing nearly the same order of events.
Have you considered having the entire bitmap in DynamoDB? Considering 16-bit color depth it would take 40 KB, which is well below the 400 KB maximum item size. You could have a single item table with a version field you'd use to do conditional updates.
Each update would take 40 WRUs and each read 10 RRUs, would that cost be manageable?
To implement the change notification, you could front DynamoDB with AppSync and use mutations. Those mutations would use a Lambda resolver that performs the conditional write. Using mutations you can have the clients subscribe to changes.
Have you considered a relational database? The schema you are describing could be a very simple table in a database.
Relevant content
- asked a year ago
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago
I had not even considered kinesis... Yeah, each coord would be a hex. That looks like a really nice solution. Then I am assuming that when users load the page for the first time and need the most up to date version of the bitmap I could have a lambda that could pull it out of the elasticache and return it back to the client, then they can begin to receive the kinesis updates to remain in sync with other users. That would work, right?
Then I have the S3 with all of the backups of the bitmap.
I guess another way of getting the most up to date version of the bitmap could be to have another lambda behind API gw to get the most recent S3 version (a minute old max) and then apply all of the changes since the S3 bitmap was last updated (get these changes from an elasticache or some other fast storage) then return that bitmap, and that should be the most up to date, but I that isnt a massively scalable solution... as I guess if there were a thousands of changes in the last minute (highly unlikely) then that would be super slow.
Also a lot of repeated work as the lambda would do this for every new user, not sure...