AWS Serverless Services for Microservices Architectures

In this article, we are going to learn how AWS Serverless Services can be use in Microservices Architectures with designing Serverless Event-driven E-Commerce Application.

Serverless Event-driven E-commerce Microservices Architecture

We will start with looking for AWS Serverless Services and after that we will continue to understand how we can use these AWS Serverless services into an example microservices architecture.

Step by Step Design AWS Architectures w/ Course

I have just published a new course — AWS Serverless Microservices with Patterns & Best Practices.

In this course, we’re going to learn how to Design and Develop AWS Serverless Event-driven Microservices with using AWS Lambda, AWS DynamoDB, AWS API Gateway, AWS EventBridge, AWS SQS, AWS CDK for IaCInfrastructure as Code tool and AWS CloudWatch for monitoring.

Source Code

Get the Source Code from Serverless Microservices GitHub — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.

AWS Operational Responsibility Model

When we talk about Serverless, the best way to explain what Serverless is looking to AWS Operational Responsibility Models. You can think this is a spectrum about responsibility level of services.

https://d1.awsstatic.com/events/reinvent/2019/REPEAT_3_Serverless_architectural_patterns_and_best_practices_ARC307-R3.pdf

If we look at the image, and if we look at the horizontal way, we can see the traditional on-premises machines , virtual machines, bare metal hardware devices at the beginning of the image.

And if we go to right hand side, you can see the cloud infrastructure, which includes managed services that managed application services on the cloud.

And if we go the last of the right hand side, you can reach the fully Serverless services that we don’t any responsibility about servers, patches, updates and also not consider about scaling, reliability and availability so on.

And if we look the vertical way, you can see the separation of services

  • Compute
  • Databases
  • Storage
  • Messaging / Application Integrations
  • Analytics
  • and we can put here API Management for AWS API Gateway

So these are the services by grouping for AWS Services that we mostly use when developing enterprise level applications.

You can also see this kind of grouping in Products of Amazon website;
https://aws.amazon.com/
Products

You can see that;

  • Application Integrations — SNS, Event Bridge, Step Functions
  • Compute — Lambda, EC2
  • Database — DynamoDB, Auora Serverless
  • Frontend Web — API Gateway
  • Serverless
  • Storage and so on.

So according to these grouping, AWS services evolve by time and now in Serverless part they have very great service which you don’t consider any server management and scalability issues.

Lets see which services available for AWS Serverless by grouping;

  • Compute — AWS Lambda
  • Databases — DynamoDB, Auora Serverless Database
  • Storage — S3
  • Messaging/Application Integrations — SNS,SQS, EventBridge
  • Analytics — Athena
  • API Management for AWS API Gateway

We will use lots of these services when designing our Serverless E-commerce application.

AWS Serverless Services for Microservices Architectures

We will use a set of AWS Serverless Services for our Serverless E-Commerce Microservices application. Lets see what exactly AWS Serverless services used by grouping in our application;

AWS Serverless Services for Microservices Architectures

Compute — AWS Lambda

AWS Lambda is Serverless service that you don’t worry about servers and machines, you only worry about uploading code. AWS responsible for scaling your application, provision machine on behalf of our cloud environment and deploying code when traffic comes our application. All server related tasks are hidden from us when using AWS Lambda.

Databases — DynamoDB

NoSQL key-value database that scales horizontally and most popular database in AWS Serverless resources.

Messaging/Application Integrations — SQS, EventBridge

Building event-driven architecture with these integration services, we will implement fanout integration pattern with using these services.

API Management — AWS API Gateway

Provide to expose rest apis without thinking servers and scaling your api methods.

IaC — AWS CloudFormation and AWS CDK Stacks

We will develop our infrastructure with using AWS CDK and AWS CDK using AWS CloudFormation on behalf of our typescript codes.

Monitoring — Amazon CloudWatch

We will examine microservice lambda logs with CloudWatch. Very important to follow lambda invocation types from Amazon CloudWatch.

We will use lots of these services when designing our Serverless E-Commerce application. And we can also extend these services with adding new use cases into our Serverless microservices architecture.

AWS Serverless Microservices for Ecommerce Application

Serverless Event-driven E-commerce Microservices Architecture

If we look at the AWS Serverless Microservices for Ecommerce Application you can see how we can use these AWS services into our application architecture.

Synchronous Communication for RESTful Microservices

Synchronous commands are request/response. In a synchronous model, the client makes a request and waits for a response. We will developed RESTful Microservices with API Gateway, Lambda Functions and DynamoDB.

We called this = RESTful Microservices

  • REST API and CRUD endpoints (AWS Lambda, API Gateway)
  • Data persistence (AWS DynamoDB)

AWS API Gateway -for- Restful API-Driven Development for performing CRUD operations amongst lambda and DynamoDB.

Asynchronous Communication

In an asynchronous design, the client sends a request and may get an acknowledgement that the event was received, but it doesn’t get a response that includes the results of the request.

We will use

  • Amazon EventBridge -for- Event-Driven asynchronous communication between Microservices

We will develop Amazon EventBridge with Lambda Basket microservices which publish the event in asynchronous way and this will consume by Ordering queue.

Event Source Mapping for Polling Event Messages

In a polling event, consumers poll the producer for messages in batches and then process the batch before returning for a new batch of records.

We will use

  • AWS SQS -for- Decouple Microservices and processing events asynchronously using queues

We will develop AWS SQS with Lambda Ordering microservices which consumes by polling the event from the Ordering queue.

As you can see that we follow Serverless Microservices with AWS Lambda Invocation Types; Following Microservices Communication Types for Serverless;

  • Synchronous Communication
  • Asynchronous Communication
  • Event Source Mapping for Poling events

AWS Serverless Microservices for Ecommerce Application Architecture

This is the big picture of what we are going to develop together for AWS Serverless Event-driven E-commerce Microservices application that is Step by Step Implementation together.

Serverless Event-driven E-commerce Microservices Architecture

We have followed the reference architecture above which is a real-world serverless e-commerce application and it includes;

  • REST API and CRUD endpoints with using AWS Lambda, API Gateway
  • Data persistence with using AWS DynamoDB
  • Decouple microservices with events using AWS EventBridge
  • Message Queues for cross-service communication using AWS SQS
  • Cloud stack development with IaC using AWS CloudFormation CDK

Step by Step Design AWS Architectures w/ Course

I have just published a new course — AWS Serverless Microservices with Patterns & Best Practices.

In this course, we’re going to learn how to Design and Develop AWS Serverless Event-driven Microservices with using AWS Lambda, AWS DynamoDB, AWS API Gateway, AWS EventBridge, AWS SQS, AWS CDK for IaCInfrastructure as Code tool and AWS CloudWatch for monitoring.

Source Code

Get the Source Code from Serverless Microservices GitHub — Clone or fork this repository, if you like don’t forget the star. If you find or ask anything you can directly open issue on repository.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mehmet Ozkaya

Mehmet Ozkaya

Software/Solutions Architect, Udemy Instructor, Working on Cloud-Native and Serverless Event-driven Microservices Architectures https://github.com/mehmetozkaya