Serverless architecture comprises a group of technologies working together as a single unit to deliver a solution. In this write-up, let’s review the involved technologies along with their high level purpose to build a web application.
Backend is a stand-alone service comprising three main components - Data store, Lambda functions used as a compute service and API Gateway acting as a main backend interface.
Data Store / Database
Aurora Serverless (PostgreSQL) is one of the options. There are few other serverless database options available to choose from. Data store choice purely depends on the type of data stored within the application.
Lambda functions with Python could be used on the backend. AWS Lambda supports many other options such as Node.js, Java, .NET Core, PHP.
API Gateway serves as a gatekeeper to the backend service. API endpoints can be secured and served through the API Gateway. API Gateway leverages lambda functions to perform necessary data processing to serve requests made to the API endpoint. Frontend applications or any other service requiring data can call these API endpoints with required security token to obtain necessary data.
Frontend framework such as Angular, Vue, React or any other framework could be used to build the frontend website. During deployment, front-end code is built and deployed to AWS CloudFront CDN and served to the end users’ browsers upon request.
AWS Cognito is an Amazon authentication and authorization service. This service also has support for SAML / OAuth2 / Open ID authentication through major Identify providers such as Facebook, Google, Okta.
Besides above mentioned core services, there are many other supporting services involved in the serverless application architecture. Let’s review the purpose of these supporting services.
Serverless Framework helps develop and deploy serverless applications along with the required infrastructure resources they require. It's a CLI that offers structure, automation and best practices out-of-the-box and helps build sophisticated, event-driven, serverless architecture applications. Framework itself is built with Node.js but it can support multiple languages (Node.js, Python, Java, and more). This framework is cloud-agnostic meaning one can use this framework to develop serverless applications for any cloud provider.
AWS Serverless Application Model is an alternative option to serverless framework but it is specific to AWS.
AWS CloudFormation gives an easy way to model a collection of related AWS resources, provision them quickly and consistently across different environments, and manage them throughout their life cycles, by treating infrastructure as code. Serverless framework’s configuration files describe all of the services that need to be provisioned for a given application.
Simple Storage Service(S3) can be used as an intermediate storage for transferring and processing data from external systems. S3 can also be used for storing artifacts during the build and deployment process.
Identity and Access Management Service is one of the important services in this solution. This service is mainly used for providing granular access permissions among various services used within the AWS serverless environment.
This service is used for domain registration so deployed applications could be accessed using a user-friendly URL.
AWS CloudWatch is a logging service used by other services to log messages within the serverless solution. Messages logged in the service can be used for setting up alerts in case there are errors/issues within the application.
AWS CodeCommit is AWS provided solution for source control. Other third party source control solutions such as Github can also be used for source code management.
This AWS solution enables automation of continuous build and deployment of applications.
Simple Notification Service used for event messaging. Events could be notified to multiple interested systems enabling microservices / distributed processing.
Simple Queue Service is a messaging service used for processing events sequentially. This service can scale well and also has facilities for guaranteed delivery of sequenced messages.
AWS Systems Manager
Systems Manager Parameter Store is used for application’s configuration and secrets management.
All of the services configured for the serverless solution would be deployed within the application’s secure Virtual Private Cloud environment. VPC should be configured properly to avoid security holes.
Here are some of the benefits of using serverless architecture:
- This architecture scales well from few users to thousands of concurrent users.
- As there are no dedicated hardware resources provisioned as part of this solution, there is no infrastructure cost around server maintenance and upgrades.
- Also, the services involved in this solution are charged based on usage. This solution could be cost effective if configured properly.