Finally, the next evolutionary stage in our units of compute is functions. While containerization technologies such as Docker are commonplace in cloud-native applications, we can take another step further by dividing our applications into discrete functions. Function as a Service (FaaS) is another level of abstraction and is where we get to choose the runtime to execute our code on, some execution parameters such as memory allocation, and that's about it. The hardware, operating system, and runtime are all managed for you.
Martin Fowler at https://martinfowler.com/articles/serverless.html says, "Fundamentally, FaaS is about running backend code without managing your own server systems or your own long-lived server applications.":
Functions running on an abstracted runtime (FaaS)
AWS was the first to release their FaaS service, called AWS Lambda in 2014, and a lot of this book is focused around this service as a core building block for applications.
There are many reasons and benefits behind running serverless compute, as follows:
- You don't pay for idle resources. This means you only pay when your code is running.
- The scale is instantaneous and continuous—you can run multiple instances of the same code in a parallel.
- A sequential batch process running on a server has a ceiling of the maximum throughput of that server's resources. With serverless, this process could be executed in parallel, saving the cost of processing time while getting the results sooner. Our unit of scale here is at the function level, so we can scale relative to the size of the workload.
One of the biggest shifts that is most pertinent to me is that serverless means developers can focus more on building the code that directly relates to outcomes for the business. Developers don't have to grind their gears understanding how to harden their operating system, how to maintain configurations across platforms, or how to tune an application server to get the most performance out of their runtimes.
The tasks of system administration and operations have also changed significantly. With the complexities of the platform abstracted away, the traditional tasks to do with making sure the underlying infrastructure is available has shifted. Instead, serverless operations are more focused on proactive tasks such as monitoring service latency or observing transactions to ensure they are being completed using meaningful data.
I believe that the future of modern organizations lies in the minds and capabilities of visionary developers, and serverless compute reduces the complexities of turning their ideas into reality.
Functions can be deployed in milliseconds and typically live for seconds. Long-running processes may not be the best fit for a serverless workload, but we'll get to this later. Next, let's learn how our evolutions in hardware abstraction have influenced software architectures.