All Products
Search
Document Center

Function Compute (2.0):Use fc-canary to perform canary release

Last Updated:Oct 30, 2023

By default, after a function is updated, the updated configurations and code are released and overwrite the LATEST version. If the function is directly invoked after the function is updated, the latest configurations and code of the LATEST version are used. To ensure stability in production environments, the community provides the fc-canary plug-in, which you can use to perform canary release. This topic describes how to use the fc-canary plug-in to perform canary release.

Use the fc-canary plug-in

Function Compute provides aliases to separate deployments from releases to ensure the stability of production environments. In an online environment, you can configure an alias and point the alias to a version. When you publish a new version, you can point the alias to the new version. When you point the alias to the new version, you can enable the canary release feature and direct only a specific amount of invocations to the new version to verify the new version before you officially release the new version.

If you use the fc-canary plug-in to perform canary release, you must perform the deployment first. The plug-in releases a stable version based on the latest configurations and code (LATEST version), and then updates the settings of the alias. If the alias does not exist, the plug-in creates an alias based on the target version, so that a specified proportion of traffic is directed to the canary release version.

In Function Compute V2.0, aliases are configured at the service level. The following sample code provides an example on how to use the plug-in:

# Update the alias settings of the web-framework-kzbp service in the China (Hangzhou) region to direct 50% of traffic to the new version. 
- plugin: @serverless-cd/fc-canary
  inputs:
    serviceName: web-framework-kzbp
    aliasName: prod
    regionId: cn-hangzhou
    canaryPercent: 50