In a websockets implementation w/ AWS Lambdas and AWS API Gateway maintaining connection state, your AWS Lambdas are invoked whenever someone 1) connects 2) disconnects 3) sends a message.
This project's pattern uses a single AWS Lambda function for all of those events, for the sake of simplicity as well as performance because by receiving more events, the function is kept warmer than average.
Further, when the user loads a page, if you establish the connection at that time, you warm up the function in the background by sending the connection event.
When deployed to us-east-1 and using it in San Francisco, when the Chat App loads, it establishes the websockets connection immediately via React's componentWillMount(), which will warm the AWS Lambda Function. By the time I send the first chat message, the function is already warm, and it takes ~100ms on average to send and receive messages.
This project's pattern uses a single AWS Lambda function for all of those events, for the sake of simplicity as well as performance because by receiving more events, the function is kept warmer than average.
Further, when the user loads a page, if you establish the connection at that time, you warm up the function in the background by sending the connection event.
Here is full Chat Application example you can deploy to test performance: https://github.com/serverless-components/RealtimeApp/tree/ma...
When deployed to us-east-1 and using it in San Francisco, when the Chat App loads, it establishes the websockets connection immediately via React's componentWillMount(), which will warm the AWS Lambda Function. By the time I send the first chat message, the function is already warm, and it takes ~100ms on average to send and receive messages.