Serverless programming has been a buzzword in technology for a while now, first implemented for arbitrary code by Amazon on Amazon Web Services (AWS) in 2014, and first spoken about two years before that. The term normally refers to snippets of backend code running in environments that are wholly managed by the cloud provider, totally invisible to developers. This approach has some astounding benefits, enabling an entirely new paradigm of computing architecture. Now, let's understand the benefits and drawbacks of serverless computing.
Following are the benefits of serverless computing:
- Speed of development
- Zero management (near)
- Cost/cost flexibility
- Auto-scaling
Following are the drawbacks of serverless computing:
- Warmup latency
- Vendor lock-in
- Lack of control for specific use cases
Serverless code can be scaled to handle as much demand as your cloud provider's data center can handle—it is essentially infinite for all but the most demanding applications. However, the real key is elastic, unmanaged scaling. Rather than having to manually set the scale at which your code is running (for example, by spinning up extra virtual machines), serverless code will react to the demand, and scale appropriately. This means that you are charged according to computing resource usage, rather than paying in advance for a scale that you might need for an expected spike of users. It also means that serverless code needs no active management whatsoever—only monitoring. This has some profound impacts, and leads to an architecture that tends toward the microservices approach.
We will introduce this new architecture from the bottom up, starting by creating serverless code, and then building a serverless application. Our first objective will be to create a simple RESTful API with serverless code, before venturing into more interesting and unusual architectures that are unique to serverless code. This book will focus on Microsoft's serverless product Azure Functions.
By the end of this chapter, you will be able to:
- Identify the benefits and drawbacks of serverless computing
- Create an Azure Function
- Debug an Azure Function locally
- Deploy an Azure Function
- Explain the Azure Functions runtime