How to effectively deal with the elastic changing demand of computing resources?
1.1 Ancient times
Long long ago, computers were extremely scarce resources. I once communicated with a university professor. He said that at the beginning, a university's computer department might have only one computer. Computers are so scarce that at that time, even if you have money, it may not be easy to get computing resources.
This era, I would like to call it the ancient era of computing resources, which is characterized by scarcity!
1.2 Middle Ages
When I just graduated, I entered 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 are huge in size, powerful in performance and stable in operation, but they are very expensive. It is not only expensive to buy, but also the cost of the supporting machine room and operation and maintenance personnel is not low to make these large servers run normally. If large enterprises can afford it, small and medium-sized companies will be powerless.
In this era, I would like to call it the medieval era of computing resources. Its characteristic is expensive!
In 2018, when I entered a private enterprise, I found that most of the enterprises used cloud servers. The advantage of using ECS is that if the deployed program has a large amount of access, concurrency, and data, you should buy a higher configuration and more expensive one. If the deployed program is relatively simple and the number of visitors is not large, then buy a low configuration and cheaper one.
And with the development of time, you can also spend money to upgrade the configuration when the number of visits increases greatly. At the same time, if the cloud server is used, there is no need to build a separate computer room, nor to buy hardware routers, firewalls, etc., which is not high in terms of cost.
It is so delicious that small and medium-sized enterprises have begun to embrace cloud servers. I remember that when I worked in the company, there were dozens of cloud servers under management, and a number of new servers were steadily added every year.
In this era, I would like to call it the modern era of computing resources, which is characterized by high cost performance.
In fact, I have found some problems in my work for a long time, that is, our demand for computing resources is uneven in time and space.
For example, we have developed a school payment system, which is usually neglected. On the day when the school issues the payment notice, the number of system visitors is exploding. But when we buy servers, we always have to buy them according to the situation that supports the maximum number of visits. Isn't the remaining computing power usually wasted?
If there is a way to expand or shrink computing capacity flexibly according to needs, users only need to pay according to the actual calculation volume, that would be a considerable progress.
In addition, from the perspective of social development and the community with a shared future for mankind, it also greatly saves social resources and improves production efficiency. Alas, forgive me for being ignorant. Although I have always had this idea, I do not know that this is a technology that has long been implemented in the field of cloud computing. Serverless is one of the representative computing technologies. It has already come to us.
In this era, I would like to call it the contemporary era of computing resources. Its characteristics are fine and harmonious.
2. The concept of Serverless
First of all, in the literal sense, Server is the server, less is the lack, and together, there is no server. Serverless computing means that our programs are not deployed to various servers, but are directly handed over to the cloud (such as Alibaba Cloud), which helps us coordinate computing resources and perform elastic computing.
Next, let's use Alibaba Cloud Serverless function calculation to really experience it.
3. Quick experience
3.1 Product entrance
Alibaba Cloud has many products. Let me tell you the location of FC.
3.2 Creating Applications
After entering the function calculation product, we first need to create an application. An application can be understood as a background service, background project, and so on.
Alibaba Cloud has built many application templates, such as common SpringBoot, Django, Flask, etc., which are very good and powerful. Here I choose the familiar SpringBoot.
3.3 Application deployment settings
As shown in the following figure, it is set to deploy application code through the Gitgee code warehouse. This is easy to understand. Our application is directly associated with a Gitee code warehouse. If we want to deploy the application, we should first submit the code to Gitee.
Note: Click the link at the red line in the figure above, and then log in to Gitee to complete the binding authorization of Gitee code to Alibaba Cloud Serviness.
After clicking Create, the following window will pop up and wait for the creation to complete.
3.4 Writing code
When creating the project above, we specified the name of the Gitee code warehouse as [start-springboot-jc]. We cloned the warehouse to the local location and viewed the project code structure as follows:
Open the pom.xml configuration file. It is a pure SpringBoot project with version 2.1.8. Since Alibaba Cloud developers have chosen 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 modifying it!
3.5 Code deployment
Submit the code to the warehouse, and then click the red line to enter the application details:
In the deployment history, I was surprised to find that it has been automatically deployed. If you want to ask me how to find it, just look at the time. This shows that Alibaba Cloud has done a good job. It automatically discovers code updates and then automatically triggers deployment. Here is one that is worth praising!
3.6 Access test
At the top of the application details page, click to access the domain name:
The pop-up page interface is as follows, and it is complete.
4. Analysis of common use problems
4.1 How to develop your own business logic
If you are familiar with SpringBoot, this problem should be very simple.
You can configure the dependency 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 web pages, and of course some background calculations can also be displayed without web pages.
4.2 How to configure an official domain name
When the project is officially launched, we often want to use the official domain name. You can enter the function calculation homepage, click [Domain Name Management Menu], and then click [Add Custom Domain Name]:
As shown in the following figure, we can associate our domain name with the functions in the application.
4.3 Instance specification and environment configuration
Click the [Configuration] button in the red circle in [Service Management] - [Function Management].
As shown in the following figure, 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 select an instance type
Instance types are divided into three categories. The following is the official description of Alibaba Cloud. I feel that it is well written, so I won't explain it too much.
• Elastic instance: basic instance of function calculation, mainly applicable to sudden traffic scenarios, such as events, large-scale promotions and red packets.
• Performance instance: Large-scale instance with higher resource limit is mainly applicable to compute-intensive scenarios, such as audio and video processing, AI modeling and enterprise-level Java applications. When you select a performance instance, your function will run in an instance with higher computing power.
• GPU instance (in public beta): GPU instance based on Turing architecture, mainly applicable to audio and video, AI artificial intelligence, image processing and other scenarios. 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 the application-related underlying services and functions will be displayed in the application details, as shown in the following figure:
Click the function and you can see a lot of information, as shown in the figure below, you can easily see the monitoring indicators.
The following figure shows the log information:
4.6 How to perform elastic management
On the function details page, click Flexible Management - Create Rules to perform flexible management on functions by setting rules.
As shown in the following figure, you can dynamically adjust the number of instances by time or by indicator.
From the above description, we can find that Serverless function calculation, as a new form of calculation, can better cope with the scenario of computing resource elasticity changes.
From a macro perspective, the demand for computing resources of different enterprises and services is characterized by space-time imbalance. Cloud computing manufacturers can realize the reasonable allocation of computing power by dynamically scheduling resources, save a lot of idle resources, and reduce costs.
On the macro level, when the idea of a community of shared future for mankind has developed to a certain extent, basic computing capabilities can be shared among cloud computing vendors around the world. When the computing resources of a country or region are not enough in a sudden event, you can temporarily call the computing resources of other countries or regions' cloud vendors - of course, you need to pay a reasonable fee.
The R&D of Serverless is beneficial to the country and the people. The future is bright. For today's technology, we will always be full of hope - to dance in the clouds and accompany the bright years of the world.
Knowledge Base Team
Knowledge Base Team
Knowledge Base Team
Knowledge Base Team
Explore More Special Offers
50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00