What is Serverless Architecture?
Serverless architectures make it easy to deploy apps in the cloud. Developers can run the app code without the hassle of deploying and maintaining servers. Cloud providers manage servers for you.
Serverless architecture is a method for creating and launching apps without the need for a server or any other underlying infrastructure management. Serverless architecture is also known as serverless computing or Function as a Service (FaaS).
With serverless architecture, a third-party service hosts your app and manages server-side logic and state. Hence, the term ‘serverless’ does not mean there are no servers at all. Instead, it means there are no servers for the developer to worry about.
Developers can focus on business logic, and individual app code functions. Serverless platforms execute the functions on demand. Think of not worrying about the management of physical, or virtual servers as well as databases. Pure coding.
From On-Premises to Serverless
Since traditional, on-premises architectures moved to the cloud, the form of providing services has changed over the years.
This is how marketers highlight the path to serverless:
- IaaS, or Infrastructure as a Service, virtualizes standard server infrastructure. Developers run their code on a virtual machine, a virtual server located in the cloud data center. These systems are highly configurable and provide administrators with control over compute power, storage and network services. Examples: Google Compute Engine, and Digital Ocean
- PaaS, or Platform as a Service, free developers from configuring and managing hardware resources. Developers only manage containers that execute an app. Examples: Salesforce Heroku and Google App Engine
- FaaS, or Function as a Service, provides the ability to manage only the code. In a complex infrastructure, developers execute snippets of code in response to events. Examples: AWS Lambda service and VoxEngine
How Does Serverless Work?
FaaS executes function calls in response to events or HTTP requests. Developers enter code fragments into a FaaS architecture. These fragments are executed discreetly, providing automatic scaling depending on the load, without the need for developers to manage servers or low-level infrastructure.
Let’s consider an example: a user takes a photo and uploads it to the cloud. The loading process includes:
- Reading EXIF data
- Preparing a small image for preview
- Content analysis with machine learning
- Image data entry into a database
The image upload event triggers all these functions. Once the event is processed, the functions stop working. This is how FaaS works: it quickly launches code to perform tasks triggered by an event and then disappears.
What Apps Best Fit Serverless Architectures?
Developers should consider serverless if there is a small number of functions that need to be hosted. Serverless fits RESTful and event-driven apps. Instead of paying for servers that are idle most of the time, you can run the code as a function.