As the idea of DevOps and microservices becomes more accepted in the IT industry, another new term Serverless is coming into view. Especially in April this year, two big domestic cloud service manufacturers Ali Cloud, Tencent cloud has launched their Serverless products, Serverless luoyang paper expensive. So what exactly is Serverless, and how does it relate to DevOps and microservices? This article will attempt to demystify Serverless and give you a glimpse.
1 Serverless ! = No Server
First of all, it should be clarified that Serverless does not literally mean Serverless. Instead, it means that application developers no longer need to worry about most server-related tasks, such as server purchase, application runtime environment configuration, load balancing, log collection, system monitoring, etc. All this is left to the Serverless platform, and all the application developers need to do is write the application code and implement the business logic. To avoid ambiguity, this article will reserve the use of Serverless rather than its usual Chinese translation of Serverless.
Serverless was first proposed by Amazon. The first Serverless platform was Amazon Lambda, which was launched at the end of 2014. Application developers only need to upload codes or application packages to publish an application. After that, the world’s major Cloud service manufacturers have launched their own Serverless platforms, such as Google Cloud Functions, Azure Functions, IBM Cloud Functions, as well as the aforementioned Ali Cloud function computing and Tencent Cloud Serverless Cloud Functions. In addition to Cloud service vendors, many excellent Serverless frameworks have emerged in the open source community, such as Apache OpenWhisk, Spring Cloud Function, Lambada Framework, WebTask, etc.
According to the Article Serverless Architectures, Serverless applications can be divided into BaaS and FaaS,
- BaaS: Backend as a Service. Backend can refer to any third-party applications and services, such as Firebase and Parse that provide cloud database services, Auth0 and Amazon Cognito that provide unified user authentication services.
- FaaS: Functions as a Service. Applications exist in the form of Functions and are hosted and run by third-party Cloud platforms, such as Amazon Lambda, Google Cloud Functions, etc.
This article focuses on FaaS, which is the main type currently supported by various Serverless platforms and frameworks.
2 functions are applications
When we talk about functions, what exactly are we talking about?
The FaaS function can be an application of the main function, or a simple addition function. Let’s start with a picture.
Monolith is Monolith on the left, microservices in the middle, and FaaS functions on the right. (To avoid ambiguity, the following functions are referred to as FaaS functions unless specifically specified.) Just as a single application can be divided into multiple microservices according to service modules, a microservice can also be divided into multiple functions according to usage scenarios. For example, an advertising micro-service, at least can be split into real-time bidding, display count, report query and other functions. That is, the functions in FaaS are of the same granularity as the apis in microservices. But unlike apis, under the Serverless architecture, each function is deployed independently and executed on demand. So does the split make sense? And then we look down.
3. Understand the four keys to Serverless
Serverless has the following four characteristics compared to other architectures.
3.1 Lower operating cost
Both the IDC of the past and the cloud hosting of today are essentially a monthly billing model, which means that you pay the same amount whether or not users visit your app, and whether or not you deploy your app. But with Serverless apps, you only need to pay based on the amount of resources actually used (e.g., Amazon Lambda calculates the amount of resources by memory size * computation time), or pay-as-you-go, which is similar to the pay-as-you-go model of mobile networks. So why does this model reduce operating costs?
The rectangles below the red line represent how much you would have paid for a traditional monthly plan, while the blue areas represent how much you would have paid for a pay-as-you-go plan, which is significantly lower. According to a Forbes study published in 2015, the average server utilization in a typical data center was a dismal 5 to 15 percent over the year, meaning that at least 80 percent of operating costs could theoretically be saved if all servers were Serverless.
Another hidden benefit of pay-per-flow is that any performance gains can be directly reflected in the cost of running, which makes the value of the technician even more evident.
3.2 Automatic Capacity Expansion and contraction
The second oft-mentioned feature of Serverless is automatic scaling. Previously said that function is application, a function only does one thing, can independently expand and shrink, without worrying about affecting other functions, and because of smaller granularity, expand and shrink faster. For individual applications and microservices, although automatic scaling can be achieved with the help of various container choreography technologies, there will always be a certain amount of resource waste compared with functions due to granularity. For example, if a microservice provides two apis, one of which needs to be expanded and the other does not, it is a waste of unnecessary apis to expand.
3.3 Event-driven
The function essentially implements an IPO (input-process-output) model, which is transient and ready-to-go. This is another feature that distinguishes functions from singleton applications and microservices. Whether it is single application or micro service, it is a permanent process in the system. To use a popular saying, I will be here if you come or not. Functions are not the same, neither publish any service, no request does not consume any resources, only when the request comes, will consume resources for response, service immediately release resources. Because of this, functions are a natural fit for any event-driven business scenario, such as AD bidding, authentication, timed tasks, and some emerging IoT applications.
OpenWhisk gives an IoT refrigeratorcase
3.4 Statelessness
The IPO nature of the function determines another feature of the function, statelessness. Statelessness, on the one hand, contributes to the reusability and portability of functions, but on the other hand, it incurs a performance penalty. First, functions are not resident processes, which means that they undergo a cold Boot on every request, which is a nightmare for applications written in compiled languages (Spring Boot, for example, takes at least five seconds to start even a simple Hello World application). Second, after each request is serviced, the process in which the function is located is killed, meaning that using memory for caching no longer makes sense for the function. Third, since each startup may be scheduled to a new server, any local disk-based caching techniques are no longer applicable. From the second and third points, we can see that functions can only use external memory (such as Redis, database) for caching, and the operation of external memory needs to be over the network, performance is one or two orders of magnitude worse than memory, local hard disk.
4 DevOps => NoOps
If Agile+IaaS breeds DevOps, Agile+PaaS breeds Serverless.
Now that you understand what Serverless is, let’s see how it relates to DevOps. DevOps does a lot of Dev stuff, but it’s still Ops (like a bear that looks like a cat). Serverless is different. In essence, it outsources Ops to a third-party platform, allowing Dev to focus on implementing business logic without worrying about OPs-related work. The end result is that Ops is no longer needed in most enterprises. What it has in common with DevOps is that it helps companies reduce time to market.
5 subtotal
The above is my Serverless some simple introduction, welcome you to my message board to share, and we have a move. Stay tuned for the next article, which will show you how to deploy a Serverless application based on Spring Cloud Function in Amazon Lambda.
6 reference
- Serverless Architectures
- What makes serverless architectures so attractive?
- InfoQ Virtual Workshop: A practical approach to serverless computing
- Serverless cloud function architecture refined solution
- How does the late arrival of Serverless help microservices and DevOps