Let’s say you’re a programmer. You write a program which includes a piece of code in a programming language such as Python or Java. Where do you run that program?
You’d run it on a computer. In fact, most likely, you’d run it on specialized computers called Servers that are designed to run 24/7 and they can be used for running your code whenever needed.
In this blog post, we will look at Serverless Computing. Simply put, Serverless Computing lets us build and run programs or applications without thinking about the servers.
The term Serverless computing has been trending since a couple of years. Furthermore, the most popular Serverless service called AWS Lambda from Amazon Web Services has been gaining even more interests over time. At the end of this blog post, you’ll know what Serverless computing is and the advantages and disadvantages of Serverless Computing.
Before looking into what Serverless computing is, let’s look into different models of Servers with analogies to Cars.
The three popular models of servers – Traditional servers, cloud servers and serverless computing are analogous to Own car, rental car and taxicab respectively.
With own car, you make an initial investment to buy the car. Once you own the car, you’re responsible for maintaining the car, having insurance and fuelling the car. Also, you need to drive the car yourself anywhere you need to go. You may not be using the car all the time, but you still have to maintain your car to have it ready to be used.
With rental car, you only pay for the duration of the rental. There’s no initial investment and you don’t have to worry about the maintenance. If there’s any issue with the rental car, the rental provider just provides you with a different one. However, you still need to take care of the insurance, fuel and driving. Moreover, you may not be using the car throughout the duration of the rental.
With taxicab, you pay for the trip from the source to destination. You’re not responsible for maintenance, insurance, fuel and most importantly driving. You get picked up from the starting point and get dropped off at the destination.
We will now see how different models of servers are analogous to cars.
Traditional Servers or On-premise servers are similar to own cars.
With traditional servers, you would need to make an initial investment to buy a computer server and maintain the hardware to run 24/7. you are also responsible for the software, license, runtime systems and other dependencies that are required for running the program. you have complete control over the server and can run the code whenever needed.
However, you need to have the computer server up and running all the time, even though you may not be running the program throughout.
Cloud servers is similar to rental cars.
With a cloud server, you rent the server from the cloud provider and only pay for the duration of usage. You don’t have to worry about hardware maintenance as the cloud provider takes care of it. You are only responsible for the software, license, runtime systems and other dependencies required for running the program.
One of the disadvantages is that You may not be fully utilizing the server or You may have it running even when it’s not being used. Let’s say You have a cloud server hosting an e-commerce web site. The web site may have different levels of traffic during different times of the day. However, You still have to pay the same throughout the day.
Serverless Computing is similar to Taxicab.
With Serverless Computing, You can provide the piece of code to the cloud provider and they take care of running the code. You don’t have to worry about the hardware, software, license or even the runtime system. You only pay for the compute time you consume. You can focus on just the code and the cloud provider takes care of the execution.
The term Serverless is a misnomer. Serverless is not really without servers. There are still servers involved but the developer doesn’t have to worry about it. This model is called Serverless because the developer can just run the code without thinking about servers.
You’re a programmer and you write a program in your favorite programming language. You just give the program to the cloud provider and they run in their cloud servers. The cloud servers are abstracted from you and you don’t have to directly deal with the servers.
The code that you provide is still being run on servers. But you don’t know how and where it’s being run as the cloud provider takes care of it.
Serverless Computing comes with several advantages.
Generally, Serverless computing has low cost compared to traditional and cloud servers.
Deploying the program or application is easier compared to other models of servers. This is because the cloud provider takes care of the operating and runtime systems. We just have to package and deploy the code.
Serverless Computing inherently comes with elasticity as it can scale up as well as down. The cloud provider takes away the responsibility from you for scaling the capacity according to the demand.
Serverless computing enables high productivity as it relieves you from tasks like server management, scalability and multi-threading.
Serverless Computing doesn’t come without any disadvantages.
Debugging or diagnosing performance of the programs may be comparatively more difficult than with traditional servers.
We have less control with Serverless environments compared to traditional servers as we don’t have access to the operating system and other software.
Programs running in a Serverless environment are by default locked to the specific cloud vendor. It’s usually an involved process to migrate the program from one Serverless computing service to another.
There are some privacy implications such as shared resources that need to be considered because many serverless environments are based on proprietary public cloud environments.
Use cases of Serverless Computing are associated with “on-demand” functionality that enables the supporting infrastructure to be powered down and not incur charges when not in use.
Some of the use cases of Serverless Computing include data processing, backend for web applications, event streaming and internet of things services.
Some of the popular Serverless computing services include Amazon Web Services Lambda, Google Cloud Platform’s Cloud Function and Microsoft Azure’s Azure functions.
In a Nutshell
With Serverless Computing, you can write a piece of code and run it without thinking about servers. The cloud provider takes care of running the code on their cloud servers.