DEV Community

Cover image for The Complete Guide to Serverless Apps I - Introduction
Sohan for Fermyon

Posted on • Originally published at fermyon.com

The Complete Guide to Serverless Apps I - Introduction

'Serverless' as a term first appeared around 2012 but it was only in 2014 when it piqued interest after the launch of AWS Lambda. The term spiked in usage in 2020 but went into decline soon after. Early in 2022, interest began to climb again. And right now, the term is as popular as it's ever been.

serverless google trends

There are few reasons for this increase in popularity (which we will delve into shortly) but I thought I'd take this opportunity to draw on my experience working in the cloud, and write a primer for Serverless Applications. This is intended to be read like an e-book and will cover all the facets of Serverless applications.

Here's the Complete Developer’s Guide to Serverless Apps which will be serialized over the course of the next few weeks.

Table of Contents

Defining Serverless 💫

A friend of mine once argued that there is no such thing as serverless because, of course there are servers underneath every one of the services mentioned above.

While he is not wrong in his statement that the things described as serverless do indeed have servers running somewhere, he missed the main point: Serverless is a statement about what resources you must be concerned with and not so much about the actual presence of physical server hardware.

Let’s dive into three definitions of Serverless, and you’ll soon see what I mean. We’ll start with the most generic definition and work toward the most specific.

Definition 1: Serverless as SaaS

The most generic term “serverless” indicates that some offering is run using the Software-as-a-Service (SaaS) model. In SaaS, an entire application is owned, built, and operated by one organization, and other individuals or organizations create accounts to use that application, typically via the web.

Some SaaS providers prefer to use the term “serverless” to describe the SaaS model, particularly when they want to emphasize that you, as the user, don’t have to do any management of the cloud resources required to run the SaaS.

If this is server-less, then what does “server” mean here? The server, that this serverless offering is hiding from you is what used to be called the application server (back in the pre-cloud days). In other words, the machine or machines whose job it was to execute a specific piece of software.


Err..not that Sass

Definition 1: ”Serverless” merely means no management of cloud resources

You can spot this usage of the term easily. For example, when serverless is being used as a synonym for SaaS it signals that:

  • the offering is targeted toward non-engineers,
  • there is no REST API, library, SDK, or CLI to use, and
  • the web interface is the only way to interact with the application.

Definition 2: Serverless as Hosted Application

Consider the following cloud services, each of which claims to be serverless:

  • Serverless database hosting.
  • Serverless logging and monitoring.
  • Serverless messaging framework.

What do these three have in common? A serverless database is one in which someone else manages the database software (starting and stopping, upgrading, patching security issues) and you simply use the database (creating tables, running queries, inserting data). Similarly, “serverless logging and monitoring” suggests the same: Someone else manages a bunch of servers that do log processing and monitoring, and you merely use the APIs provided to attach to your application.

This definition treats the word “server” as referring to the hardware or Virtual Machine (VM) instance. While you (the user) may be required to say what kind of Operating System (OS) or architecture you prefer their cloud service to run on. In this case, you perhaps also choose your memory and/or storage requirements but you are not responsible for the day-to-day operations relating to any of this infrastructure.

Definition 2: ”Serverless” means you (the user) do not have to manage the infrastructure that your cloud services runs on.

You can spot the meaning of “serverless” in this context when the offering:

  • is engineering-oriented,
  • has a REST API, libraries, SDKs, or CLI client,
  • allows you to create instances of this offering for your usage (but you don’t have to manage the day-to-day operations like upgrading, patching, or monitoring), and
  • typically does not allow you to gain access directly to the operating system (such as a shell prompt or system administrator account).

Definition 3: Serverless as a Software Concept

Consider the process of building a Ruby on Rails, Python Django, or Node.js Express application. One of the first things you must do is write the code that starts a server to listen on a particular port. Or, if you go a level lower than these common frameworks, you might even have to create a socket server, attach a thread pool, and map incoming requests to an HTTP (or other protocol) handler. When you are doing any of these things, you are writing a software server.

In the software world, a server is a long-running process that listens for incoming requests (usually on a network connection) and then handles those requests. A server typically handles hundreds to millions of individual requests over its lifetime, which may span hours, days, months, or even years before the server is restarted.

Contrast this with a program where, instead of standing up an entire server, you merely write a function that starts up (receives a single request), handles that request, and then optionally returns a response before it shuts down. That is, each request executes the program from start to finish. Such a program may run for milliseconds, seconds, or perhaps several minutes. But rarely does it run longer.

This is the serverless app model. And this is our third usage of the term “serverless”.

This model gained the name “serverless function” when Amazon released its Lambda offering.

Definition 3: “Serverless” means you do not have to write the software server that will listen for requests, nor do you need to manage the hardware or operating system

You can spot the meaning of the term “serverless” in this context when:

  • you, the developer, write request (event) handlers instead of software servers,
  • a variety of SDKs, APIs, or tooling are provided to make it easier for you to write programs,
  • you do not need to manage server hardware or virtual machines, and
  • you also typically do not have administrator access or shell access to the environment executing your code

What is a Serverless App 🤓

A serverless app is a thing that runs inside of an environment that manages all of the protocol-level and process-level aspects of serving content. Additionally, that serverless environment provides a layer of secure isolation from other serverless apps. In the strongest cases, this allows multitenant hosting, where two different customers or users can run their apps on the same serverless app platform without fear that the other users or customers can tamper with the app.

A serverless app is the piece of software you, as the developer, write and upload to a serverless application platform. And the code you write is started when a new request is received. Your code is expected to handle that request and perhaps return a response, at which point your code is shut down again (ready to be started again in the future).

For the most part, it is acceptable to use the terms “serverless app” and “serverless function” interchangeably. In this guide, we tend to use serverless app because it is more generic (and also shorter to type). Where it is necessary to distinguish between the two, we do so carefully.

Comparing Serverless Apps and PaaS 🗒️

It is useful to contrast a serverless app with an app written for a Platform-as-a-Service (PaaS). Heroku and the open-source Cloud Foundry are examples of PaaS. In contrast, Fermyon Cloud is an example of a serverless app platform, and Spin is a developer tool for building serverless apps.

For starters, Serverless apps are more cost-effective than long-running servers in a PaaS environment. A serverless app is simpler, faster, and more resource-efficient than a PaaS. But let's dive into the conceptual details to see why this is the case.

In a PaaS, you (the developer) write an application in any language the PaaS supports. And then you deploy that application to the PaaS service, where it is hosted on your behalf. Developer self-service is a core feature of a PaaS. That means developers can deploy their applications without relying upon an operations (DevOps or platform engineering) team.

Most serverless app platforms, including Fermyon Cloud, also provide the same kind of developer self-service, including a web dashboard, metrics and monitoring, and a host of tools to assist in developing and debugging.

Where a PaaS differs from serverless apps is, again, in the programming model. A PaaS follows definition 2 of serverless where the hardware is managed, but the developer must still write a software server.

Meanwhile, serverless apps follow the 3rd definition of serverless. Whereby a developer writes only the small program that handles a request and does not have to worry about writing the software server.

If you are looking for a developer self-service platform to run long-running services that are always on, a PaaS is probably the solution you are after. If you are looking for a developer self-service platform where you can quickly write highly efficient apps that need to execute instantly and scale rapidly, you may prefer to take a look at serverless apps.

Conclusion 😊

That was a comprehensive look at defining Serverless and Serverless apps. In the rest of the series we will look at the characteristics of a serveless function, the use cases and of course some code.

Let us know in the comments if you are using Serverless already, and what your usecases are!

Top comments (0)