Real-time event patterns with WebSockets and AWS AppSync (FWM302)
Real-Time Application Patterns with AWS AppSync Events
Real-Time Use Cases
Event Broadcasting: Sending real-time updates to many connected clients
Example: Updating fans on a sports game-changing touchdown or inventory availability on an e-commerce website
Real-Time Collaboration: Enabling communication and interaction between two or more clients
Example: Multi-turn gameplay where players strategize and feed off each other's moves, or a call center where agents need to see ticket updates in real-time
Challenges with Existing Solutions
Polling: Clients frequently checking for updates, leading to increased latency, unnecessary resource utilization, and scalability challenges
WebSockets: Complexity in managing connections and fan-out of messages, requiring custom backend code
AWS AppSync Events
A fully managed pub/sub service for building real-time experiences at scale
Reduces operational overhead by handling connection management, message fan-out, authentication, and other enterprise features
Allows publishers (application clients or backend services) to publish events over an HTTP POST API
Subscribers (application clients or backend services) connect over a WebSocket to receive updates in real-time
Key Features
Namespaces and Channels: Namespaces provide centralized configuration and behaviors, while channels are ephemeral and created on-the-fly
Event Handlers: JavaScript functions that can be used for event enrichment, schema validation, and filtering
Authorization: Support for various modes like Amazon Cognito, OpenID Connect, AWS Lambda, API keys, and IAM
Scalability and Performance: Default quotas of 1 million messages per second outbound and 10,000 messages per second inbound, with no limit on the number of connections
Cost-Effective: Serverless, pay-per-use pricing at $1 per million API operations, with a free tier
Real-World Architecture Patterns
Event Broadcast:
One or more publishers (backend services) broadcasting events to many connected clients (subscribers)
Example: Sports scores and stats, inventory availability, or real-time voting
Collaborative Patterns:
Multiple publishers (application clients) interacting with a set of subscribers in a collaborative fashion
Example: Group chat, collaborative document editing, support ticket updates, or turn-based gameplay
Advanced Patterns
Event Persistence: Persisting events to a data store to allow clients to query for the last update or replay messages
Event Order: Adding timestamps or other metadata to events to enable clients to reason about the order of events
Future Enhancements
Private APIs: Support for deploying AppSync Events APIs within a VPC
WebSocket Publish: Adding the ability to publish over WebSocket, in addition to the current HTTP POST
Lambda Integration: Allowing event handlers to be written in other languages and access external resources
Built-in Data Sources: Integrating with services like DynamoDB, Aurora, OpenSearch, and Amazon Bedrock (generative AI) for event handling
Event Persistence and Presence Detection: Providing built-in options for event persistence, ordering, and presence detection
Attend upcoming sessions and workshops related to AppSync Events
Provide feedback through the surveys to help shape the future roadmap
Your Digital Journey deserves a great story.
Build one with us.
This website stores cookies on your computer.
These cookies are used to collect information about how you interact with this website and allow us to remember you. We use this information to improve and customize your browsing experience, as well as for analytics.
If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference.