Cloud Computing 21 min read

Understanding FaaS and Serverless with Alibaba Cloud Function Compute

This article explains the concepts of Serverless, FaaS and BaaS, demonstrates how to build and deploy a Todo List application using Alibaba Cloud Function Compute and the Midway FaaS framework, and discusses advantages, pricing, cold‑start issues, and best‑practice optimizations for serverless development.

政采云技术
政采云技术
政采云技术
Understanding FaaS and Serverless with Alibaba Cloud Function Compute

Serverless

Serverless, literally "no server", refers to a serverless architecture where developers do not need to manage physical servers; instead they use managed services provided by third‑party vendors.

In practice, serverless means that business logic runs in stateless compute containers triggered by events, while state is stored in databases or storage services.

Relation between Serverless and FaaS

Serverless = FaaS + BaaS :

FaaS (Function as a Service) : developers write function‑level business logic, event‑driven, stateless, and the platform handles deployment, scaling and operations.

BaaS (Backend as a Service) : provides common backend services such as databases, authentication, message queues, object storage, etc., which are stateful and managed by the cloud provider.

Both are needed for a complete application.

FaaS

For front‑end developers, FaaS removes the need to manage servers, domains, Nginx, and other ops tasks. Developers only focus on business logic while the platform handles the rest.

Quickly creating a FaaS app

The article uses Alibaba Cloud Function Compute to create a Todo List app (front‑end built with React, back‑end with Express). The app is deployed as a single project with both front‑end and back‑end code.

Service / Function

A service can contain multiple functions. After deployment, you can configure, delete, or view metrics for the service and its functions.

Function code

FaaS supports multiple languages (Node.js, Python, PHP, Java, etc.). Below is the core Node.js code for the Todo List API:

const
{ Server } = require('@webserverless/fc-express')
const
express = require('express')
const
fs = require('fs')
const
path = require('path')
const
bodyParser = require('body-parser')
// initial todo list
let
todos = [
  { id: '123', text: 'Go shopping', isCompleted: false },
  { id: '213', text: 'Clean room', isCompleted: true }
]
const
staticBasePath = path.join('public', 'build')
const
app = express()

app.all('/', (req, resp) => {
  resp.setHeader('Content-Type', 'text/html')
  resp.send(fs.readFileSync('./public/build/index.html', 'utf8'))
})

// static resources (js, css, png, etc.)
app.all('/*.js', (req, resp) => {
  const filePath = path.join(staticBasePath, req.path)
  resp.setHeader('Content-Type', 'text/javascript')
  resp.send(fs.readFileSync(filePath, 'utf8'))
})

// API endpoints
app.get('/api/listTodos', (req, resp) => {
  resp.send(JSON.stringify(todos))
})

app.get('/api/createTodo', (req, resp) => {
  const { todo: todoStr } = req.query
  const todo = JSON.parse(todoStr)
  todos.push({ id: todo.id, text: todo.text, isCompleted: todo.isCompleted })
  resp.send(JSON.stringify(todos))
})

app.get('/api/updateTodo', (req, resp) => {
  const { todo: todoStr } = req.query
  const targetTodo = JSON.parse(todoStr)
  const todo = todos.find(t => t.id === targetTodo.id)
  if (todo) {
    todo.isCompleted = targetTodo.isCompleted
    todo.text = targetTodo.text
  }
  resp.send(JSON.stringify(todos))
})

app.get('/api/removeTodo', (req, resp) => {
  const { id } = req.query
  const index = todos.findIndex(t => t.id === id)
  if (index !== -1) {
    todos.splice(index, 1)
  }
  resp.send(JSON.stringify(todos))
})
const
server = new Server(app)
module.exports.handler = function(req, res, context) {
  server.httpProxy(req, res, context)
}

The entry point template.yml defines the function handler and triggers.

Triggers

FaaS functions are invoked by triggers. Common trigger types include HTTP, OSS (object storage), Log Service, Timer, and API Gateway. The Todo List app uses an HTTP trigger, allowing web users to call the function via standard HTTP requests.

Pricing

FaaS follows a pay‑per‑use model: you are charged for the number of invocations and the execution time. A monthly free quota usually covers personal usage.

Cold Start

When a function is invoked for the first time, after an update, or after a period of inactivity, the platform must initialize a new instance – the "cold start" – which can add several hundred milliseconds of latency. Strategies to mitigate cold start include reducing code size, using larger memory, keeping functions warm with timer triggers, and leveraging initializer functions.

Impact on Front‑end Developers

Serverless enables front‑end engineers to build full‑stack applications without managing servers, allowing them to contribute to backend logic and accelerate delivery.

Conclusion

The article demonstrates how to quickly create a FaaS application on Alibaba Cloud using the Midway FaaS framework, explains the workflow, advantages, drawbacks, and best practices, and shows that serverless is reshaping development across web, mobile, AI, IoT, and real‑time data processing.

backendFaaSfrontendserverlessdeploymentAlibaba CloudCloud Functions
政采云技术
Written by

政采云技术

ZCY Technology Team (Zero), based in Hangzhou, is a growth-oriented team passionate about technology and craftsmanship. With around 500 members, we are building comprehensive engineering, project management, and talent development systems. We are committed to innovation and creating a cloud service ecosystem for government and enterprise procurement. We look forward to your joining us.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.