Talk about Serverless, which is naturally complementary to front-end engineers

As front-end engineers, our mission is to provide users with a good front-end user experience. With the arrival of the cloud native era, it is obvious that we can do more. Serverless products are characterized by maintenance free, pay as you go and adaptive flexibility. Therefore, we can use various serverless capabilities on the cloud to develop cooler products at a relatively lower cost and create more value for our customers.

How to build a cloud native modern Web application?

Let's review how we published a static website.

Before the cloud native era, what we thought might be that we need to find a server, install Nginx, upload static files, and then complete the website publishing through a series of configurations. After completing these tasks, we 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 just the beginning. With the development of the business, we need to solve the problems of stability, elasticity, security and cost one by one. We will spend more and more time and energy on operation and maintenance. Otherwise, the website may be just a toy.

But with the arrival 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 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 have a better experience. These two products are both volume based 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 our 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 (nailing, WeChat, Feishu) and call smart voice phone

• Processing pictures, audio and video uploaded by users (transcoding, thumbnail, yellow identification, watermarking, GPU reasoning)

• Server side rendering of SSR pages

• Push and kill

• Collect users' behaviors on the website and analyze how to improve users' conversion rate

Faced with these demands, do we have to go to the server again? In order to ensure the stability, flexibility, security and cost of services, do we have to spend a lot of time on operation and maintenance? Is there a cloud product that can solve our back-end needs as OSS/CDN solves the operation and maintenance 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 just like "weapons repositories" for front-end engineers. We can use these cloud products to provide our customers with high-quality services.

Introduction to advantages and related principles of FC by function calculation

Extremely elastic, easy to deal with peak flow

Function computing FC will automatically perform millisecond elastic expansion according to 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 an "instance concurrency" for the function, which represents the maximum number of requests that a function instance can process at the same time. The function instance is essentially a Linux security container, which is the smallest unit for functions to provide external services.

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 (after the instance is frozen, there will be no billing), the function instance will be automatically destroyed. In some scenarios, if the business is very sensitive to delay or the business code starts slowly, you can set the minimum number of function instances by configuring elastic rules, so that 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 requires you to expand and shrink the server capacity yourself, the automatic elasticity method of FC calculation can not only reduce such complex lock expansion and reduction operations, but also avoid the business unavailability caused by the untimely expansion in the traditional server mode, thus improving the stability of the system.

Reduce costs and improve resource utilization

Function to calculate the specifications of CPU, memory, GPU and other instances that can be configured freely in FC. At least, functions with 0.05 cores and 128 MB can be created, and the specification selection of minimal gradient is provided. Basically, you can configure any specification required by the application.

FC billing is at the millisecond level. For example, if the execution time of our code business logic is 5 milliseconds, we only need to pay for the 5 milliseconds. In addition, when there is no flow, the function calculation FC will shrink the function instance to 0. This is very friendly to new businesses that have not yet started their business volume, or to medium and long tail businesses that have few calls themselves. We do not need to pay a fixed server fee for them.

The features of free configuration specifications, millisecond billing, and capacity reduction to 0 can help us greatly improve resource utilization and greatly reduce costs.

Operation and maintenance free, more secure

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

FC also provides the default HTTP/HTTPS domain name of the function, so that we can access the function easily. It also supports binding your domain name to functions. Therefore, compared with the traditional server architecture, when using function computing, we can eliminate 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, hackers can find and attack servers by scanning IP and ports when the security configuration is unreasonable or code vulnerabilities are not repaired in time. Function computing FC will not always serve as an instance, nor will it directly expose the IP to the public network, so it can avoid such problems that are attacked by scanning.

In addition, we don't need to care about the security vulnerabilities of the operating system. When a security vulnerability occurs, FC will complete the repair as soon as possible.

When it is necessary to access other services, FC will also automatically generate a temporary key according to the configuration. The validity of this temporary key is 36 hours, so it is unnecessary to write important access keys 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 Web Application Firewall WAF products 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". API, SDK, console and Serverless Devs tools are provided to help us complete application development, construction, deployment and observation.

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

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

When using "container image", we can completely customize the execution environment of the application without learning how to update the Linux version, GCC version, installation of various dependencies, fonts, and other issues in the function calculation running environment. In addition, because the container image has excellent portability, we do not have to worry about being bound by the cloud manufacturer. The same container can run on the server of the cloud or local data center, or in the Kubernetes cluster of 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.


By calculating the function of FC and other Serverless cloud products, we do not need to manage the server and other infrastructure. The Serverless cloud products will provide us with resources, run our applications in an elastic, secure and reliable way, store our data, and provide us with other additional value.

The O&M free feature of Serverless is naturally complementary to that of front-end engineers, who can quickly build cloud native modern Web applications by writing business code. 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