A Serverless with FaaS

Serverless is a cloud Computing concept that stands for Serverless Computing:

Serverless suggests that the cloud user simply writes the code and leaves all the server provisioning and administration tasks to the cloud provider.

All the configuration management work related to the Server is handed over to the cloud provider, so users do not have to spend a lot of energy to manage the Server (or cloud resources), so it is called Serverless

Function as a Service (FaaS) is the key to Serverless:

The core of Serverless is Function as a Service (FaaS). However, cloud platforms usually provide the Serverless framework to meet specific application requirements, such as Backend as a Service (BaaS). Therefore, it can be simply understood as:

Serverless computing = FaaS + BaaS

Cloud programming is greatly simplified by Cloud functions providing routine computing, supplemented by a specific BaaS product ecosystem (such as object storage, databases, messaging mechanisms, etc.) where users focus on implementing their functional logic

This may sound like a bit of a fantasy, but as of today (2020/7/5) there are already a number of relatively mature FaaS products on the market

2. FaaS products already on the market

AWS Lambda

Amazon launched its AWS Lambda service back in 2015:

AWS Lambda – Run code without thinking about servers. Pay only for the compute time you consume.

Cloud computing services that run the code directly, regardless of the server, and charge for the computing time used

That is, developers just need to upload the code, and Lambda automatically handles all the work needed to run the code and extend it for high availability:

Just upload your code and Lambda takes care of everything required to run and scale your code with high availability.

The main application scenarios include:

  • The data processing

  • Real-time file processing: creating thumbnails, converting video code, processing logs, etc

  • Real-time data flow processing: for example, tracking user access metrics

  • Machine learning: Preprocessing data before feeding it into a machine learning model

  • Back end: Handles Web, mobile, Internet of Things (IoT) and third party API requests

Free trial packages are also available for small customers:

  • AWS China (Ningxia) Free package: 25GB NoSQL database + 1 million requests per month cloud function free forever

  • AWS Overseas Account free package: Same configuration, free forever

Ali cloud FC

Ali Cloud also provides FaaS solution, called function calculation:

Function computing – Ali Cloud function computing is an event-driven, fully hosted computing service. With functional computation, you don’t need to manage infrastructure such as servers; you just write code and upload it. Functional computing prepares the computing resources for you, runs your code in an elastic, reliable manner, and provides logging queries, performance monitoring, alarms, and more. With functional computing, you can quickly build any type of application or service without the need for administration and operation. Also, you only pay for the resources that the code consumes when it actually runs, not when it doesn’t.

The application scenarios are as follows:

  • Low-cost cross-border file transfer: large-scale file synchronization

  • File processing: For example, compress/decompress, transcode, and watermark files uploaded to OSS

  • Front-end CI/CD system: Webhook notification triggers cloud function, uploads front-end code base to OSS, and implements CDN deployment

  • Log ETL processing: processing and delivering data

  • Smart home appliances: Smart home, App to get weather, environmental index

  • Small and medium sites: such as serverless website based on functional computing + wordpress

Free packages are also available for small customers (teams of 1-10) :

  • Free Cloud Development

However, the free amount is not transparent, and a fee may be charged later

P.S. In addition, there seems to be no free quota for OSS provided by Ali Cloud, so please pay attention to the trial

Tencent cloud SCF

FaaS product provided by Tencent Cloud is SCF (Serverless Cloud Function) :

SCF – Serverless Cloud Function (SCF) is a Serverless execution environment provided by Tencent Cloud for enterprises and developers, helping you run code without purchasing and managing servers. You only need to use the language supported by the platform to write the core code and set the conditions for the code to run, so that the code can run flexibly and safely on Tencent cloud infrastructure. SCF is an ideal computing platform for real-time file processing and data processing.

Four main application scenarios:

  • Real-time file processing: e.g. audio/video transcoding

  • Data ETL processing: Concurrent analysis and processing for large data sets (ETL stands for typical extract-transform-load data processing)

  • Mobile and Web application backends: Implement back-end services in the form of cloud functions

  • AI reasoning prediction: after the AI model is trained, it provides reasoning services externally

Say to have certain free amount every month, but outside net flow is not free, try to play need cautious

What does FaaS bring to the front end?

Having FaaS means being able to:

