Title
AWS re:Invent 2023 - Building Serverlesspresso: Creating event-driven architectures (SVS204)
Summary
- Serverlesspresso is an event-driven coffee ordering system created during the pandemic, combining serverless technology and coffee.
- The system became popular, serving thousands of drinks at various events, and required scalability to handle simultaneous events in different countries.
- The architecture includes a QR code system for order initiation, a backend with microservices, and real-time updates using AWS IoT Core.
- Design principles focused on minimal code, extensibility, scalability, and cost efficiency, with each team member responsible for one component without implementation sharing.
- The team used AWS services like Amplify Console, API Gateway, Cognito, DynamoDB, EventBridge, Step Functions, IoT Core, and Lambda.
- They avoided building a state machine in code by using AWS Step Functions and Workflow Studio, which simplified the process and reduced code.
- The team created a QR service to generate and validate dynamic QR codes, preventing abuse from shared codes on social media.
- An order manager microservice was developed to handle order interactions, task tokens, and maintain a list of open orders.
- Real-time updates for front-end apps were achieved using IoT Core, which uses MQTT protocol and handles fan-out and network resilience.
- The architecture allows for decoupled microservices that only interact through events, making the system highly extensible and adaptable.
- Lessons learned include the importance of event content, versioning, discovery, and testing by event injection.
- Useful patterns emerged, such as CQRS over WebSockets, orchestration within microservices, choreography between them, and using workflows for waiting management.
- The system proved to be cost-effective, running the entire platform for less than $1 a day on active days.
- Serverless Land and AWS skill builder resources were recommended for further learning.
Insights
- Event-driven architecture (EDA) provides a high degree of flexibility and extensibility, allowing for easy addition of new features and services without disrupting existing functionality.
- The use of AWS Step Functions and Workflow Studio can significantly reduce the complexity and amount of code required to manage stateful processes in serverless applications.
- The Serverlesspresso project demonstrates the effectiveness of using AWS IoT Core for real-time updates, which is a scalable and low-code solution for keeping front-end applications in sync with backend changes.
- The architecture of Serverlesspresso emphasizes the importance of decoupling microservices, where each service is unaware of others and communicates solely through events, enhancing modularity and maintainability.
- The project's approach to handling dynamic QR codes for order initiation is a clever solution to prevent misuse and ensure that the system is only used by attendees at the event.
- The cost efficiency of serverless applications is highlighted, with the ability to scale to thousands of transactions while maintaining low operational costs.
- The lessons learned from Serverlesspresso can be applied to other serverless projects, particularly the insights on event content, versioning, and the balance between orchestration and choreography.
- The Serverlesspresso project serves as a practical example of how AWS services can be combined to create a robust, scalable, and cost-effective serverless application that can handle real-world demands.