Author: Programmer Dayang (independent developer)
Source: This article is selected from the Serverless Function Computing Evaluation Activity Call for Papers
1. History of the computing arena
1.1 Ancient times
long long ago, computers were an extremely scarce resource. I once communicated with a professor at a certain university, and he said that in the beginning, the computer department of a university may only have one computer. Computers were so scarce that computing resources at that time could not be easily obtained even if you had money.
This era, which I would like to call the ancient era of computing resources, is characterized by scarcity!
1.2 The Middle Ages
When I just graduated, I joined a large state-owned commercial bank to work in information technology. The first time I walked into the computer room, I was shocked by the rows of server computers. Looking at the flashing lights of those servers from time to time, I can imagine that they support tens of billions, hundreds of billions, and trillions of capital flows.
They're huge, powerful, and stable, but—well—very expensive. Not only is it expensive to purchase, but to keep these large servers running normally, the cost of supporting computer rooms and operation and maintenance personnel is not low. Large enterprises can afford it, but small and medium-sized companies are powerless.
This era, which I would like to call the Middle Ages of computing resources, is characterized by being expensive!
1.3 Modern and modern
In 2018, I entered a private enterprise, and I found that the enterprise basically used cloud servers. The advantage of using a cloud server is that if the deployed program has a large amount of access, high concurrency, and a large amount of data, then buy the one with higher configuration and higher price. If the program to be deployed is relatively simple and the number of visitors is not large, then buy the one with lower configuration and cheaper.
And with the development of time, when the number of visits increases greatly, you can also spend money to upgrade the configuration. At the same time, if the cloud server is used, there is no need to build a separate computer room, and there is no need to buy hardware routers, firewalls, etc., and the cost is not high.
It is simply too fragrant, so small and medium-sized enterprises have begun to actively embrace cloud servers. I remember when I was working in the company, there were dozens of cloud servers under management, and several new ones were added every year.
This era, I would like to call it the modern era of computing resources, is characterized by high cost performance.
1.4 Contemporary
In fact, in my work, I discovered some problems a long time ago, that is, our demand for computing resources is uneven in time and space.
For example, we developed a payment system for schools. Usually no one cares about this system. When the school issued the payment notice, the number of visitors to the system exploded. But when we buy a server, we have to buy it according to the situation that supports the maximum number of visits. Isn't the remaining computing power usually a huge waste?
If there is a way to flexibly expand or contract computing power as needed, and users only need to pay for the actual computing volume, that would be a considerable improvement.
In addition, from the perspective of social development and a community with a shared future for mankind, this also greatly saves social resources and improves production efficiency. Hey, forgive my ignorance, although I have always had this idea, but I don't know that this is a technology that has long been realized in the field of cloud computing. Serverless is one of the representative computing technologies, and it has already come to us.
This era, which I would like to call the contemporary era of computing resources, is characterized by finesse and harmony.
2. The concept of serverless
Let’s understand it literally. Server is a server, less is a lack, and together it means no server. Serverless computing means that our programs do not need to be deployed to various servers, but are directly handed over to the cloud (such as Alibaba Cloud), and the cloud helps us coordinate computing resources and perform elastic computing.
Next, let's use Alibaba Cloud Serverless Function Computing to really experience it.
3. Quick experience
3.1 Product Entry
Alibaba Cloud has many products. Let me first tell you the location of the function calculation FC.
3.2 Create an application
After entering the Function Compute product, we first need to create an application. An application can be understood as a background service, a background project, etc.
Alibaba Cloud has many built-in application templates, such as the common SpringBoot, Django, Flask, etc., which are very good and powerful. Here I choose the more familiar SpringBoot.
3.3 Application Deployment Settings
As shown in the figure below, it is set to deploy application code through the Gitgee code repository. This is easy to understand. Our application is directly associated with a Gitee code repository . If we want to deploy the application, we must submit the code to Gitee first.
Note that you can complete the binding authorization of the Gitee code to Alibaba Cloud Serveless by clicking the link in the red line in the above figure, and then logging in to Gitee.
After clicking Create, the following window will pop up, wait for the creation to complete.
3.4 Writing code
When creating the project above, we specified the name of the Gitee code repository [start-springboot-jc], we cloned the repository to the local, and viewed the project code structure as follows:
Open the pom.xml configuration file, familiar feeling, this is a pure SpringBoot project, version 2.1.8. Since Alibaba Cloud developers chose this version, it should be very stable and excellent.
Next, look at the startup class, we can easily guess that welcome is the default entry for our application.
Come on, how can I witness the style of my generation of Java full-stack programmers without making some changes!
3.5 Code Deployment
Submit the code to the warehouse, and then click the red line to enter the application details:
The surprising discovery in the deployment history has been automatically deployed. If you want to ask me how I found it, just check the time. This shows that Alibaba Cloud has done a good job. It automatically discovers code updates and triggers deployment automatically . One of them is worthy of praise!
3.6 Access test
At the top of the app details page, click Visit Domains:
The pop-up web interface is as follows, and you're done.
4. Analysis of common usage problems
4.1 How to develop your own business logic
If you are familiar with SpringBoot, this question should be simple.
You can configure dependencies in pom.xml, then write the service class, and finally call the encapsulated service class in the welcome method. The running results can be displayed through the web page, and of course some background calculations can also be displayed without the web page.
4.2 How to configure the official domain name
When the project is officially launched, we often want to use the official domain name. You can enter the Function Compute home page, click [Domain Name Management Menu], and then click [Add Custom Domain Name]:
As shown in the figure below, we can associate our domain name with the functions in the application.
4.3 Instance Specifications and Environment Configuration
In [Service Management] - [Function Management], click the [Configure] button in the red circle.
As shown in the figure below, you can configure instance specifications and environment information, such as memory, concurrency, and instance type.
Note that memory refers to the maximum memory for function execution, and concurrency refers to how many requests the function can handle at the same time .
4.4 How to choose an instance type
Instance types are divided into three categories. The following is the official description of Alibaba Cloud. I think it is well written, so I will not explain too much.
- Elastic instance: A basic instance of Function Compute, which is mainly suitable for sudden traffic scenarios, such as events, large-scale promotions, and red envelopes.
- Performance instance: Large-scale instance, with a higher resource limit, is mainly suitable for computing-intensive scenarios, such as audio and video processing, AI modeling, and enterprise-level Java applications. When you choose a performance instance, your function will run on an instance with higher computing power.
GPU instance (in public beta): A GPU instance based on the Turing architecture, which is mainly suitable for scenarios such as audio and video, AI artificial intelligence, and image processing. In different scenarios, different business loads are sunk to GPU hardware acceleration, which greatly improves the efficiency of business processing.
4.5 How to monitor and view logs
Note that in the application details, the underlying services and functions related to the application will be displayed, as shown in the following figure:
Click on the function, you can see a lot of information, as shown in the figure below, you can easily see the monitoring indicators.
The following figure is the log information:
4.6 How to manage flexibility
On the function details page, click [Flexibility Management] - [Create Rules], and you can manage functions flexibly by setting rules.
As shown in the figure below, the number of instances can be dynamically adjusted by time or by indicator.
5. Summary
After the above description, it can be found that serverless function computing, as a new form of computing, can better cope with the scenarios of elastic changes of computing resources.
From a macro perspective, the demand for computing resources of different enterprises and services is characterized by an imbalance in time and space. Cloud computing vendors can dynamically allocate resources to achieve reasonable allocation of computing capabilities, save a lot of idle resources, and reduce costs.
From a macro perspective, when the idea of a community with a shared future for mankind develops to a certain extent, basic computing capabilities can be shared among various cloud computing vendors around the world. When the computing resources of a certain country or region are not enough under a certain unexpected event, the computing resources of cloud vendors in other countries and regions can be temporarily invoked—of course, reasonable payment is required.
The research and development of serverless products is beneficial to the country and the people. The future is bright, and we are always full of hope for today's technology - may the clouds dance gracefully and accompany the world in a bright future.
For more content, pay attention to the Serverless WeChat official account (ID: serverlessdevs), which brings together the most comprehensive content of serverless technology, regularly holds serverless events, live broadcasts, and user best practices.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。