Introduction:
Serverless architectures have gained immense popularity due to their scalability, cost-effectiveness, and ease of management.
Requirements:
- Serverless architecture
- Expose as REST API with HTTPS
- Users should be able to directly interact with their own folder in S3
- Users should authenticate through a managed serverless service
- Users can write and read to-dos, but they mostly read them
- Database should scale and have some high read throughput
Architecture:
To meet the requirements for the serverless ToDo List app, I would use the following architecture:
- Leveraging AWS Lambda for Serverless Compute: AWS Lambda will serve as the compute engine for our ToDo List app. We’ll write the business logic for the API endpoints using Lambda functions, which can be written in multiple programming languages supported by AWS Lambda.
- Giving users access to a folder in S3:
- To grant users access to their specific folder in S3, we can utilize Cognito Identity Pool. After users authenticate using Cognito User Pool (CUP), we can obtain temporary credentials through the Identity Pool (AWS STS). These credentials can then be used to grant access to the entire S3 bucket, including the user’s folder. Unlike pre-signed URLs, which provide access to specific objects, this approach allows users to access their entire folder.
- Improving read throughput:
- To enhance read-throughput for DynamoDB queries, we can implement a DAX (DynamoDB Accelerator) layer. DAX is an in-memory cache that sits between the application and DynamoDB. By caching frequently accessed data, DAX reduces the number of requests made to DynamoDB, improving read performance.
- Additionally, caching can be implemented at the API Gateway level if the read responses from the ToDo List app do not change frequently. API Gateway provides caching options that store API responses for a specified period. This reduces the load on the backend services, resulting in faster responses and improved read throughput.
Conclusions:
Overall, this architecture allows users to interact with the ToDo List app via a REST API secured with HTTPS. The serverless compute service (AWS Lambda) handles the logic and integration with authentication and storage services. By leveraging a scalable NoSQL database, the app can handle high read throughput efficiently. While implementing a DAX layer and API Gateway caching improves the read throughput, reducing latency and enhancing scalability.