DEV Community

Cover image for What is serverless?

What is serverless?

sheltog profile image Shelton Graves ・Updated on ・3 min read

If you landed here wondering what serverless is and how it works, you are in the right place. Depending on who you ask you may get different answer to what "serverless" means. The first thing we need to do is demystify the notion of "serverless". Serverless doesn't mean there aren't any servers, it just means you don't have to worry about them because they are abstracted from your experience.

ELI5 (Explain Like I'm Five)

Before we can dive into what serverless is let's define it in simple terms first.

Server as a concept

Let's say you want to make bread, you need to buy flour, yeast, water all by yourself and you must mix in a certain proportion according to your recipe. Once the mixture is complete you will need to turn your oven to the right temperature to bake your bread. All these steps are necessary to bake one single unit of bread.

You can take this concept and apply it to using a server to host your application. Not only do you need to provide the code for your application (aka the recipe) you also must setup and configure all the settings necessary to run your application or in this example bake your "bread".

Serverless as a concept

What if instead of making the bread yourself, you outsource the process to a 3rd party. The 3rd party has all the ingredients to make your bread and has the oven(s) to bake your bread. All you need to do is provide your recipe. They will take your recipe; make your bread and you can label it and sell it as your own brand. What if you wanted more loaves of bread? Simply tell them how many loaves you want and they will bake them for you. You will only pay for number of units of the bread you ordered.

In this instance the you don't need to manage the process to bake the bread, you only need to provide the recipe (your code) and the third party will take care of the process of baking the bread (hosting your code). The third party can scale up or down depending on how much you need and you only pay for what you need.

Why use serverless computing?

Serverless computing allows developers to build and deploy applications without having to manage a server. Instead, developers can focus on the code for their application while the service provider takes care of everything else. While serverless computing can be useful in some scenarios, there may be instances where it might not be the right fit.

What are the advantages of serverless computing?

No infrastructure management

With serverless you don't need to worry about managing a server. The process of provisioning, setting up and maintaining a server is taken care of by the vendor. You don't have to worry about patching operating systems or monitoring a server.

Dynamic scalability

Depending on the number of requests of your application receives the vendor will automatically provision more resources as needed and remove them when they are not

Cost efficient

You only pay for when your application when it is running, opposed to paying for a server to run continuously.

What are the disadvantages of serverless computing?

Debugging is difficult

The challenge with using serverless is debugging your code to find errors. Every time you run your application it exists on a new instance so it can be hard to track down the problem. Debugging in serverless isn't impossible but can be more difficult than a traditional server-based application.

Vendor lock-in

When you use a cloud providers serverless platform you inherit all of the intricates of their programming model which makes it hard to switch in the future

Security concerns

Since you don't have one server assigned to your application, the vendor will be running code from multiple customers at a given time. If you have sensitive data, this could pose a risk.

When should you use serverless?

You can use serverless when you have asynchronous and concurrent tasks to be executed, or when you have infrequent requests and spiky traffic where you don't have a dependency on latency. Serverless is also a good option when you need to quickly something running with minimal setup.

For applications that require a predictable constant traffic patterns using a traditional server model may be more cost efficient than serverless. If you are looking to refactor a legacy application to a serverless application, there may be a slight learning curve as a serverless approach requires a paradigm shift in how you architect applications.

Discussion (0)

Editor guide