Member-only story
A First Look at Serverless Architecture: The Why, The What, and The How
Implement your first serverless app
I recently came across serverless architecture and at first sight, it looked like a one-stop solution for all my infrastructure problems. But with more time spent reading about its reason for existence, I found there is a specific use case that serverless architecture aims to solve, thus I decided to write an article detailing my take on it.
Why Serverless?
Suppose you wanted to create a microservice that simply checks if a particular property
is within a user’s budget or not. The service will end up performing the following steps:
- Take the
propertyId
and budget from the request - Get the price of the property using
propertyId
from an external microservice or a DB - Return if the
property
is affordable or not
Now for implementing this simple functionality, you’ll have to spin up an entire infrastructure, lets say you decide to go with a simple Ec2
instance provided by AWS.
- First, you’ll have to decide which operating system image to chose for instantiation.
- Then set up other instance configurations like inbound rules, CPU and disk size, etc
- Then install the environment and environment dependencies like
npm
,pm2
, etc (assuming you’re using Node.js as your environment) - Then set up a reverse proxy server like Nginx to handle proper DNS resolution.
And even after doing all that if tomorrow the load on your server increases your service might break, and you’ll be forced to look for some autoscaling solutions which is a whole world of choices in itself and will end up costing you more.
All this seems too much of work for such a simple service. This is where Serverless Architecture comes to the rescue.
What is Serverless?
Serverless architecture is a software design pattern where applications are hosted by a third-party service, eliminating the need for server software and hardware management by the developer.