What is Serveless? A complete guide.

The serverless market has a growth of more than 30% per year and its growing popularity attracts the curiosity of developers and decision-makers.

But it is not a miracle cure and it is essential to understand serverless to know if it is the right solution for your project.

This guide will allow you to understand everything about this new hosting solution:

  • What is serverless.
  • Why serverless is growing in popularity.
  • Advantages and disadvantages of serverless.
  • In which cases is serverless recommended.
  • And how Scalingo addresses these issues.

Finally at the end of the article, we will explain how to do serverless on Scalingo.

Ready? Let’s start!

What is Serverless?

Serverless refers to a managed application environment. If we translate the term literally from English, the term Serverless means “no servers”.

However and despite its name, there are many servers but you don’t need to manage them.

Unlike traditional forms of hosting (dedicated servers, VPS, IaaS), serverless does not require users to maintain the operating system or software installed on the servers.

It is the service provider who takes care of everything: server configuration, deployment, monitoring, logging, alerts, etc.

As a result, a developer only needs to write the code for his application and nothing more.

PaaS vs FaaS vs Kubernetes

Before starting, we thought it was important to clarify the differences between various terms frequently used when discussing the concept of serverless.

Indeed, many articles and projects make an amalgam between the terms serverless and FaaS (Function-as-a-Service) while companies like Google and ourselves (Scalingo) use a broader framework of serverless.

Therefore here is how we use the term serverless for the following services:

  • Platform-as-a-Service](/blog/paas-guide-complet), or PaaS, is therefore a managed application environment.
  • Function-as-a-Service, or FaaS, whose main difference with PaaS is that the servers are permanent for PaaS and ephemeral for FaaS.
  • Backend-as-a-Service, or BaaS, which refers to ready-to-use services accessible by APIs.

This guide will focus particularly on the differences between PaaS and FaaS.

Kubernetes and serverless?

Kubernetes is an orchestration system that also allows to lighten the work of developers and system administrators.

This tool allows to automate deployment and scalability, but unlike serverless, many things still have to be managed manually such as logging, monitoring, alerts, etc…

Kubernetes can nevertheless be used as a basis for a PaaS or a FaaS. This is possible for example with open-source projects such as OpenFaaS and Kubeless.

Why did we come to Serverless?

At the beginning of web applications, their architecture was sometimes very simple: all the code was in the same place. We then speak essentially of monolithic applications. However, there are many cases where the reality is different.

The challenges of scalability

With the growing popularity of the web, it has become difficult to use this kind of architecture to scale up and handle millions of requests per second.

Two scalability strategies exist, but neither is perfect:

  • Vertical scaling consists in replacing existing servers with more powerful servers. This is a strategy generally used when a project has only one or two servers and proves to be costly, difficult and with possible unavailability of your applications.
  • Horizontal scaling consists in managing many servers, often smaller than with a vertical strategy. But managing the addition and removal of servers as well as the infrastructure architecture can quickly become a headache.

In addition, scalability is not the only challenge that system administrators face. DevOps is another challenge that needs to be addressed.

The challenges of DevOps

DevOps is a term used to designate the unification of application development and operation processes.

In recent years, DevOps has become a competitive advantage for innovation.

With better collaboration between developers and operations, better automation and transparency are possible. The result is faster project delivery while gaining stability.

Unfortunately, maintenance requires time and, above all, a great deal of expertise, whether it be in the build system, the development, test and production environments, and finally in correcting deployment problems.

The solution: serverless

The evolution of the web has enabled the creation of many tools to deal with the growing problems of a growing platform with billions of daily users around the world.

Among these tools are the PaaS and the FaaS we mentioned above.

Serverless allows you to have peace of mind throughout the entire value chain of the web: deployment, scalability, delivery, etc..

As we said above, with serverless it is the service provider who takes care of everything: server configuration, deployment, monitoring, logging, alerts …

The advantages of serverless

The changes in the way applications are developed and hosted has therefore created new problems and serverless is one of the solutions that has made it possible to correct these problems and lighten the work of developers and system administrators.

Serverless has many advantages over hosting on dedicated servers or VPS.

Nevertheless, a large part of these advantages are already in the Platform as a Service.

Serverless has many advantages over hosting on dedicated servers or VPS.

To learn more about the specific advantages and disadvantages of PaaS, we have a complete guide on the subject.

Advantages shared between PaaS and FaaS

No infrastructure to maintain

The main advantage of serverless and PaaS is that the configuration and maintenance of the infrastructure is no longer a bad memory!

No more infrastructure security problems, your hosting provider takes care of everything for you.

A version upgrade that goes wrong? Never again.

When the operational no longer needs to spend his time managing the infrastructure, he can spend his time simplifying DevOps procedures improving everyone’s productivity.

Ease of deployment

Deployment requires more maintenance than is reasonable.

There are many scripts and procedures to maintain and bugs every time a new dependency is added to an application.

With serverless and PaaS, no more worries!

Just one command line and it’s done. And Scalingo also offers integration with GitHub and GitLab allowing automatic deployment without even a command.

A complex project will require a little more configuration than that, but it’s usually a lot less work than before.

Exclusive advantages at FaaS

Automatic scaling

The success of your application will create scalability problems.

If performance is not there, it will result in fewer customers, lower satisfaction and reduced confidence.

The virality of a marketing campaign can very quickly create temporary spikes in traffic that need to be managed.

The same is true with shopping periods in e-commerce such as Black Friday.

The serverless does not have these problems. No more need to worry about having the right number of servers at the right time.

The scalability is done automatically without the need for anyone to interfere.

And because each part of your application can scale independently, it also saves money. Instead of having one server that can handle the entire application and all potential traffic spikes.

