Cloud Native 11 min read

How Midway Serverless Simplifies Multi‑Cloud Function Deployment

This article introduces Midway Serverless, explains its background in the serverless trend, details its architecture, directory structure, toolchain, dependency‑injection mechanism, anti‑corruption layer, lifecycle hooks, and how it enables seamless migration of traditional Node.js applications to multiple cloud platforms with minimal code changes.

Alibaba Terminal Technology
Alibaba Terminal Technology
Alibaba Terminal Technology
How Midway Serverless Simplifies Multi‑Cloud Function Deployment

Background

Serverless is rapidly gaining traction in the industry, with companies like Alibaba migrating workloads to reduce costs. Midway Serverless is presented as a framework that abstracts multi‑cloud deployment, eases migration of traditional applications, and allows code to run unchanged across different platforms.

Structure

The classic project layout is minimal: a f.yml configuration file and an index.ts logic file. More complex projects add additional directories that align with traditional coding practices.

Toolchain and Capabilities

Beyond f.yml, Midway provides faas-cli with four core commands— create, invoke, test, and deploy —covering the entire development lifecycle. Additional examples demonstrate integration with React/Vue and typical use‑cases such as Todo lists.

Principle Analysis

Midway v1 built on EggJS added an IoC container that scans user code, registers decorators, and creates a dependency graph. Each service defined in f.yml maps to a handler method, and the container lazily resolves instances at runtime.

Design

The original entry function varies across platforms. Midway Serverless inserts an anti‑corruption layer that normalizes runtime differences, handles async wrappers, and bridges the traditional Midway v1 container with the serverless execution model.

Architecture Anti‑Corruption

Platform adapters are generated from provider.name in f.yml, supporting Alibaba Cloud, Tencent Cloud, and soon AWS. The core entry point (FaaSStarter) invokes user code in src/index.ts, while asyncWrapper and asyncEvent ensure uniform async handling.

Lifecycle

The runtime defines stages such as RuntimeStart, FunctionStart, Invoke, and Close, with before and after hooks for extensibility. These hooks allow custom logic to run around each phase.

Application Migration

By adding a simple f.yml with four lines, Midway generates all necessary entry and adapter code, enabling seamless migration of legacy applications to a serverless model while preserving code structure.

Conclusion

The article covered Midway Serverless fundamentals, entry generation, lifecycle, and migration strategy, representing a portion of its anti‑corruption architecture. Future posts will explore additional aspects of the framework.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeServerlessNode.jsMidwayFunction as a Service
Alibaba Terminal Technology
Written by

Alibaba Terminal Technology

Official public account of Alibaba Terminal

0 followers
Reader feedback

How this landed with the community

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.