Serverless Microservices: AWS lambda and API Gateway
By: Nidhi Canopas
Tags: Serverless, Microservices, AWS Lambda, Aws Api Gateway, Serverless Architecture

Photo by K8 on Unsplash

What does serverless mean actually ??

When I heard a serverless word the first time, I thought how is it possible to run applications without servers. You might be thinking the same as me if you are seeing it first time🤔. No worries, once you go through this post you will surely have some crunchy clues about serverless. In short, serverless doesn’t mean to run applications without using servers, but it’s without managing servers.

Photo by Tyler Casey on Unsplash

What are microservices?

Microservices are an architectural approach for software that is designed to speed up development cycles and support scalability. In this approach, the software is composed of small independent services that communicate over well-architected APIs.

We gotta to know about the AWS Lambda function and API Gateway before we go through serverless microservices.

1. AWS Lambda function :

AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume — there is no charge when your code is not running. With Lambda, you can run code for virtually any type of application or backend service — all with zero administration. Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.

AWS Lambda makes it easy to execute code in response to events, such as changes to Amazon S3 buckets, updates to an Amazon RDS table, or custom events generated by your applications or devices. With Lambda you do not have to provision your own AWS EC2 instances. Lambda performs all the operational and administrative activities on your behalf, including capacity provisioning, monitoring fleet health, applying security patches to the underlying compute resources, deploying your code, running a web service front end, and monitoring and logging your code. AWS Lambda provides easy scaling and high availability to your code without additional effort on your part.

AWS Lambda natively supports Java, Golang, PowerShell, Node.js, C#, Python, and Ruby, and provides a Runtime API which allows you to use any additional programming languages to author your functions. Please read our documentation on using Node.js, Python, Java, Ruby, C#, Go and PowerShell.

2. AWS API Gateway:

Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the “front door” for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications.

API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, CORS support, authorization, access control, throttling, monitoring, and API version management. API Gateway facilitates you to pay only for what you use, which includes the API calls you receive and the amount of data transferred out and, with the API Gateway tiered pricing model, you can reduce your cost as your API usage scales.

Serverless microservices workflow

The client application will call API at the backend side, which will be forwarded to API gateway service in AWS, which will trigger lambda function and process it.

Major advantages of serverless microservices:

Optimized latency Selective scalability Free from server maintenance

I hope you’ve got somewhat understanding about serverless architecture. Go and give it a try!