Roadmap to Serverless Computing

Serverless is the latest stage of On-Demand Economy applied to software development.

“Close-up of colorful pins in a world map” by delfi de la Rua on Unsplash

A bit of history on how we got here before explaining what serverless is. In the early days of cloud computing, companies had to set up their infrastructure for their services and applications, including mounting the racks with the servers and configuring all the underlying network and security. Emerging from the necessity of an abstract layer and quicker response from conception to production (TTM — time to market), Infrastructure as a Service was born.

IaaS (Infrastructure as a Service), allowed companies to request the required underlaying infrastructure from other providers, releasing them of huge upfront costs in material and personnel to set up all their services.

But they still had to configure operating systems, software licenses, some network settings and so on. So we got to the next stage.

Photo by Samuel Zeller on Unsplash

Platform as a service (PaaS), now customers can focus on developing their solutions, knowing that they have a platform already configured to run those workloads, in minutes, without having to manage networking infrastructure, servers, storage and so on. Therefore a customer can, for example, launch a PostgreSQL or MySQL database almost instantly without having to install anything by simply configuring the database on a web interface.

But still, this was not enough, because even though with PaaS, SaaS (Software as a Service) or even containerisation (e.g. Docker) were are giving a high-level abstraction of the underlying infrastructure most of the times we still needed to tackle availability problems and manage some applications restrictions and decide on how many instances/containers we needed or how much memory and cores should be used to run the application smoothly.

Photo by Liam Henry on Unsplash

So out of the micro-services model and the breakdown of monolithic applications, serverless was born.

With highly decoupled applications we were able to go a level upwards in abstraction layer and only think about the code and what output we want to have for a certain input, regardless of the number of requests.

Quick example, in order to process large amounts of incoming data, a good developer traditionally would send these requests to a queue to be processed by our instances once they were free to do so. With lambda, you can launch as many calls as we want without ever thinking about application and infrastructure limitations. And if we think about cost, with providers such as AWS you pay only for the amount of time your code is running rounded up to the nearest 100ms, so that is efficiency!

Serverless presents a true on-demand service that starts when receives a request and shuts down as soon as that request is processed, leveraging only the resources needed for as long as they are needed and nothing more. A high-level abstraction such as this also allows for more fault tolerant and secure applications since it cuts the underlying dependencies between services while making sure you don’t have servers running on half or even less of their computational capacity, while paying for the whole computation power.

Wrapping up, serverless takes advantage of a truly on-demand approach and can benefit a lot from economies of scale, since the same server can serve thousands of customers by using virtual independent processes to launch each lambda function allowing for a better distribution and sharing of resources.


In more detail

In practice, a lambda function is simply an anonymous function that receives an input, it can be from a IoT device sending some data, a queue, an instance, a database trigger, and API endpoint and so on that is processed and generates an output, which again can be a trigger to a next step.

Example of a lambda function in node 8.10:

exports.handler = async (event) => {
 // TODO implement
 return ‘Hello from Lambda!’;
};

You can have a full operating application only using serverless. Services like AWS provide you with all the necessary tools, for example, you can use Cognito for authentication, S3 for static hosting, Lambda for any required processing, DynamoDB for database and so on, all stateless services and with well documented SDKs ready to use. I don’t want to get into to much detail on specifics but hope I got your interest in serverless and go ahead and give it a try!

Promising services

Aurora Serverless (Serverless Database): https://aws.amazon.com/rds/aurora/serverless/

Serverless Docker Deployments: https://zeit.co/blog/serverless-docker?utm_source=newsletter&utm_medium=email&utm_campaign=now_docker_beta

The AWS Serverless Platform (describes a wide range of serverless services): https://aws.amazon.com/serverless/

Thanks to Edgar Passos and Bernardo Belchior for the article revision.