Serverless, FaaS and why do you need them?

Published 22.02.2021

Author Hrittik Roy

Categories Engineering

In recent years, serverless adoption has started, with more and more individuals depending on serverless technology to meet organizations’ specific needs. A survey conducted by Serverless Inc showed in 2018 that half of the respondents used serverless in their job, and the numbers are projected to rise further.

In this post, we would get around the terms so that you can start your own serverless journey 😉

Let’s get started!

What is a Server?

If you have been on the internet even for a while, you have undoubtedly interacted with a server. Servers are a piece of specific hardware which ‘serves’ information or data to you. The specific hardware contains a lot of memory, speedy internet and generally hosted in massive data centres with other servers.

The Limitation

Hosting websites by buying your server is something you can think of, but you get limited if the numbers you calculate are wrong, which generally is the case. The under-provisioning (having less server capacity than required) and over-provisioning (having less traffic than the server can handle) of servers would take time from your development and cost you money.

You can always jump into a scalable cloud computing infrastructure. Still, then there, you must manage your infrastructure and would have to set aside time for your infrastructure management from the total time you could focus on development. Serverless helps you with this aspect.

Companies often invest less in cloud computing by using serverless services. The organization only pays the cloud service provider for the time their code is executed, instead of paying a flat fee for virtual machine (VM) instances that are always under- or over-utilized. Time is calculated in the form of applications, sometimes billed for every million requests. AWS, for example, charges about $0.20 for its serverless product per million requests.

What is Serverless?

Serverless helps you run an application without the need to configure or own the infrastructure even when the demand increases on an as-needed basis.

serverless doesn't means no server

There’s a misconception that serverless doesn’t require a server, but that’s completely wrong. Serverless run on the server, but the term signifies that you don’t need to worry about servers and the cloud provider takes care of them. They are the most flexible and cost-effective cloud computing technique to date.

How Serverless Works?

Developers rely on serverless to execute specific functions within the application code. We can call this model as a Functions as a service (FaaS) model due to this function-based approach.

If broken down into steps, a serverless lifecycle looks like this:

  1. Code Generation: Developers create a specific use case function with their choice of language.
  2. Event Declaration: A function only starts to pop up when an event happens. The event is often an HTTP request but can be queues, timers, and other various ways to trigger the function.
  3. Event Triggers: As soon the event is triggered via the specified ways, the function is executed. The trigger can be an application requesting information or a user clicking a button generating an HTTP response, or hundreds of other triggers.
  4. Function Execution: Before the function starts running, the cloud provider checks if an instance of the function is running or not. If not, it forms a new one for the function.
  5. Output: The function on execution generates a result that is sent back to the application specified on the code generation phase.

OpenFaas, OpenWhisk, and Kubeless are few frameworks you can use to build your serverless application.

Why use Serverless?

No Servers to Manage

You don’t have to worry about calculating how much hardware you need to provision for your requirements with FaaS. You can go to the market fast with your product because now you’re focusing mostly on your development and don’t have to worry about installing dependencies and other libraries.

Scalability

FaaS helps you to scale automatically up and down if your service traffic fluctuates. Forget about configuring scale sets to scale your VMs, i.e., servers, if a sudden influx of traffic occurs. Your service on FaaS will scale automatically if it’s day or night, just depending on how much traffic you get.

Pay for usage

With traditional VMs, you can fall into the trap of the wrong size configuration of VMs (leaving full capacity unutilized), which could cost you extra money. Moreover, if you forget to shutdown VMs which are not in service, you could reck up a hefty bill.

serverless benifits

FaaS charges you for the requests or the function trigger and not any other parameters. This request billing translates into you only have to pay for how many requests you are getting and nothing extra.

Why are the drawbacks of using Serverless?

Cold Starts

The Serverless Computing environment dictates that functions are run on demand and, when not needed, are thrown away. All these efficiencies lead to a phenomenon called cold starts.

A cold start happens when your function is running the first time in a while. The underlying reason for this is the function must be downloaded, containerized, booted and primed to be run. This problem could increase your service latency if traffic spikes, and so some providers try to minimize it by pushing function on edge.

