title: Best approach for sending message to multiple connected users by using aws websockets
body: <p>I am building a chat application similar to <strong>Telegram</strong>. 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.</p>
  <p>In my project I am using dynamodb for storing user &amp; 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 &amp; sending the message to all the connected users? If so, what will be the alternative approach?</p>
  <p>Flow Explanation:</p>
  <ol>
  <li>Once the lambda function gets a group message from client/frontend, It will store the data in dynamodb.</li>
  <li>After that I will read all the websocket connected users from another table. (eg. connections)</li>
  <li>Finally I send the message to all the users one by one through the websocket.</li>
  </ol>
  <p>I've deployed my project in <strong>us-east-1</strong> region.</p>
  <p>If my approach is not a scalable or recommended way of creating a group chat application. Please suggest any other approaches.</p>
  <p>Thanks,</p>