Serverless computing is a cloud computing execution model that lets software developers build and run applications and servers without having to provision or manage the back-end infrastructure. With serverless, the cloud vendor takes care of all routine infrastructure management and maintenance, including updating the operating system (OS), applying patches, managing security, system monitoring and planning capacity.
With serverless computing, developers purchase back-end services from cloud services vendors on a pay-as-you-go basis, which means they pay only for the services used. The main goal of serverless computing is to make it simpler for developers to write code designed to run on cloud platforms and to perform a specific role.
How serverless computing works?
With serverless computing, developers don’t have to deal with managing machine instances in the cloud. Instead, they can run code on cloud servers without having to configure or maintain the servers. Pricing is based on the actual amount of resources consumed by an application rather than on pre-purchased units of capacity.
Typically, if developers host their applications on virtual servers based in the cloud, they must set up and manage those servers, install OSes on them, monitor them and continually update the software. With a serverless model, developers can write a function in their favorite programming language and post it to a serverless platform. The cloud service provider manages the infrastructure and the software, and maps the function to an application programming interface (API) endpoint, transparently scaling function instances on demand.
Advantages and disadvantages of serverless computing
The advantages of serverless computing include the following:
- Cost-effectiveness. Users and developers pay only for the time when code runs on a serverless compute platform. They don’t pay for idle virtual machines (VMs).
- Easy deployment. Developers can deploy apps in hours or days rather than weeks or months.
- Autoscaling. Cloud providers handle scaling up or spinning down resources or instances when the code isn’t running.
- Increased developer productivity. Developers can spend most of their time writing and developing apps instead of dealing with servers and runtimes.
The disadvantages of serverless computing include the following:
- Vendor lock-in. Switching cloud providers might be difficult because the way serverless services are delivered can vary from one vendor to another.
- Inefficient for long-running apps. Sometimes using long-running tasks can cost much more than running a workload on a VM or dedicated server.
- Latency. There’s a delay in the time it takes for a scalable serverless platform to handle a function for the first time, often known as a cold start.
- Debugging is more difficult. Because a serverless instance creates a new version of itself each time it spins up, it’s hard to amass the data needed to debug and fix a serverless function.
Serverless computing use cases
There are numerous use cases for serverless computing:
- Event-triggered computing. For scenarios that involve numerous devices accessing various file types, such as mobile phones and PCs uploading videos, text files and images.
- Internet of things (IoT) data processing. Serverless computing provides a way to combine and analyze data from a variety of devices and then trigger the desired events, offering a highly functional, less expensive way to manage IoT.
- Back-end tasks for mobile apps or websites. A serverless function can take a request — such as for information from a user database — from the front end of the site or application, retrieve the information and hand it back to the front end.
- High-volume background processes. Serverless can be used to transfer data to long-term storage; convert, process and analyze the data; and move metrics to an analytics service.
- Microservices support. Supporting microservices architectures is one of the most common uses of serverless computing. Although developers can use containers or platform as a service (PaaS) to build and operate microservices, they can also use serverless computing because of its inherent and automatic scaling, rapid provisioning, attributes around small bits of code, and pricing model that only charges for the capacity used.
- Building RESTful APIs. Serverless computing makes it easier to build RESTful APIs developers can scale up on demand.
- Video and image manipulation. Serverless computing enables developers to modify video transcoding for different devices and to resize images dynamically.
- Writing multilanguage apps. When developers create applications, one of the first factors to consider is what language to use. Since serverless is a polyglot environment, developers can write code in any language or framework they choose, including Python, Node.js, Java and JavaScript.
- Continuous integration/continuous delivery (CI/CD). CI/CD pipelines let developers ship small bits of code, which means they can ship bug fixes and other updates every day. Serverless architectures can automate many of the workflows in developers’ CI/CD pipelines — for example, pull requests triggering automated tests.