What is serverless computing?
Serverless computing is a method of providing backend services on an as-used basis. A serverless provider allows users to write and deploy code without the hassle of worrying about the underlying infrastructure. A company that gets backend services from a serverless vendor is charged based on their computation and do not have to reserve and pay for a fixed amount of bandwidth or number of servers, as the service is auto-scaling. Note that despite the name serverless, physical servers are still used but developers do not need to be aware of them.
In the early days of the web, anyone who wanted to build a web application had to own the physical hardware required to run a server, which is a cumbersome and expensive undertaking.
Then came cloud computing, where fixed numbers of servers or amounts of server space could be rented remotely. Developers and companies who rent these fixed units of server space generally over-purchase to ensure that a spike in traffic or activity will not exceed their monthly limits and break their applications. This means that much of the server space that gets paid for can go to waste. Cloud vendors have introduced auto-scaling models to address the issue, but even with auto-scaling an unwanted spike in activity, such as a DDoS Attack, could end up being very expensive.
Serverless computing allows developers to purchase backend services on a flexible ‘pay-as-you-go’ basis, meaning that developers only have to pay for the services they use. This is like switching from a cell phone data plan with a monthly fixed limit, to one that only charges for each byte of data that actually gets used.
The term ‘serverless’ is somewhat misleading, as there are still servers providing these backend services, but all of the server space and infrastructure concerns are handled by the vendor. Serverless means that the developers can do their work without having to worry about servers at all.
What are the advantages of serverless computing?
- Lower costs - Serverless computing is generally very cost-effective, as traditional cloud providers of backend services (server allocation) often result in the user paying for unused space or idle CPU time.
- Simplified scalability - Developers using serverless architecture don’t have to worry about policies to scale up their code. The serverless vendor handles all scaling on demand.
- Simplified backend code - With FaaS, developers can create simple functions that independently perform a single purpose, like making an API call.
- Quicker turnaround - Serverless architecture can significantly cut time to market. Instead of needing a complicated deployment process to roll out bug fixes and new features, developers can add and modify code on a piecemeal basis.
How serverless technology works
Developers rely on serverless to execute specific functions. Because of this, cloud service providers offer Functions as a Service (FaaS). Below, you can see how functions are written and executed in a serverless way.
- The developer writes a function. This function often serves a specific purpose within the application code.
- The developer defines an event. The event is what triggers the cloud service provider to execute the function. A common type of event is an HTTP request.
- The event is triggered. If the defined event is an HTTP request, a user triggers the event with a click or similar action.
- The function is executed. The cloud service provider checks if an instance of the function is already running. If not, it starts a new one for the function.
- The result is sent to the client. The user sees the result of the executed function inside the application.
Example
Single function applications
Chatbots are popular among customer service and sales teams for communicating with customers and prospects when team members aren’t available. They’re also popular for internal communication and updates (e.g. Slack). But even though they provide substantial value, their code is relatively minimal and can often be turned into a single function.
Instead of hosting chatbot logic on VMs that are always running at capacity—even when functions are not being executed—chatbot service providers can run that logic on a serverless platform to decrease their operational costs. This way, the company is only billed when serving a request. They are not over-billed for VMs that are underutilized.
Companies can also create their own chatbots more easily and save on chatbot services. Developers can quickly create serverless bots and other internal business apps without needing to think about the backend.