Book Image

Hands-On Serverless Computing

By : Kuldeep Chowhan
Book Image

Hands-On Serverless Computing

By: Kuldeep Chowhan

Overview of this book

Serverless applications and architectures are gaining momentum and are increasingly being used by companies of all sizes. Serverless software takes care of many problems that developers face when running systems and servers, such as fault tolerance, centralized logging, horizontal scalability, and deployments. You will learn how to harness serverless technology to rapidly reduce production time and minimize your costs, while still having the freedom to customize your code, without hindering functionality. Upon finishing the book, you will have the knowledge and resources to build your own serverless application hosted in AWS, Microsoft Azure, or Google Cloud Platform, and will have experienced the benefits of event-driven technology for yourself. This hands-on guide dives into the basis of serverless architectures and how to build them using Node.js as a programming language, Visual Studio Code for code editing, and Postman for quickly and securely developing applications without the hassle of configuring and maintaining infrastructure on three public cloud platforms.
Table of Contents (16 chapters)

The benefits of serverless computing

So far I have covered the definitions of serverless computing and FaaS. Let's now look at the benefits of serverless applications. Let's look at the benefits that serverless applications provide:

  • Reduced operational cost
  • Rapid development
  • Scaling costs
  • Easier operational management

Reduced operational cost

As we covered earlier in the book, serverless or FaaS applications run on the cloud provider in a fully managed environment. As there are only certain pre-defined runtimes where you can run your functions and the same runtimes are used by many other people within the cloud provider environment, the cloud provider is able to utilize the economy of scale effect and reduce the operational cost required to run your functions. The gains in cost that the cloud provider gets are also due to the fact that everyone shares the same infrastructure, including networking, and everyone will be using it only for a certain period of time rather than using it all the time, like in a traditional application.

These reduced costs of running the functions are passed down to the people consuming these FaaS offerings. They are charged very little for the execution of the functions and are charged in ms intervals. You will see similar benefits in using IaaS and PaaS solutions; however, FaaS takes it to the next level.

Rapid development

As FaaS applications run in an infrastructure that is fully managed by the cloud provider, automatically provisioned and automatically scaled based on the load by the cloud provider, you as a developer can just focus on writing the code that is required to solve your business problem rather than spend time figuring out how to spin up the server, making sure that it is highly available and scales based on the load.

AWS, Microsoft Azure, and GCP all provide various tools to develop and deploy your functions to their environment easily. We will talk about these in later chapters when we talk about setting your development environment and when we are ready to deploy our serverless applications.

Scaling costs

With FaaS offerings, horizontal scaling is something that is automatically managed by the cloud provider. They also take care of scaling up and scaling down the infrastructure that is required to process your functions. What this means is that you don't have to spend any time in developing the solutions yourself, everything is automatically taken care of for you. The cloud provider also takes care of ensuring that your functions are run in an environment that is highly available and that it runs across multiple availability zones (AZs) within a region. The other big benefit that you get is that the cloud provider takes care of patching the infrastructure automatically for you and you don't have to worry about it when there are security vulnerabilities to patch for the operating system or runtimes.

The big benefit with FaaS offerings is that for the compute infrastructure you only pay for what you need down to 100 ms execution time (AWS Lambda). Based on what your application traffic patterns are, this could result in huge cost savings for you:

Cost savings with serverless compared to traditional infrastructure

If you look at the preceding diagram, you will see that in a traditional infrastructure environment, you will always scale up in step functions to ensure that you are able to handle the load without effecting your application, but in a serverless/FaaS infrastructure environment, you scale up for what you need and don't have to scale up in step functions to handle your peak load. This gives you tremendous cost savings.

Another example would be, let's say, your application with traditional infrastructure processes only one request every minute and takes 100 ms to process each request, which will result in CPU usage of about 0.2 percent for the entire hour. If you look at the utilization of this infrastructure, it is very inefficient and you could have a lot of other applications running on the same infrastructure without impacting your application. With FaaS offerings, you will only pay for the 100 ms or 200 ms of computer time per minute, as that is what is used by your application and that would result in an overall time of 0.3% for the entire hour, which will result in huge savings for running your application in serverless architecture.

Easier operational management

So far we have talked about the benefits that serverless computing provides in areas such as scaling, rapid development, and reduced operational costs. Let's look at how FaaS offerings help us in reduced operation management of the application.

Easier packaging and deployment

The packaging and deployment of your application in a FaaS environment is really simple compared to deploying your application to a container or even an entire server. With FaaS, all you will be doing is creating your artifact (JAR (JVM)/ZIP (Node.js or Python)) and then uploading them directly to the FaaS offerings. You don't need any additional deployment or configuration management tools to deploy your applications to a FaaS environment. Some of the cloud providers do provide access to write the application directly in the console itself.

As there is no need to have additional configuration or deployment tools, system administration is significantly reduced.

Time to market

As the operational management in a FaaS environment is significantly reduced, the time it takes to make a business idea a reality is significantly less than what it takes in a traditional infrastructure environment, which means there is more time to try out more business ideas, which in turn is a win for your business. As less time is spent on operations, you have more people to work on solving business problems, which in turn can help you bring your idea to market faster.