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:
Finally at the end of the article, we will explain how to do serverless on Scalingo.
Ready? Let's start!
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.
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:
This guide will focus particularly on the differences between PaaS and FaaS.
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.
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.
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:
In addition, scalability is not the only challenge that system administrators face. DevOps is another challenge that needs to be addressed.
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 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 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.
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.
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!
A complex project will require a little more configuration than that, but it's usually a lot less work than before.
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.
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.
There is no such thing as the perfect solution, so FaaS has more than just advantages.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.