Directly run the back-end code, without considering the server and other computing resources and service scalability, stability and other issues, even log, monitoring, alarm and other supporting facilities are also out of the box

That is, launching a simple back-end service (such as interface aggregation, data orchestration) does not require the help of an experienced professional back-end engineer:

  • Select Technology stack

  • Consider scaling mechanisms for high concurrency

  • Estimate peak flow, pre-allocate resources (application machine)

  • CI/CD process

  • Access the monitoring, operation and maintenance system

We only need to provide a piece of code, and the FaaS scheme carefully developed by the cloud provider helps us select the best practices of the technology stack corresponding to the programming language. Based on the built-in extension mechanism, we can dynamically expand computing resources according to actual needs, easily deploy services to the public network, and provide reliable monitoring and alarm guarantee

Feed FaaS a function and you can launch a highly available service. The professional requirements of (simple) service interface development are reduced, and the front-end has more room to play, including but not limited to:

  • BFF (Backend For Frontend)

  • SSR (Server-side Rendering)

  • End-to-end cloud integration development

BFF

Backend For Frontend (BFF) is not a new concept:

One Backend per user Experience Is used for each user experience.

In other words:

BFF is specific to the user experience and is implemented and maintained by the front-end team that implements this part of the UI (i.e., the UI and corresponding BFF are the same team)

In 2018 (and even earlier) there were teams exploring and practicing BFF based on Node.js, with front-end module developers responsible for some interface development work on the corresponding BFF layer

With the BFF layer, back-end engineers can focus on the business domain, but it puts higher requirements on front-end engineers: front-end full-stack engineers are needed, and with the development of BFF layer, the requirements are higher and higher (scalability, stability, etc.).

The emergence of FaaS solves this problem well. The BFF concept is upgraded to SFF (Serverless For Frontend), which encapsulates the part of the back-end service framework with high professional requirements into FaaS solutions. Transfer of availability assurance outside of business logic in BFF from front-end engineers to back-end domain experts at cloud vendors, making each other more professional and efficient

SSR

SSR (Server Side Rendering) is also not a new concept:

Generate a complete HTML page on the server side

It saves the network overhead of the client’s second request for data and the performance burden of rendering the view template, which helps to speed up the first screen loading. However, SSR also faces similar problems with BFF. It is not difficult to set up a demo-level SSR rendering service, but it is not easy to put on line a highly available SSR rendering engine

FaaS brings the high availability requirements of services within reach, and stateless template rendering is particularly suited to cloud functions

Some Serverless Side Rendering schemes have emerged in the P.S. community, such as YKFE/SSR

End-to-end cloud integration development

That is, the integration of front and back end development, in a single project, can not only complete the front-end display requirements, but also can solve the data service

What is the difference between PHP and Java Web site development? Are we back to square one?

Obviously not. The main differences are:

  • Hierarchical decoupling of front and rear ends: The front and rear ends are integrated, but not overly coupled

  • The back-end project is the body: Unlike PHP or Java Web, the back-end part is the body

  • Not just on the Web, but on mobile as well

Integration is embodied in:

  • A cloud IDE based development/debugging environment for a seamless development experience

  • Focus on the front end and (almost) ignore the deployment, operation and maintenance of back-end services

P.S. currently has FaaS+React/Vue integrated development framework, such as MidwayJS/Midway

Possibilities for the future

Going forward, FaaS may also bring these changes:

  • There are more and more free/cheap solutions for small customers: small program cloud, IoT development packages, etc

  • Faas-based Web services frameworks tend to be unified with traditional Web services frameworks: applications based on traditional Web services frameworks can be migrated at a low cost

  • Different front-end rendering modes such as SSR, CSR/NSR have become the configuration options of the Web front-end framework: they can switch flexibly between different rendering modes and even mix them

  • The front end enters the all-cloud R&D mode: the popularization of FaaS and the maturity of BaaS ecology accelerate the popularity of SSR and BFF, and pull the front end development from the local environment to the cloud

Are you, are you ready?

It is good to have gained and confused

Follow the “front end back” wechat official account and you will receive a series of “heart original” high-quality technical articles on topics including but not limited to front-end, Node.js and server-side technologies

This article was originally published on ayqy.net. The original link is www.ayqy.net/blog/faas-a…