There’s some topics on this subreddit already but there doesn’t seem to be a good answer for doing this.
I have a react native app that has hundreds of thousands users active at the same time. They all need to receive the same message at the exact same time and I’m wondering what the best way to achieve this would be.
My current thought is to have everyone connected via a websocket connection through lambda and then when I want to broadcast the message loop through each connection through lambda again but do it about 30 seconds earlier to do state synchronization on the client side which will handle the actually change in a countdown.
Would this provide the most scalable, cost effective, and reliable method?
If you’re sending messages over the network it is literally impossible to verify that they will all show up at the exact same moment - partially because of network congestion, partially because of devices prioritizing notifications differently, partially because of physics. You also can’t guarantee that everyone is using NTP correctly - someone’s clock might be two seconds out for whatever reason so good luck correcting for that.
Let’s say the clocks were all correct then wouldn’t sending the time to display the message beforehand make this possible? I understand the first part which is why I’m thinking the synchronization would be the best method.
Yes, but that’s a huge assumption for 100,000 recipients. Unless these recipients are all corporate devices that you can control their time settings via MDM, you need to assume that someone’s clock will be wrong.
What if you checked if the time was accurate enough by comparing it to the actual time via the internet on connection since all the devices will be connected to the internet.
As others have said - the “no delay” requirement is basically impossible. How much development time can you put into this? I would just be reaching for SNS for a basic integration and if you find it lacking, implement a custom websocket on ECS.
AppSync just rolled out some new rate limits on real-time subscription capabilities (websockets). Outbound messages are capped at default now at 1,000,000 per second. Still well above what you need.
How important is it that no one sees it early? If you send it and then display client side there’s always the chance someone can snoop the network traffic and read it earlier
If you know in advance, can you set it to run on the client side? Instead of depending on network to deliver all of them at the same time.
Or if you want it more dynamic you could broadcast a message saying: event is at 13:05 or something, and then the client would make the notification itself at that time (if that makes any sense).