Cloud | Serverless Architecture
Serverless architecture is a product of cloud computing. In order to understand what serverless computing is, it is essential to know how we got here. As complicated as the cloud computing sounds today, the early cloud computing was relatively straightforward to understand. Initially, there were only three cloud computing models i.e. Infrastructure as a Service (IaaS), Platform as a service (PaaS) and Software as a Service (SaaS). Then in few years ‘As a Service’ (aaS) model started appearing everywhere to the point that we have lost track of the never-ending list of aaS offerings which consists of almost every single thing in the computing world. Here are some examples just presumption: security as a service, network as a service, backup as a service, customization as a service, logging as a service, APIs as a Service, data as a service, backend as a service, authentication as a Service and the list goes on and on.
Although it appears that these providers just want to be part of aaS (as a Service) Club, in reality, there are legitimate business reasons why so many companies have converted their products and services into aaS model. As a Service model offers many benefits. First of all, these services are fully managed therefore customers do not have to worry about how to architect, host, scale and operate these services. Secondly, they offer subscription-based pricing or pay-for-what-you-use pricing and Lastly, these services are typically very easy to consume through standard web based APIs. When you start using these cloud-based services in your applications, you outsource parts of your application out to the cloud service providers. As developers started using more and more of these cloud-based services in their applications, they soon realized that they do not need monolithic full stack applications anymore. All they need is some way to glue and orchestrate various cloud services together in a coherent manner with a user interface and by doing this, they can build highly scalable business applications without using any servers at all.
The power of the thick client native applications on the mobile devices along with HTML5 based rich browser web applications (using MVC frameworks e.g. AngularJS) has enabled developers to write large scale and complex applications by orchestrating any number of cloud service to replace their traditional server-based application backends. Today almost any service you can imagine is HTTP enabled and supports standard authentication token exchange protocols for secure consumption. However, there is one more piece that is still missing in the serverless architecture puzzle. We know, in most real life business application scenarios it is almost impossible to avoid backend customization code entirely. There will always be some unique business requirement that will require custom code. Or there will be cases where you would want to orchestrate some other cloud services from the backend.
Amazon was the first cloud provider who understood this demand and in response, Amazon launched its Lambda service (AWS Lambda is an example of Function as a Service, FaaS). Lambda allows developers to upload and run small chunks of code as microservices or functions. These functions can be invoked in response to events from various AWS services or as APIs through an API gateway. The Lambda was the last missing piece of the serverless architecture puzzle. The Lambda service allows developers to write code as microservices without worrying about how to host that code. Developers just upload their code to Lambda and Amazon takes care of the rest. Lambda is incredibly cheap, Amazon only charges for the time how long Lambda functions run, moreover, the free tier lets developers run first one million function calls for free every month. The Lambda has been a great success for AWS which enabled the serverless architecture. The serverless architecture is the future of application architecture, and all the main cloud providers have recognized this fact that is why every cloud provider have started releasing their version of Function as a Service (FaaS) offering. Google has released Google Cloud Functions, IBM has released OpenWhisk, and now Microsoft has also released its version called Azure Functions in response to AWS Lambda.
It’s important to understand that serverless does not mean that services your applications use do not run on servers. Of course under the hood every cloud service uses servers, but those servers are the service provider’s problem, and you as a consumer do not have worry about managing those servers. Managing servers and infrastructure is not an easy task. At the end of the day “No server is easier to manage than no server at all”.
Since serverless architecture is a new trend, therefore, there is no standard industry-wide accepted definition of serverless architecture. However, there are certain characteristics that define serverless architecture. For example, the serverless architecture only uses cloud-based functional services and not the servers directly, the front end applications are typically either thick client apps or AngularJS type rich web apps.
Now let's look at a real world example of the serverless architecture to understand the concept little better. A Cloud Guru is an online learning school (similar to Udemy), its e-learning platform is a perfect example of serverless architecture because the entire e-learning platform runs serverless.
Example: when a user opens the "acloud.guru" website, after resolving the DNS the request hits the AWS S3 from where the user’s browser downloads the web page contents along with the AngularJS app code. The AngularJS app contains most of the app logic that orchestrate the various cloud services. The users signup or log in using OAuth service with their existing IDs e.g. Google, LinkedIn, Facebook, etc. The application uses Auth0 service to establish users' identity. For storing user’s profiles and other courses related data the application uses Google’s Firebase real-time streaming database. Some functions such as credit card payments or sending email notifications trigger API calls to AWS Lambda functions which then orchestrate other cloud services to complete those tasks.
The serverless is surely the future of application architecture. However, it is not without its drawbacks and limitations. The serverless concept is still very new and evolving; therefore, it would require few years to propagate in the technology community. It is also a complete mindset shift, and most organizations are not prepared to adapt this type of change that quickly. The organizations which are agile and have the appetite to adopt modern technologies quickly will save fortunes by going serverless.
Good one AMIT SINGH. Quite informative.