-
Notifications
You must be signed in to change notification settings - Fork 2
Agenda architecture
This document outlines the architecture for a backend system designed to efficiently distribute event agenda data to clients. The system utilizes Sessionize as the source of truth for session information while implementing a caching and distribution mechanism to prevent API throttling issues during high traffic periods.
The event's speakers team uses Sessionize to manage the schedule, which exposes an API with session information. However, several challenges exist:
- The agenda needs frequent updates throughout the event day
- Sessionize's API has throttling limits
- Direct client polling would likely exceed these limits during peak usage
- Some users might be unable to access the agenda during high traffic periods
We've designed a serverless architecture that efficiently caches and distributes agenda data while minimizing API calls to Sessionize.
flowchart TD
A[Sessionize API] --> B[AWS Lambda\nAgenda Fetcher]
B -->|Put Object| C[S3 Bucket\nAgenda Cache]
B -->|If Changed| D[GraphQL API\nDummy Mutation]
D -->|Triggers| E[GraphQL Subscription]
F[Client Apps] -->|Subscribe| E
F -->|Query| G[GraphQL API\nResolver]
G -->|Get Object| C
H[EventBridge\nScheduler] -->|Trigger every minute| B
- Triggers the Lambda function every minute
- Ensures regular checks for agenda updates
- Fetches session data from Sessionize API
- Calculates MD5 hash of response
- Compares against cached version in S3
- Uses conditional write operations to update S3 if needed
- Triggers GraphQL mutation when updates occur
- Stores the latest agenda data as JSON
- Uses ETag for version control (MD5 hash)
- Serves as the data source for GraphQL resolvers
- Provides a custom resolver to retrieve agenda data from S3
- Includes subscription mechanism for real-time updates
- Contains a dummy mutation to trigger subscriptions
sequenceDiagram
participant EB as EventBridge
participant LF as Lambda Function
participant SA as Sessionize API
participant S3 as S3 Bucket
participant GQL as GraphQL API
participant C as Client
EB->>LF: Trigger (every minute)
LF->>SA: Fetch agenda data
SA->>LF: Return JSON response
LF->>LF: Calculate MD5 hash
LF->>S3: PUT object with ETag (If-Match condition)
S3->>LF: Confirm update
LF->>GQL: Invoke dummy mutation
GQL->>C: Notify via subscription
C->>GQL: Query for updated agenda
GQL->>S3: Get agenda data
S3->>GQL: Return JSON data
GQL->>C: Deliver updated agenda
sequenceDiagram
participant EB as EventBridge
participant LF as Lambda Function
participant SA as Sessionize API
participant S3 as S3 Bucket
EB->>LF: Trigger (every minute)
LF->>SA: Fetch agenda data
SA->>LF: Return JSON response
LF->>LF: Calculate MD5 hash
LF->>S3: Compare hash with S3 object ETag
Note over LF,S3: Hashes match (no changes)
LF->>LF: No further action needed
For effective operation of this system, consider implementing the following monitoring:
-
Lambda CloudWatch Alarms:
- Error rate exceeding threshold
- Duration approaching timeout
-
S3 Metrics:
- Number of PUT operations (to track update frequency)
- 4xx/5xx errors on operations
-
GraphQL API:
- API error rate
- API latency
- Connection counts for subscriptions
https://sessionize.com/api/v2/d3orwuq1/view/All
-
Error Handling: The Lambda function should implement robust error handling with retry logic for transient failures when accessing the Sessionize API.
-
Rate Limiting: Consider implementing backoff strategies if Sessionize API returns rate limiting errors.
-
Scaling: The architecture is designed to scale automatically for read operations. The single Lambda function updating S3 serves as a throttle for write operations.
-
Cost Optimization: The frequency of the EventBridge trigger can be adjusted based on the expected update frequency to balance cost vs. freshness.
-
Security: Ensure proper IAM permissions are configured for the Lambda function and S3 bucket. Use API keys or other authentication for the GraphQL API.