Serverless Architecture is an architectural pattern of hosting an application on cloud servers without the need of the developer setting up any server and managing infrastructure. The cloud hosting provider is in charge of setting up the server for the developer, maintaining and scaling up the server when the need arises.
Serverless Architecture runs apps only when they are needed, this also helps to reduce cost, as you only pay for what you use as oppose to paying for a traditional server for a month that is only used at certain times of the day.
In a nutshell, Serverless Architecture eliminates the need for periodic tasks such as security patches, load balancing, scaling, etc
Now that we have discussed the definition of serverless architecture, let us dive into its benefits and drawbacks
Types of Serverless Architecture
Function As A Service – FAAS
FAAS is a serverless way of executing a block of code known as a function in response to certain events. The developer divides the applications into different functions and then uploads the functions to a FAAS provider. FAAS enables developers to write and make code changes on the fly.
List of Function As A Service providers
Backend As A Service – BAAS
BAAS helps developers to accelerate the backend development of an application by providing resources that allow developers to concentrate on the frontend and the business logic side of the application. Developers using BAAS for their application development don’t have to bother with a lot of backend complexities such as Server provisioning, authentication, and authorization, database, etc, because BAAS has been structured to provide all these features for the developer.
List of Backend As A Service providers
Benefits of Serverless Architecture
1. Reduced time to Market
Developers don’t have to worry about setting up the server for the application nor ensuring the server is secured against malicious attacks as this is already provisioned by the cloud solution provider. Instead, the developer focuses on building the business logic of the application.
2. Automatic scalability
Serverless architecture is inherently scalable. This means that developers don’t have to make plans for provisioning more servers once there is a humongous spike in traffic. The serverless provider handles the scalability or the provisioning of more servers as the case may be when needed.
3. Pay as you go
Serverless architecture gives developers the ability to pay for what is being used and not what might be used. Traditionally, when a developer wants to host an application, the developer would need to estimate the expected number of resources that might be used per month, then purchase them. In most cases, the application doesn’t use the expected resources estimated by the developer thereby costing the developer some expenses that could have been saved. But with serverless architecture the developer pay per usage
4. Serverless Saves time
Besides just provisioning servers as you use, serverless architecture also lift off the heavy burden of implementing certain task in the development of your application. Such tasks include authentication and authorization, database setup, image processing etc. These heavy lifting by the serverless architecture providers save developers time and also enable developers to focus on the real business side of the application
5. Easy to deploy
Serverless providers have made it easy to deploy applications. Meaning that developers don’t have to bother themselves configuring the server environment. Deployments could be done directly from Github or from the command line terminal by typing a simple line of code and the application is ready to be used
Drawbacks of Serverless Architecture
1. Difficulty in switching to another serverless provider (vendor lock-in)
It may become difficult to migrate an application to another serverless provider in cases where a developer begins to get dissatisfied with the services provided by the serverless provider. This is due to the reliance on the serverless provider tools. Each serverless provider has a different architecture, libraries, APIs, etc, and how they communicate with applications hosted on their platform. To switch vendors, developers may need to alter or rebuild some parts of their applications
2. Dependency on the serverless provider
Changes in the underlying infrastructure by the serverless architecture provider could affect the performance of the application. Likewise, if the serverless provider reviews its pricing, it might become expensive to manage the application on their infrastructure
3. Cold start could affect performance
Cold start is the delay in the execution of a function when an event invokes it. Because serverless architecture isn’t running continuously, there will be a delay when an event triggers the function because the function would need to trigger the essential resources needed to execute the function. Once the server executes the function, the server waits for a considerable amount of time for another event before shutting down the resources to avoid another cold start. In the scenario where another event doesn’t come in the server shuts down to save cost
Now that you have an understanding of serverless architecture including its advantages and disadvantages, would you consider it in your next project? Think about it 😉