02 the Value of Serverless

02 The Value of Serverless #

Looking back at the evolution of architecture, it is clear that developers and operations personnel are gradually shifting their focus away from managing machines.

In reality, although called “Serverless,” servers are not going to disappear completely. In the context of Serverless, the term “less” means that developers do not have to worry about servers. It’s similar to modern programming languages like Java and Python, where developers do not have to manually allocate and release memory, but the memory still exists and is managed by the garbage collector. Just as we refer to Java and Python as “Memoryless” languages, we can call a platform that helps manage servers a “Serverless” platform.

However, in the age of the cloud, we cannot narrowly define Serverless as just not having to worry about servers. Cloud resources include not only the basic computing, networking, and storage resources that servers provide, but also various higher-level resources such as databases, caches, and messaging.

The Vision of Serverless #

In February 2019, UC Berkeley published a paper titled “Cloud Programming Simplified: A Berkeley View on Serverless Computing.” The paper also provides a very clear and visual analogy. It describes:

In the context of the cloud, Serverful computing is like programming in low-level assembly language, while Serverless computing is like programming in a high-level language like Python. For example, a simple expression like c = a + b would require selecting registers in assembly language, loading values into registers, performing mathematical calculations, and storing the result. This is similar to the way Serverful computing works in the cloud today, where developers first need to allocate or find available resources, load code and data, perform calculations, store the results, and finally manage the release of resources.

The paper refers to Serverful computing as the mainstream way of using the cloud today, but it should not be the way we use the cloud in the future. I believe the vision of Serverless should be “Write locally, compile to the cloud,” meaning that code only focuses on business logic, while tools and the cloud manage resources.

The Value of Serverless #

After having an overall abstract concept of Serverless, it is also essential to understand the key characteristics of Serverless platforms, as these characteristics represent the core advantages of Serverless.

1. No need to worry about servers #

Managing one or two servers may not be much of a hassle, but managing thousands or even tens of thousands of servers is not as simple. Any server can experience failures, and it is crucial for a Serverless platform to have the ability to automatically identify and remove problematic instances. In addition, the platform needs to automatically handle security patch upgrades on the operating system without affecting the business. Default integration of logging and monitoring systems is necessary, and automatic configuration of security policies to mitigate risks is crucial. When resources are insufficient, the platform should be able to automatically allocate resources, install related code and configurations, and more.

2. Automatic scalability #

Today’s internet applications are designed to be scalable. When there are clear peak and off-peak periods in business, or temporary capacity demands (such as marketing campaigns), Serverless platforms can achieve automatic and stable scalability. To achieve this capability, the platform needs to have powerful resource scheduling capabilities and be very sensitive to application metrics such as load and concurrency.

3. Pay for actual resource usage #

Using cloud resources in a Serverful manner means paying for occupancy rather than usage. For example, if a user purchases three ECS instances on the cloud, the user will need to pay for the overall cost of these three instances, regardless of how much CPU and memory they actually use. In the Serverless model, users pay for the actual resources they use. For example, if a request actually uses a 1core2g resource for a duration of 100ms, the user only needs to pay for the price of that specific resource multiplied by the time (i.e., 100ms). Similarly, if a user is using a Serverless database, they only need to pay for the resources consumed by the queries and data storage.

4. Less code and faster delivery speed #

Code based on a Serverless architecture typically heavily utilizes backend services and separates data and state management from the code. Furthermore, the more thorough FaaS architecture hands over the code runtime management to the platform. This means that the code in Serverless mode for the same application will be much less compared to Serverful mode. Therefore, whether it is distribution or startup, Serverless code will be faster. Serverless platforms also typically provide very mature features such as code build, release, and version switching, which improve delivery speed.