Microservices to Serverless architecture Implementation in AWS Lambda

Zubin Mukherjee
Mindful Engineering
5 min readApr 7, 2020

Most businesses today are operating in a highly uncertain environment which can be tricky to predict what exactly a customer needs now. One way to start by a hypothesis and going ahead with an assumption of what will work is by running a quick experiment to verify that. It probably takes us through multiple experiments to conclude with what is the right thing to do.

So, the faster we can experiment the faster we could get from IDEAS to Service to Product and sooner can align with the customer’s need hence achieving a competitive advantage.

Modern application development requires a set of best practices and when it comes to designing, developing and managing you application it helps to develop applications faster and it makes you more agile

This blog will walk us through the following topics listed below:

  • What and Why to use serverless computing?
  • Benefits of serverless
  • Five pillars of well-structured architecture
  • Advantages of serverless microservices
  • FaaS
  • AWS Serverless Application Model (SAM)
  • Serverless Frameworks
  • Steps to create AWS Lambda function using Python
  • Conclusion

What is serverless computing?

Serverless computing is a cloud computing execution model providing backend services in which the cloud provider runs the server and dynamically manages the machine resources allocation. The user pays for the actual usage of resources consumed by an application instead of pre-purchased units of capacity.

Why use serverless?

Serverless enables to build modern applications with increased agility and lower total cost of ownership. Building serverless applications means that developers can focus on the core product functionality without worrying about managing and operating servers or runtimes, either in the cloud. This reduced overhead lets developers reclaimed time and energy.

Features of serverless:

  • Greater agility
  • Less operations
  • More product focus
  • Faster time to market
  • Cost that grows with your business

Five pillars of well-structured architecture

  • Operational Excellence
  • Security
  • Reliability
  • Performance Efficiency
  • Cost Optimization

Advantages of serverless microservices

  1. Resilience: Because the application is divided up, one part of the application breaking or crashing does not necessarily affect the rest of the application
  2. Selective scalability: Instead of scaling the entire application, only the microservices that receive a great deal of usage can be scaled
  3. Easier to add or update features: Features can be rolled out or updated one at a time, instead of updating the entire application stack

4. Flexibility for developers: Microservices can be written in different languages and each have their own libraries.

Functions-as-a-Service (FaaS)

  1. The traditional system operations have separate operations in the applicaton process.
Figure 1.0 : Microservice architecture

2. In Faas, all required application processes that are common and iterative are encapsulated into a single Faas Platform.

Figure 1.1

3. For performing a particular operation it will trigger the respective function as shown below.

Figure 1.2 : How Functional operation works

AWS Serverless Application Model

SAM model plays a major role when we want to define our serverless application. The SAM template consists of data types, intrinsic functions , API gateway and resource variants like its attributes, types and properties.

AWS SAM templates are extensions of AWS Cloudformation but in a minified version that make the development pace easier and faster.

Things you should know for most importantly are:

  1. AWS SAM Template Anatomy

2. AWS SAM command line interface (AWS SAM CLI).

3. Writing YAML file which involves Globals, Description, Metadata, Parameters, Mappings, Conditions, Resources and Output.

4. AWS SAM Resource and Property Reference

Steps to create AWS Lambda function using Python

Step 1: Headover to https://amazon.com and sign in as root user or IAM user.

Step 2: Go to the AWS Console.

Step 3: We’re gonna headover to AWS Services -> Lambda section and we’re going to create our first Lambda function in python.

Step 4: Select “Create a function”.

Step 5: Assign name to the AWS Lambda Function as “pythonLambdaFunction”, select “python version 3.8”.

Step 6: Select execution role “Choose or create an execution role” as “Create a new role with basic Lambda permissions”.

Step 7 : Scroll down and you will be able to see the pythonic function click on “Test”.

Figure 2.1 :- Glimpse of Python Lambda Function.

Step 8: First name your event as “ pythonEventHandler“ then create the event.

After creating the Lambda Event you should see the below success code in output.

Figure 2.2 :- Successfull execution of Lambda Function

Top Severless Frameworks

Figure 3.0 : Serverless Trending Frameworks

Wrapping-Up:

  1. AWS Lambda is an very great web service which we can use to make the iterative process concise and this will increase development speend faster, it is also cost consuming as you pay as per usage.
  2. Microservices has lots of disadvantages like the intercals between the shared services puts lots of load on servers here autoscaling is done by the AWS itself.
  3. Serverless is the next evolution to the cloud computing domain so adopting it will be helpful for our modern applications in this challenging environment.
  4. Serverless services, and our understanding of how to use. It will be fascinating to see Serverless architecture how it fits into our architectural toolkit.

Finally, thanks to the serverless , AWS community and for reading if you find this helpful.

For further queries you can connect on LinkedIn

Happy Coding!

--

--