DEV Community

Cover image for Deep dive into AWS Serverless Architecture
Rashi Agarwal for AWS Community Builders

Posted on

Deep dive into AWS Serverless Architecture

Serverless architecture is more than just a buzzword, it’s a revolution in how we build and scale applications. Imagine writing code without worrying about servers, infrastructure, or scaling. Sounds dreamy, right? But serverless isn’t magic—it’s a well-structured approach with distinct layers working together seamlessly.

Tiers of a Serverless Architecture

The most common serverless architecture pattern that we find almost everywhere, irrespective of whether we are using servers or going serverless. It is the three-tier Architecture, most common form of multi-tier architecture

The three-tier architecture, as the name suggests, has 3 tiers. Let’s dive into these tiers :

1. Database or Data Tier

No application is complete without data. The data layer ensures your application stores, retrieves, and processes information effectively.The data tier would contain the databases and you could also use other data stores as well. The data stores fall into two categories:
1️⃣ IAM enabled Data stores: IAM enabled data stores allow you to connect to them directly using the AWS APIs.
Core Services: Amazon DynamoDB, S3, and Amazon ElasticSearch.

2️⃣ VPC hosted Data stores: hese services run on hosted instances within a VPC. It allows you to connect to different databases using database credentials.
Core Services: Amazon RDS, Redshift, and ElastiCache.

Example => You could use Amazon RDS for PostgreSQL as your relational database and connect to it through your Serverless Lambda functions. This setup is perfect for applications that require complex queries, transactional consistency, or advanced analytics, such as an inventory management system that tracks stock levels, sales, and reorders in real time.

2. Serverless Logic Tier or Application Layer

This is where the core business logic of your serverless application would run.This layer processes user requests, runs workflows, and applies your application’s core logic.
Core Services:
1️⃣ AWS Lambda: Execute your code without provisioning servers.

2️⃣ Amazon API Gateway: Expose your backend logic through REST or WebSocket APIs.

3️⃣ AWS Step Functions: Orchestrate multiple workflows with visual diagrams and state machines.

Example => Let’s say you’re building a real-time translation app. When a user sends text, an API Gateway triggers a Lambda function that:
(i) Calls Amazon Translate for language conversion.
(ii) Stores the original and translated text in Amazon DynamoDB.
(iii) Sends a notification via Amazon SNS to the recipient.

This entire workflow can be orchestrated using Step Functions, ensuring each step runs smoothly or retries on failure.

3. Presentation Tier or Frontend

The presentation layer is where your users interact with your application. In serverless, this layer is often lightweight and scalable.The frontend would interact with the backend through the Logic tier.

Example => Frontend applications could use API Gateway endpoints or event triggers to call Lambda functions, which in turn interact with the data stores available in the Data Tier.
These frontend applications could be: static websites hosted in S3, Alexa, IOT devices, mobile app frontend.

Putting it Together

Let’s combine everything into a real-world application: a serverless static website hosted on S3.

  • Presentation Tier: The website’s HTML, CSS, and JavaScript files are hosted on Amazon S3 and distributed globally through Amazon CloudFront for low-latency access. The frontend includes a user-friendly interface that allows visitors to submit feedback. We can include services like AWS Cognito for authentication and authorization.

  • Logic Tier: When users submit feedback through the form, the request is sent to Amazon API Gateway, which triggers an AWS Lambda function. The Lambda function interacts with the data tier, processes the feedback, applies any business logic (e.g., spam filtering), and stores the data in the database.

  • Data Tier: Feedback submissions are stored in Amazon DynamoDB for fast and scalable access. For additional analytics, the data is periodically streamed to Amazon S3.
    Below is the architecture diagram for the same:

Serverless architecture of website hosted in Amazon S3

That's all for the blog! Hope you liked it and learned something from it😄

Top comments (4)

Collapse
 
jatinmehrotra profile image
Jatin Mehrotra

I like the way you have explained concepts talking real world examples

Collapse
 
rashiagarwal profile image
Rashi Agarwal

Thank you 😊

Collapse
 
wulemat profile image
wulemat

It's very insightful and easily explained 👍

Collapse
 
rashiagarwal profile image
Rashi Agarwal

Thank you :)