Front-end engineers naturally complement Serverless

How to build cloud native modern web applications?

Let's review how we publish a static website.

Before the cloud native era, we might think that we need to find a server, install Nginx, upload static files, and finally complete the website release through a series of configurations. After completing these tasks, I found that it had taken half a day. In fact, the time spent on operation and maintenance did not create value for our customers. But this is only the beginning. With the development of business, we need to solve the problems of stability, flexibility, security and cost one by one. We will spend more time and energy on operation and maintenance. Otherwise, this website may just be a toy.

However, with the advent of the cloud native era, it is much easier to publish static websites. We can easily host our websites through cloud products. For example, you can upload static resources to the OSS through the tools provided by Alibaba Cloud Object Storage OSS, and then enable one-click hosting. In addition, in order to enable customers to open the page more quickly, you can also set OSS as the origin of the CDN through Alibaba Cloud CDN, so that static resources are closer to customers and customers' use experience is better. These two products are pay-as-you-go and maintenance-free serverless products, which greatly reduce our various complex O&M costs. We can spend more time on R&D and experience to create more value for our customers.

But with the development of business, what if our website is not just a static website?

● API for external services (need to interface with cache, database, message queue, file storage, etc.)

● Execute tasks regularly, even massive tasks

● Send email/SMS/instant message (pin, WeChat, flybook), and make smart voice calls

● Processing of images, audio and video uploaded by users (transcoding, thumbnail, yellow identification, watermark, GPU reasoning)

● Server renders SSR page

● Fast and fast

In the face of these needs, do we have to find servers? In order to ensure the stability, flexibility, safety and cost of services, should we spend a lot of time on operation and maintenance? Is there any cloud product that can solve these back-end requirements like OSS/CDN to solve the operation and maintenance problems of static websites?

In the face of these challenges, Alibaba Cloud's Serverless product function computing FC is a good choice. In addition to processing API requests and large-scale tasks through functional computing FC, you can also access Alibaba Cloud's RDS, SLS, Tablestore, NAS and other rich cloud services or other third-party services in functional computing FC to meet the needs of storage, computing, network, security, large data, artificial intelligence and other businesses.

All kinds of Serverless cloud products are like the "arsenal" of front-end engineers. We can use these cloud products to provide high-quality services for our customers.

Introduction to the advantages and related principles of functional computing FC

Extremely elastic, easy to cope with the flow peak

Function calculation FC will automatically perform millisecond elastic expansion based on the request volume, and quickly schedule computing resources. So that we can easily deal with massive API requests and large-scale concurrent tasks.

When using function calculation, you can configure a "instance concurrency" for the function, which represents the maximum number of requests that a function instance can handle at the same time. Function instance is essentially a Linux security container, which is the smallest unit of external services provided by functions.

For example, when the "instance concurrency" is set to 20, if the function computing platform receives 100 requests at the same time, it will pull up 5 function instances to process these requests. After processing these requests, the function instance will be frozen. If there are no new requests in the next 2 to 5 minutes (the instance will not be charged after freezing), the function instance will be destroyed automatically. In some scenarios, if the business is very sensitive to delay or the business code is slow to start, you can set the minimum number of function instances by configuring elastic rules, so that the function calculation FC will start the function instances in advance to ensure the user's experience. You can also limit the maximum number of function instances by setting the maximum number of function instances to protect downstream services and control costs.

Compared with the traditional server mode, which needs to expand and shrink the capacity of the server itself, the automatic elastic method of function calculation FC can not only reduce the complex lock expansion and contraction operation, but also avoid the unavailability of business due to the untimely expansion in the traditional server mode, thus improving the stability of the system.

Reduce costs and improve resource utilization

The function calculates the specifications of CPU, memory, GPU and other instances in FC. At least 0.05 cores and 128 MB of functions can be created, and minimal gradient specification selection is provided. Basically, the application can be configured with whatever specification is required.

The function calculates the charging of FC in milliseconds. For example, if the execution time of our code business logic is 5 milliseconds, we only need to pay for the 5 milliseconds. And when there is no traffic, the function calculation FC will shrink the function instance to 0. This is very friendly to new businesses whose business volume has not yet risen, or some medium and long tail businesses whose calls are few in themselves. We do not need to pay a fixed server fee for them.

Free configuration specifications, millisecond level billing, and scaling to 0 can help us greatly improve resource utilization and greatly reduce costs.

Free of operation and maintenance, safer

In the traditional server architecture, we always need to pay attention to the resource usage of the physical machine running the application. In function computing FC, we don't need to care about the resource usage of the underlying physical machine. The function computing FC platform will automatically schedule and operate and maintain resources. However, if our business code consumes excessive resources, such as OOM, the function instance will restart automatically and the request will fail. At this time, we need to find out the problems in the code according to the monitoring indicators and logs, or modify the function specification to give more resources to the function instance.

The function calculation FC also provides the default HTTP/HTTPS domain name of the function, which is convenient for us to access the function. It also supports binding your own domain name to functions. Therefore, compared with the traditional server architecture, when using function calculation, we can avoid the operation, maintenance and purchase costs of application servers and load balancing servers.

From the perspective of security, because traditional servers need to be running all the time, when the security configuration is unreasonable or code vulnerabilities are not repaired in time. Function calculation FC will not always be running an instance, nor will it directly expose the IP on the public network, so it can avoid the occurrence of such problems that are broken by scanning.

In addition, we don't need to care about the security vulnerabilities of the operating system. When a security vulnerability occurs, the function calculation FC will complete the repair at the first time.

When other services need to be accessed, the function calculation FC will also automatically generate a temporary key according to the configuration. The validity period of this temporary key is 36 hours, so there is no need to write the important access key in the code or configuration file, thus reducing the risk caused by key leakage.

With the continuous development of business, you can also purchase Alibaba Cloud's web application firewall WAF product to protect function security.

Zero transformation, high R&D efficiency

Function calculation supports the creation of three types of functions, "built-in runtime", "custom runtime" and "container image". It also provides API, SDK, console and Serverless Devs tools to help us complete the development, construction, deployment and observation of applications.

When using the "built-in runtime", we need to write code to process requests according to the interface rules defined by the function calculation FC. For example, the following is an example of Node.js API. After using these lines of code to create functions, we can immediately use this API in our website.

When using "custom runtime", we can run applications developed by Web frameworks such as SpringBoot, Flask, Express, NextJS, NestJS, Gin, etc. on function calculation without modifying the code. You only need to configure the "port number" and "start command" for application listening in the function calculation. It is very similar to the deployment method using traditional servers. The code in the figure below should be familiar to students who are familiar with the Express framework.

When using "container image", we can completely customize the application execution environment, without learning how to update the Linux version, GCC version, install various dependencies, fonts and other issues in the function calculation running environment. In addition, because of the excellent portability of container images, we don't need to worry about being bound by cloud vendors. The same container can run on the server in the cloud or local data center, or in the Kubernetes cluster in the cloud or local data center. You can even deploy an image in the server, Kubernetes cluster and function computing at the same time, and complete disaster recovery through several different products.


Through functional computing FC and other serverless cloud products, we do not need to manage the infrastructure such as servers. Serverless cloud products will prepare resources for us, run our applications in an elastic, safe and reliable way, store our data, and provide us with other additional value.

The operation and maintenance free feature of Serverless is naturally complementary to that of front-end engineers. Front-end engineers only need to write business code to quickly build cloud-based modern web applications. Let front-end engineers focus more time on creating value for users.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us