28 June 2020

Serverless ??

If you are a software developer then you must have heard "Serverless" word. You might have heard in context with serverless application, serverless architecture, serverless computing, serverless framework, etc.. Let me start with word serverless, it is little distracting compared to literal meaning of serverless. My first impression was serverless means "no server". On 2nd thought, how can an application like a website or a web-service can be serverless. Have they really came up with an idea to go away from server ?? On further reading I realized that serverless means you will not be owning the server but only the code. Serverless do not meant that there is no server but more like someone else's server. But then why to use word serverless, actually i didn't find the reason. They could have used word like "someone else's server" or "Server is not my headache" or "I worry only my code" or any other set of words. May be they are following a strategy "if you can't convince then confuse" and attract an attention. For sometime initially i incorrectly assumed "embedded server" with "serverless".

To make understand easier, let compare the situation with a car production plant. In it we have a  manager (factory incharge), workers which are spread acrosss different skill sets and buyer who buy the car. Comparing this situation with a Web application like shopping website, the factory manager is like a server (Tomcat, WildFly, Weblogic, etc..), back end API + pages are like workers and car buyers are the end users which are buying products from website. For simplicity assume car is built immediately as soon as car buyer places an order same like page is visible to shopper while browsing a website. As car buyer asks for car, factory manager asks worker to start working and starts creating car. In car factory each worker is specialized for a specific car and there are multiple workers available, kind of a queue. As a factory owner i need to keep on paying to factory manager, workers to make sure they are available. Even if there are no buyer, i have to keep them available.

In serverless paradigm below changes will incur.

  1. I will take my workers to a place where manager and factory setup is owned by someone else like a mass producer (cloud provider) who will manage my workers and give me car as per need. Similarly I will put my code in cloud provider setup where hardware and server will be provided by cloud provider
  2. I will pay to mass producer only for the time my workers are busy and using his setup to produce a car. Similarly I will pay to cloud provider only for the time my code is running on server a span of few milliseconds. For remaining time my workers will be sleeping i.e. code will be idle.  
  3. I do not need to maintain a seperate manager and factory setup for my workers. I do not need to maintain server and keep maintaining it, securing it, etc. 
To rip the maximum outcome of this way of working I can make few changes in workers (code).