Skip to main content

Gray Release

CloudBase cloud functions support multi-version management. You can use the function canary capability to adjust request traffic proportions between versions, enabling canary release and rollback for online business to ensure smooth deployment transitions.

Version

Each cloud function can release multiple versions, where a version is a snapshot of the function at the time of generation, including code and configuration (timeout, environment variables, etc.).

LATEST Version

Cloud functions always have a LATEST version, which is the latest version. Uploading, updating, or deploying code for cloud functions all modify the LATEST version.

Traffic Ratio

You can adjust the traffic ratio for different versions of cloud functions. CloudBase will automatically distribute request traffic based on the configured ratio.

Consistency Guarantee

CloudBase uses the user's globally unique ID to ensure request consistency.

After setting the traffic ratio, if a user is assigned to a specific traffic range, their invocations of the cloud function will always be routed to the corresponding version, eliminating random assignment.

For example, if the LATEST version of a cloud function has a 10% traffic ratio and Version 1 has 90%, once a user is assigned to Version 1 by the system, all their requests to this cloud function will definitely be routed to Version 1, rather than having a 90% probability of going to Version 1 and 10% probability to LATEST.

For requests without user information, the canary release mechanism defaults to random routing.

How to Perform Canary Release

The recommended canary release process is as follows:

  1. Release a new version from LATEST, where the snapshot of this version is identical to the current LATEST.
  2. Set the traffic for the LATEST version to 0% and the newly released version to 100%.
  3. Update the cloud function code (the LATEST version has been updated at this point, but its traffic remains at 0%).
  4. Manually adjust the traffic ratio for the LATEST version.

Example:

  1. Release version 1.
  2. Set 100% traffic to version 1;
  3. Modify the LATEST code and deploy;
  4. To allocate 10% of online traffic to the latest code requiring canary observation, set 10% traffic to LATEST and 90% to version 1.

Canary Release Usage

Create version

Access the CloudBase platform cloud function management page, then click on the function you wish to perform canary release on.

In the "Canary Configuration" section, click "Publish New Version" to create a new version from LATEST. After entering the version description, version 1 will be generated.

Note

Once a version is generated, the code of this version cannot be modified.

Configure Traffic Ratio

Configure the traffic ratio for different versions as follows:

Note that after adjusting the ratio, the changes take effect immediately; please confirm with caution.

Best Practices

First-Time Usage

During the first cloud function canary release, only the LATEST version exists with no generated versions. At this point, developers need to first publish a version for the current LATEST version:

  1. In the console, select the cloud function, publish new Version 1, and set the traffic to 100%;
  2. Update the LATEST version; since the traffic for the LATEST version is 0%, it does not affect the online business;
  3. Set the traffic ratios for LATEST and 1 to 10% and 90% respectively

At this point, the first online canary release is completed, with the new version (updated LATEST) accounting for 10% of the traffic and the old version (version 1) accounting for 90%.

Version Rollback/Full Release

For full release or version rollback, simply adjust the traffic to direct 100% to the specified canary version/official version.