Serverless Architecture in AWS

Mahfooz Ahamed
4 min readOct 22, 2021

--

In this article, we’ll cover the basics surrounding AWS serverless architecture.

What Makes an Application Serverless?

A serverless application is often comprised of many microservices. What are microservices? A microservice is an independent and modular service that is deployable as a stand-alone service in and of itself. This means that each service does one job within a domain and only that job itself.

An example of a microservice could be an authentication service. The authentication service accepts credentials, verifies authenticity, and returns a JWT token ( A token that verifies you are who you say you are).

Each service is often configured to make use of existing managed services from the cloud vendor or external vendors as much as possible. This reduces code needed for standing up a service greatly — a strong driving point for developers to go serverless.

AWS Lambda are functions-as-a-service that serve as “glue code” for microservices and aid in connecting functionality across the domain.

Simplified Serverless Web Application Diagram

What is AWS Lambda?

AWS Lambda are managed compute services that will auto-scale and execute code when a pre-configured event triggers its executions. What does this mean?

This means that within an AWS Lambda function we can do whatever we need to the data passed to it from the event object (data that lambda function receives when it is invoked).

Here are a few examples of potential Lambda event triggers:

  • Putting an object in an S3 Bucket
  • Scheduling an action to occur
  • Modifying data within a database

Anatomy of a Lambda Function

Handler() Function — Function to be executed upon invocation

Event Object — Data sent during Lambda function invocation. For example, if data is coming from an API gateway, possible event objects could be:

  • Path
  • Headers
  • Request Body Info
  • Other Parameters

Another example would be if data were coming from an S3 bucket. Possible event objects could be:

  • Bucket Name
  • Object Key
  • Action Type

Context Object — Methods available to interact with runtime information. A common use is to find log information and other related items. Here are some examples of what a context object could be:

  • Request ID
  • Log Group

Lambda Function Example

Lambda API

The Lambda API is used by all other services that invoke Lambda across all models. As there is a client in every SDK, the SDK Client invokes the Lambda function, which in turn executes the Lambda function.

For example:

  • An API Gateway invokes the Lambda API to call a Lambda function
  • A S3 Bucket invokes the Lambda API to call a Lambda function
  • Your own custom code invokes the Lambda API to call a Lambda function

API Gateway Basics

Illustrated Below is a basic API Gateway Diagram within a serverless AWS architecture:

Put simply, an API gateway enables you to create endpoints. It also provides you with the ability to create a unified API frontend for multiple microservices at these endpoints that you establish. As a result, API gateways are very commonly used with Lambda functions to create API Backends. If you’re familiar with traditional MVC application architecture, you could make the comparison that an API Gateway in some way resembles a route manager.

Conclusion

Thanks for reading this AWS serverless architecture! I hope it proves useful for anyone interested in serverless architectures.

--

--

Mahfooz Ahamed
Mahfooz Ahamed

Written by Mahfooz Ahamed

Graduated | Postergraduate Msc Big Data Analytics

No responses yet