What is Serverless and how we got here?
The first thing we need to know about serverless architecture is that it’s not what the name suggests. Despite how the name says, it actually has servers. The only difference is the server related works is not handled by the developer.
Now, before jumping right into this topic lets know the history of Serverless, as in how we got to where we are today?
Initially, companies and individuals used to buy and manage their own software and hardware from networking infrastructures for data storages and servers hiring specialized teams and individuals for each responsibility for high-level responsibilities. It was kind of a DIY (Do It All Yourself) thing.
Then the cloud came which in combination with virtualization laid the ground for Infrastructure as a service (IaaS), Platform as a Service (PaaS), and similar services which made companies and individuals happy. These technologies in trends allowed for more outsourcing and as a result more focus on the business logic. So, lead time has shortened and the creation of software from requirements gathering to production within software has become relatively easier, cheaper and quicker. Then the containerization wave came and we started to hear about deploying single instances and units that use enough resources from the host and the same thing happened, new services emerged referred to as CaaS or Container as a Service.
All of this makes deploying software easy, cheap and quick. All of which reduces the risk and increase in efficiency right? And Serverless is nothing but a step forward in this evolution of servers.
We will see with each of these advancements some concerns have been gone by outsourcing the management and maintenance of the infrastructure. But there are some other factors as well. For example, the logic required by the servers, creating server site codes that perform a lot of functionalities that are not related to the business like routing, security, authentication and authorization and more. Serverless architecture came into the picture here by building and managing the server side of our application.
Serverless is building software by focusing more on business logic without thinking about how we’re going to serve our software like there is no server, just business logic. This doesn’t mean there will not be any server-side work by developers at all. There will be still some configuration and integration work but the crowding, debugging server technologies as well as scaling and handling failovers like concerns of the developers is gone.
Serverless Architecture can be classified into two different things:
- Backend-as-a-Service (BaaS)
BaaS is all about replacing custom server-side logic with off-the-shelf services. It is like Software as a service or SaaS but for application development rather than business processes. BaaS offers generic components that can be used in an application especially as the generic back-end of a custom front-end component. Some examples of backend-as-a-Service are
- Database: Mobile application development teams found that it makes sense to connect a mobile app to the database. A BaaS database is a vendor-hosted database which removes many administrations overhead and provides authorization.
- Authentication: Many applications code their own authentication functionality like signup, login, password management, integration with other authentication providers etc. Now because these codes are very similar across many applications, products like Auth0 and Amazon Cognito exist and they already build functionality so we don’t have to build our own authentication ourselves.
Conclusively, BaaS is a generic, hosted application component that we can bundle into our own apps.
- Function-as-a-Service (FaaS)
Traditionally while deploying server-side software, we start deploying the application within the host instance. This application is an operating system process and usually contains code for several different operations. FaaS (Function as a Service) changes this type of deployment. It focuses on the operations of the application logic rather on the host instance and the application process.
Instead of a host, FaaS platform is being used. We deploy these functions to the FaaS platform as very basic code units like playing source code for java scripts. The FaaS platform is configured for each operation to listen for a specific event. When that event occurs, the vendor platform transparently creates a container for a function on demand and executes it within the container passing it a representation to the triggering event. Once the function has finished executing the FaaS platform is free to tear down the container.
Some good serverless providers:
There is many more provider of this service, with different features and functionalities which needs to be evaluated as per the requirement.
- Amazon with lambda
- Microsoft with Azure functions
- Google with Google Cloud functions
- IBM with Openwhisk
What are the benefits of serverless over the traditional method?
- We don’t need to manage provision scale services by hand. It’s a big task so its complex, we’ve to remember to patch, we’ve to remember about security all of that is abstracted away from you.
- Using services like lambda we don’t need to worry about any of those lower level concerns. We typically have to think about our architecture, our code and actually focus most of the time in solving a business problem.
Demerits to Serverless:
- Like every product or service, we’ve to know about the limitations. For example, if we use Lambda, our custom code will only run for 5 minutes. In order for some task to run longer, we’ve to go for other options.
- There is some lack of operational tools as well. For example, developers are dependent on vendors for debugging and monitoring tools. Debugging Distributed Systems is difficult and usually requires access to a significant amount of relevant metrics to identify the root cause.
Like many technologies, services, and processes, Serverless Architecture has its own pros and cons. Hence it is imperative to evaluate everything before finalizing anything.