Skip to main content

Serverless Architecture with AWS


Serverless architecture has become much more than a trend now and its benefits have gained attention from professionals in the technology industry. Multiple cloud providers like Amazon and Microsoft have invested heavily in serverless, which is boosting it's popularity and adoption rate.

What is serverless?

Serverless is a design pattern followed by developers to manage the application in a serverless way. For decades people used to build a huge monolithic application that will be deployed on servers which will be managed by the operations team for deployment and regular maintenance activities. As time passed microservice architecture design patterns became more popular. The huge monolithic application got split into multiple independent microservices and REST APIs were used by the frontend to interact with backend. It was a major architectural change but it didn't simplify server management activities. With serverless, cloud vendors introduced the concept of exposing function as a managed service.

Serverless over Traditional

Reduced setup time: With managed service from a cloud vendor, operations team are no longer needed to look into the low-level aspect of the system

Reduced cost: With serverless, we don't need to invest money upfront on physical machines. It follows the pay-as-you-use model for all of their managed services.

Scalable: Cloud vendors provision or adjust resources automatically when the load on the system changes.

AWS Lamda

AWS Lambda is a compute service that lets you run code without provisioning or managing servers. AWS Lambda executes your code only when needed and scales automatically, from a few requests per day to thousands per second. You pay only for the compute time you consume - there is no charge when your code is not running.

One of the limitations of using AWS is the ability to deploy cloud solution in your local computer for working offline. Initially, developers followed one of the below approaches.

a) Using a shared development environment on the cloud.

b) Using a personalised development environment on the cloud.

They have certain drawbacks though.

a) Conflicts while multiple developers work on the same system.
b) The cost associated with services.
c) Higher turn around time to test the application.
d) Debugging applications in the cloud is difficult.

To improve turn around time and for debugging the application easily, we need to have all the services deployed in your local machine. It's always better to run as many services locally during development lifecycle.

Introducing LocalStack- A fully functional local AWS cloud stack

LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications. It spins up a testing environment on your local machine that provides the same functionality and APIs as the real AWS cloud environment.

LocalStack spins up the following core Cloud services on your local machine.
a) API Gateway
b) Kinesis
c) DynamoDB
d) DynamoDB Streams
e) Elasticsearch
f) S3
g) Firehose
h) Lambda
i) SNS
j) SQS
k) Redshift
l) ES
m) SES
n) Route53
o) Cloudwatch
p) Cloudformation
q) EC2

Why LocalStack?

a) All services run isolated
b) Supports most of the AWS services.
c) Deployment of the stack using cloud formation.
d) Easily unit test & perform integration test of your application in local machine.
e) Easy to use.
f) Support for AWS CLI
g) Integration with serverless

Installing LocalStack

Localstack will be installed in your machine by running below command

docker-compose up -d

Create stack using cloud formation

Your services can be easily deployed on LocalStack using AWS CLI.

Conclusion

If your stack consists of costly services and if multiple developers are involved, it is recommended to use platform that supports the local deployment of AWS services like LocalStack. Unit testing your application with real services in local will help in identifying the issues very early during the product lifecycle.

Comments

Popular posts from this blog

Say Hello to AWS Lambda

Lambda AWS Lambda is a serverless computing platform that allows users to create functions and run your code without provisioning or managing servers. It executes your code only when needed and scales automatically and we need to pay only for the compute time consumed. For more details :  https://docs.aws.amazon.com/lambda/latest/dg/welcome.html Languages supported Java Nodejs Python Ruby Go Dotnet   https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html Use Case  Today we are going to write a simple lambda function in nodejs which takes 2 strings as input and check if the first string is a substring of the second string. {    "first' : "serverless",    "second" : "The art of serverless"  } We will be receiving below response. { "substring" : true  } Steps a) Login to AWS management console b Search for the service 'Lambda' c) From the Lambda consol...