Nevertheless, some PaaS offer a feature to do automatic scaling. We will see later how to do this with Scalingo.

Payment by consumption

Finally the last advantage of serverless is the payment by consumption.

No more need to pay all month long for a server when you only have activity at certain hours.

No more paying at night when nobody is using the application, a dream come true with serverless.

A secondary advantage to this one is the reduction of resource consumption.

The electricity demand of information technology could represent 20% of the total demand in 2030. Less electricity used is a crucial issue for the future of the planet.

But serverless is more expensive per minute than alternatives such as PaaS. If the application is constantly active, serverless will not be advantageous.

But the ideal uses of serverless are also covered by some PaaS. With Scalingo, you can run containers on an occasional basis that you also only pay for on a pay-per-use basis. We will come back in more detail later in the article.

Energy Forecast
Energy Forecast

Disadvantages of FaaS (and how Scalingo responds to them)

There is no such thing as the perfect solution, so FaaS has more than just advantages.

Latency

Pay-per-use has the following consequence: the servers are not always active, so they have to be started.

As a result, there is a latency time between a request and its response when the servers are inactive.

The technical solutions used for FaaS are optimized to reduce this latency to a minimum, but it is still not negligible.

It also depends on the programming language you use. Some have a boot time that will be much more important than others.

So in use cases where the response time is critical, FaaS is not at all adapted.

With PaaS, the servers are always active and permanent, so these latency problems do not exist.

Technical limitations

Existing FaaS platforms are not yet as mature as PaaS and other alternatives.

Firstly, few languages are supported. For example, AWS Lambda officially only supports Java, Go, PowerShell, Node.js, C#, Python and Ruby.

An API exists for the support of other languages by the community but these supports will not be as stable as the officially supported languages.

Another problem with FaaS comes from the connection with the database. With microservices and FaaS, the number of connections to databases increases considerably and therefore there is a need for hosts that support this type of use.

One solution is the FaaS database. As with applications, you only pay per use and these databases are made so that they are not limited by a certain number of connections.

But few exist at the moment and they require specific libraries to be used with your preferred language, libraries that do not always exist, adding yet another limitation.

Finally FaaS also has memory and CPU limits. If one of your workflows is intensive on these fronts, it will be a problem.

On the contrary with a PaaS like Scalingo, you have support for more than 30 languages, and MySQL, PostgreSQL, Redis, MongoDB, Elsticsearch and InfluxDB databases.

Reduced eco-system

There are also few resources and tools to learn how to use FaaS and be more productive compared to more traditional application architecture models.

As a result, time will be lost on development compared to the time saved on operations.

This is a sacrifice that we must be aware of when choosing FaaS.

Vendor lock-in

The FaaS also has different implementations and functionalities at each hosting provider.

It is therefore impossible to migrate from one to the other without changing the application code.

If the host you have chosen disappears, removes features or increases the prices, it will create more problems than the FaaS will have made you gain.

This is not the case with the alternatives.

With Scalingo, there is a compatibility with Heroku which allows you to migrate without any code change.

Use cases suitable for FaaS

Complement to a static site

When you need a few features on a static site, FaaS is very well suited.

Let’s take the example of a contact form. If you have a static site, you will have to pay a SaaS to manage your forms. And this usually costs within 10$ per month.

But with FaaS, you can manage your contact form yourself for a fraction of that cost.

Recurring tasks

All applications have their own set of recurring tasks: backup management, monitoring, etc.

These tasks are crucial and must therefore not be dependent on possible application availability problems.

FaaS is recommended in this case too.

Webhooks

It has become almost inevitable to have to integrate its application with external services and therefore the management of webhooks has become commonplace.

But the load these webhooks receive is totally different from the rest of the application. Some may only receive a few requests per day.

Therefore, using FaaS to host them is a serious option.

Data processing

If you have data processing needs, the FaaS can be adapted.

But not in all cases.

Indeed, FaaS is not really made for tasks that need a lot of time to run.

Generally, FaaS platforms have limits on the execution time, so one must be aware of this before embarking on this path.

Background jobs

Finally FaaS is useful for background jobs.

The generation of PDFs or images, batch processing, execution of algorithms and many others are portions of applications that have specific resource requirements and the FaaS will be able to load them independently.

How does serverless work at Scalingo?

In addition to PaaS, Scalingo offers several features that allow you to take advantage of the benefits normally exclusive to FaaS: ephemeral containers and automatic scaling.

One-off containers

For all the cases described in the previous section for which SaaS is suitable, it is possible to do the same with Scalingo and its one-off containers.

These containers are not always active unlike the application containers and can be launched from the command line or with the API.

It then becomes very easy to launch these containers on a recurring basis or following events.

Moreover, since the one-off containers are identical to those of your application, there is no need to create specific code as with FaaS services. You can use your favorite frameworks.

In the end, you will only pay per use and you will be able to scale up your application much more serenely.

Automatic scaling

Like the FaaS platforms, Scalingo allows you to load your containers automatically.

You can manage the minimum and maximum number of containers that your application must have, which metric to use as an indicator of scalability, and the target of this metric that will trigger the scalability.

Case Study : How Studo uses Scalingo to do FaaS

Studo, an application that allows Austrian students to manage their studies online, has been using Scalingo for several years and we interviewed them to learn more about their use of ephemeral containers.

Find this case study in a dedicated article : How Studo uses Scalingo to do FaaS.

Conclusion

Serverless is therefore a managed application environment including services such as PaaS, FaaS and BaaS.

Each of these solutions has advantages and disadvantages that it is crucial to take into account when choosing the hosting of a web project.

Mature solutions such as Scalingo minimize the disadvantages of serverless with the versatility of PaaS combined with automatic scaling and ephemeral containers.