What is a Serverless
First of all, we need to correct a misunderstanding. Many people will think that Serverless is the concept of the front end, and it is Serverless that makes the front end go deep into the business side. But in fact, Serverless can still make the business side carry out an architectural innovation. Serverless is an architectural pattern, or platform capability, and the architecture itself is language – free.
Severless literally means no service, and the actual service here refers to the server. Now when we develop applications, whether monolithic or microservice, we need to deploy our code to a server, whether that server is physical or logical. But no piece of code can run in a vacuum, so serverless doesn’t mean we don’t need physical machines anymore, it just means we developers can stop caring about the state of the server. Even though we now hand over server management to operations, developers still need to care about the state of the server, which I believe all application developers recognize.
Before explaining why Serverless does not require a user managed server, the concepts of Baas and Faas need to be explained here. Backend as a Service (Baas) is a collection of apis, similar to a two-party package. Baas provided by a third party can be used for message notification and data analysis. Function as a Service (Faas) refers to a Function that is a Service. A Function is a piece of business logic code triggered by events. It can be considered as a method in our application. We can host a piece of business logic code to the Faas platform, which can be run and served by the computing container provided by the platform. We only need to provide the conditions and parameters triggered by the event, and we can execute this code without deploying the application.
Serverless is now commonly thought of as a combination of Baas and Faas. Faas is very flexible and easy to use, but very simple. When combined with Baas, it can provide quite powerful functions, and even migrate the whole application to Serverless platform
Now we can know why there is no need to care about the concept of server under Serverless, because under the architecture mode of Serverless, our code will be hosted and run in a third-party container, which is equivalent to the cloud computing vendor helping us to do the operation and maintenance work, and the third-party can not let us take over the container. This naturally shields developers from the server concept.
The advantage of the Serverless
Reduce operation and maintenance costs
One obvious advantage of Serverless is that it frees ops developers from the burden of servers. The burden on the operations staff was obviously lightened as their work was transferred to the Serverless platform. For developers, it allows them to focus on developing business logic rather than worrying about whether the application will run well on the server
Improving r&d efficiency
When the scale of the application reaches a certain point, software deployment becomes a burden. It takes an average of 5-10 minutes for a code change to be delivered to the server and deployed. Because much of the logic is difficult to unit test, a lengthy release process is required to validate the code. Faas applications are inherently flexible and portable. We deployed a single function on the Faas platform, and it took only a few tens of seconds from submission to deployment, compared to the deployment time of a large application.
Stronger ability to expand
Since we no longer have to worry about the server, the elastic scaling problem is left to the cloud vendors to solve. Serverless is naturally containerized, and due to the flexible and agile deployment of Faas, rapid expansion can be achieved in a short time. Because Faas applications are stateless and contain only business logic, natural scaling is much stronger than traditional applications.
Development under the Serverless architecture
In the Serverless architecture, instead of developing individual applications or services, we develop a series of functions. We can split a complete business service into a series of logical code segments, as shown in the figure below. We split the service in the application server into a series of functions, which are hosted and run on the Serverless platform.
Is Serverless perfect
Admittedly, Serverless architecture has obvious advantages both for cluster management and r&d efficiency. The concept of cloud native, which has been hot in recent years, seems to lead a software development industry innovation just as microservices replaced individual applications. But even now, one architectural approach is not necessarily superior to the other. Although it has been 6 years since Amazon officially announced AWS Lambda commercialization in 2014, Serverless architecture is still not widely applied by any company. At least at present, Serverless still has the following defects
An untrusted third party
Although at present many domestic companies will host their servers in Ali Cloud, Tencent cloud and other cloud manufacturers, but it is only similar to entrust cloud manufacturers to help manage the computer room. In the Serverless architecture, the company’s developers need to develop functions on the Faas platform and submit them for deployment. All the processes are handed over to the third party for maintenance, and the developers only need to care about the business logic. It’s hard to say whether it’s a good thing to not have users care about the server, and at least for now, no cloud vendor can guarantee that the process won’t run into problems.
In fact, most companies do not have the ability of operation and maintenance. If the management is handed over to a third party, the operation and maintenance accidents will obviously be greatly reduced. As for why third parties can’t be trusted, it goes back to the question of autopilot, which can prove a lower accident rate than people, but as long as it’s not 0%, it’s still useless. What’s more, Serverless is still immature, and whether third-party cloud vendors have enough capacity to protect tens of thousands of users is still unknown
Stateless applications
As mentioned above, Faas itself is stateless. We can think of it as a function method, receiving parameters -> executing logic -> returning results. Our stateful services such as data storage need to rely on the Baas capability provided by the platform, which is actually bound to the cloud vendor. Functions also sometimes need to share data, which works well in traditional applications, but needs to be carefully designed under the Serverless architecture.
For developers, stripping out stateful and stateless services is difficult if they want to migrate their applications to the Serverless architecture, leaving aside zero-based projects. For a large project, the performance gains that Serverless can bring are dwarfed by the problems and difficulties associated with migrating to a Serverless architecture
Do we really need Serverless
The concepts of Serverless and cloud native, while not fully developed, are not far-fetched. In terms of development and operation, Serverless benefits are quite obvious, but at present I think it is suitable for some simple and lightweight services. Many people will say that Faas is not suitable for heavy traffic, which is a misunderstanding. On the contrary, Faas naturally fits this scenario. In practice, some functions such as data mapping, code parsing, or frequently changing stateless methods could be migrated to the Serverless platform.
All in all, cloud native is definitely the future, but for now I’m still on the fence. It is obviously not feasible to migrate traditional applications rashly, but for some emerging projects or simple scenarios, you can try Severless first, only to hear others say that it is not reliable, always use yourself before you can know the real benefits and disadvantages of Severless.
🏆 issue 7 | all things can be Serverless technology projects