For visualization, think in a cold-weather your engine takes more time to start than when the engine was working a few minutes ago.

Third-Party Vendor Lock

Each cloud provider deals with its infrastructure differently, but migration is easy because it’s similar on an infrastructure level.

Serverless removes the complete responsibility from your shoulders and put them on the cloud providers. It merely means they are managing infrastructure, and now if you want to develop an application, you have to follow the providers’ path, which is different for each provider.

Suppose a serverless application is developed on a specific provider. In that case, it becomes hard to migrate to another provider (in case you’re getting a better deal there) as a different management system exists. This difference in management system helps the provider lock-in clients. You can see that’s why some cloud providers offer free tier encouraging developers to develop an application on top of their serverless infrastructure.

Hidden Costs

A typical application requires networking, disk, memory and API requests to function. Cloud providers try to outsmart customers by charging a different amount for each service or component need for an application to work. These costs add up drastically, and in some scenario owning your server via a cloud provider comes cheap.

serverless hidden costs

The cold starts also come costly as the users have attention spans in milliseconds, and if it takes more time than that, users will return to some other website. Fun Fact: Only AWS as few milliseconds cold start timing azure and GCP have them measured in seconds (more than 2 seconds in most case).

Read more about hidden costs in this awesome blog.

Final Thoughts⭐

Serverless is a new technology that is under development and makes your developer life easy. A long way to go yet in terms of technology to mature!

One thing to remember serverless can’t be a perfect use case for all your development life cycle, but if sifted through, some cool stuff can be build using serverless.

Happy Learning!

Join the club,

stay in the loop.

Sign up to receive exclusive content around cloud native software development right into your inbox.

We don’t spam! Read our privacy policy for more info.

More stories from our blog

What is cloud native?

What is cloud native?

Cloud native is a term that has been around for a while, but it’s still not well understood. The term was first used in 2010 by Adrian Cockcroft, then VP of cloud architecture at Netflix. He defined it as: “The application is designed from the ground up to take...

Three Monsters: The path to Self Growth

Three Monsters: The path to Self Growth

If you ever take a journey down your daily journal, you would find certain traits that set you back and harm your trajectory to success. Now, if you are busy and don’t have time to write a journal (aka no time for self-discovery) but want to discover these traits (I...

Proxy Servers: The Captivate Shield

Proxy Servers: The Captivate Shield

If you have been scrolling the web, you would have heard about the terms proxy and reverse proxy at least once. You might know a bit of them or might be completely unaware of what they are. This is completely okay with me, and if you have the desire to understand...

Service Mesh: The Gateway to Happiness

Service Mesh: The Gateway to Happiness

Microservices have lead the human race away from monolithic applications to a cloud native landscape. The dominance of microservices (containers) has impacted the modern development environment to be scalable, flexible and continuous. But as the number of...

CNCF: Forefront of the Cloud Native Landscape

CNCF: Forefront of the Cloud Native Landscape

Cloud Native Computing Foundation or CNCF is a term you would see flying all around the cloud native landscape. You might know about it a bit as a prominent organization that maintains your frequently used open source tools like Kubernetes, Prometheus (and more!)...

Kubernetes: Everything You Need to Know about it

Kubernetes: Everything You Need to Know about it

The demand around scalable and reliable services is increasing every day exponentially. The market is driven by customers demanding their favorite services to have zero downtime and companies that lose millions of dollars for every minute they’re down. If you have...

Turbo-charge with Container Orchestration

Turbo-charge with Container Orchestration

Managing containers while traffic increases or decreases in cost-effective ways round the clock sounds challenging and complex without tools. We, as cloud-native citizens, crave scalability and agility. But our containers going into production without the cloud-native...

Unikernel Vs Container Vs VMs: Here is what you should use

Unikernel Vs Container Vs VMs: Here is what you should use

If you’d gone through Containers, Unikernels and VMs, I would bet you’re confused about which one to try for your new venture. It’s normal and happens to everyone while experimenting with adopting new technology. Remember the age-old dilemma of you thinking which...

Interested in what we do? Looking for help? Wanna talk about software strategy?