The Rise of Serverless Computing
Hey there!! It’s been a long since we met on medium and let’s discuss something about “Serverless”.
CASE STUDY:
Throughout this article, I will be referring to a fictitious garment retailer (say Bend the Trend) that manages retail clothing stores across the globe and also online. Bend the Trend currently maintains its own datacentre(on-premise)
that hosts the company’s retail website which stores all the required data.
Now imagine as an IT professional, you and your team are responsible for procurement of hardware, maintenance of the data centre and deployment of the application.
CHALLENGES:
The organization has now extended its business capabilities globally and the need to make the retail website highly available is more important now!
With these management responsibilities coming into the picture it's obvious
that they require great compute capacity like servers, databases, storage and
other services to develop and deploy applications at ease.
Say hello to Cloud!
You have probably landed in a one-stop solution where you can easily address
those challenges and deliver your applications to your users on time.
In my last article, I have discussed how Virtual Machines(VM) and Containers can serve an organization in the best possible way. So it's time to take a step further to explore what else cloud vendors can offer you.
Before moving ahead it's necessary to know why we need an alternative solution, that is the limitations of VM’s and container instances. Here are a few problems that may arise:
- Though you do not own the hardware in the case of VM’s, you are solely responsible for spinning it up and making suitable configurations for your applications. But what if you don’t have any idea about the number of applications that you will run across various regions?
- Now, if you don’t have several applications to run you might opt for running multiple instances of your application via containers. But again, what if you don’t know the workloads that your website will handle?
Welcome Serverless
Bend the Trend, after brainstorming with their IT team have realized that their applications are “Event-Driven”. To be more precise, their application would have to wait for a particular input(event) before it can start executing business logic. To avoid paying for the time when the application is idle, i.e waiting for an event to occur, Bend the Trend has opted for Serverless deployment.
What is Serverless?
The term “Serverless” might be deceiving, making you think that there are no servers involved during deployment, but it doesn’t work that way. It simply means the task of maintaining servers isn’t your responsibility.
Serverless deployment refers to the abstraction of underlying infrastructure like server, OS etc by allowing the user to pay for the exact amount of resources been used.
Bend the Trend will also have the following benefits through this architecture:
- Abstraction of Servers- They cannot reserve any server instances and each function will run on a different compute instance. (You only need the code :D)
- Micro-Billing- Traditionally the billing is done on a yearly or a monthly basis which is not cost-effective. But now Bend the Trend will pay only for the time their code has been executed (even on a minute basis).
- Auto-Scaling- Wouldn’t it be amazing if someone automatically allocates and de-allocates resources in your backend based on your business demand? You guessed it right! Autoscaling is a feature where the number of instances would be scaled up and down automatically.
Let’s get behind the stage!
The IT team has figured out their requirements and are now ready for design and deployment. Let us guide them on how it works(:P)
Getting started is very simple, as one need not learn any new tool, language or frameworks in order to use this. The modern serverless tools support almost every third party library and even native ones. The steps are as follows:
- Choose a standard template from the cloud console of any vendor if your use-case matches with one. (Example- sending notifications to devices) where the function would be invoked with pre-defined blocks.
- If you have any specific use case that doesn’t match the standard templates, you can do your own code with your preferred programming language and add it as a zip file to the cloud platform.
- Specify a few necessary things like the region, and the number of instances via a configuration file along with your code.
Yayyy, we did it! The trigger for the uploaded function will be automatically created when an event occurs and you can take rest now!!
Few popular services:
Leading cloud vendors like Amazon(AWS), Google(GCP) and Microsoft(Azure) offer a wide range of services for this architecture.
Few services offered by GCP(Google cloud platform) are:
- Google App Engine- A PaaS solution(Platform as a Service) where GCP provides you with an integrated platform for development along with backend services. One can use this to build an application like a web app or an API from scratch and deploy it.
- Cloud Functions- This service is the sole of serverless architecture where the business logic is triggered in response to a specific event. The ideal case to use this is when you are concerned only about the code and not the infrastructure, which can be done by integrating third party services.
- Cloud Run- A special service where you can deploy container instances on a serverless platform which makes it easier for managing. Generally, cloud run is used for orchestration of containers and automating workflows.
I think Bend the Trend is now satisfied with the solutions provided by their IT team, by making development and deployment more cost-effective and making it suitable for their applications, enabling their access worldwide.
With this, I conclude the article by providing a few documentation links of serverless capabilities offered by GCP and Azure for you to explore!