I am building a chat application similar to Telegram. Let's say 1 million members are in a group and if someone sends a message in that group, everyone should get the message instantly.
In my project I am using dynamodb for storing user & message details and AWS Lambda for querying data from dynamodb and API Gateway for websocket connection. Is there any possibility that lambda function will be closed before the query & sending the message to all the connected users? If so, what will be the alternative approach?
Flow Explanation:
- Once the lambda function gets a group message from client/frontend, It will store the data in dynamodb.
- After that I will read all the websocket connected users from another table. (eg. connections)
- Finally I send the message to all the users one by one through the websocket.
I've deployed my project in us-east-1 region.
If my approach is not a scalable or recommended way of creating a group chat application. Please suggest any other approaches.
Thanks,