-->

Serverless

In the end, as a developer I just want my code to run. I do not want to mess with servers, VM’s, dockers, containers, memory, CPU’s, network, load balancing, disk space… you get the point.
Serverless architecture aims to do that for me.
No more servers!

What is Serverless?

A decade or more ago, if we wanted to deploy our applications, we needed to build data centers, with servers racks, freezing air condition and IT department that was busy all the time.
After the invention of AWS, we had a much easier way to bootstrap and run our application using Amazon’s infrastructure. It is called IaaS (infrastructure as a Service).
We could use their server and only pay money for using them. But we still need to configure and install everything ourselves.
Then services like Heroku appeared, they gave us an abstraction of the servers that known as PaaS (platform as a service).
We didn’t have to do much, just deploy our code to Heroku and it worked. The problem was that it worked very good for monolithic applications, but for a complicated applications that use microservices it was harder.
Then Amazon invented FaaS (Function as a service). You do not need to deploy your application, only your functions. Amazon will take care of everything for you.
FaaS is a synonym for serverless (in the rest of this post I will use both terms for serverless). It is not that the code is not running on a server, it is just that you do not care about it.

It worth mentioning another approach of BaaS (backend as a service) that enables web or mobile applications to have a backend with some services such as authentication, database or storage, but didn’t allow them to run logic on the server (all the logic was on the client).

The are three major serverless providers: AWS Lambda, Google Cloud functions, and Microsoft Azure functions. Each of them is very good and selecting between them is a matter of convenience or personal preference.

Serverless pros

Serverless or FaaS has many advantages:

Serverless cons

Event-driven programming

FaaS has a different approach from traditional server programming. Instead of a synchronous chain of procedures, FaaS is event-driven. A function is being called after an event is triggered. The event can be an Http request, file upload to storage, database change and more. It takes time to get used to it, and design the app accordingly. When writing app with Firebase, simple CRUD operations are trivial, and the functions give the added functionality such as sending a push notification, update a different record in the database etc.

Conclusion

As I can see it, Serverless is the future. You will need a very strong argument to deploy in any other way. It saves salaries of IT and devops, it is stable, scalable and reliable. Currently, there are still some drawbacks: slow bootstrap and performance, but I think that over time when the technology will become mature it will improve.

References

https://martinfowler.com/articles/serverless.html

Originally posted on Spectory's blog