Diagram
Comments
- AppSync manages WebSocket subscriptions for you. If you need full control over the connection, API Gateway WebSocket is the alternative.
- DynamoDB Streams delivers each table change in order, so there is no need to poll the database periodically.
- Authenticate connections with Amazon Cognito or another identity provider. Without a valid token, AppSync does not open subscriptions.
- Send only what changed in each event. Resending the full state on every change consumes bandwidth and raises cost.
Information flow
- AWS AppSync
The user sends a GraphQL mutation to AppSync.
- Amazon DynamoDB
AppSync writes the change to the DynamoDB table.
- DynamoDB Streams + AWS Lambda
DynamoDB Streams emits the change and a Lambda function receives it.
- AWS Lambda
Lambda sends the event back to AppSync.
- AWS AppSync
AppSync pushes the event to subscribed clients over WebSocket.