Skip to main content

Canary release

CloudBase cloud function supports multi-version management. With the canary release capability, it can adjust the request traffic ratio between different versions, achieving smooth transition of online services, canary verification, and quick rollback, ensuring the stability and security of service releases.

Core Concepts

Version Management

Each cloud function can publish multiple versions. A version is a complete snapshot of the function at a specific point in time, including:

  • Function code
  • Configuration information (timeout period, environment variables, memory specifications, etc.)
  • Runtime environment

LATEST version

Cloud functions always have a LATEST version, which represents the most recent version. When you upload, update, or deploy cloud function code, you are modifying the LATEST version.

Traffic Distribution

You can precisely control the traffic ratio for different versions of cloud functions. CloudBase automatically distributes request traffic to corresponding versions based on the set ratio.

Consistency Guarantee

CloudBase uses the user's globally unique identifier to ensure request consistency:

  • Requests with user information: All requests from the same user are consistently routed to the same version, ensuring a consistent user experience
  • Requests without user information: Traffic is allocated using a random scheduling policy
Example Explanation

Assume that the LATEST version of the cloud function has a traffic ratio of 10%, and version 1 has 90%. If a user is assigned to version 1, all subsequent requests from that user for this cloud function will be routed to version 1, rather than being randomly allocated based on probability.

Canary release process

  1. Creating a stable version: Publish a new version (e.g., version 1) from the current LATEST version
  2. Switching traffic: Set the LATEST version traffic to 0% and the new version traffic to 100%
  3. Updating the code: Deploy new feature code in the LATEST version
  4. Canary verification: Gradually adjust the traffic ratio of the LATEST version for canary testing

Operation Guide

Create Version

  1. Go to the Cloud Function Management Page
  2. Select the function that requires canary release
  3. In the Canary Configuration module, click Release a New Version

  1. Enter the version description and confirm the release

⚠️ Note: After the version is released, the code and configuration of this version will be locked and cannot be modified again.

Configure Traffic Ratio

On the Canary Configuration page, you can dynamically adjust the traffic allocation ratio for different versions in real time:

⚠️ Note: Traffic ratio adjustments take effect immediately. Proceed with caution and verify the results promptly.

Best Practices

First Canary Release

For cloud functions that have never used the canary release feature, it is recommended to follow these steps:

  1. Release the baseline version

    Current status: Only the LATEST version (100% traffic)
    Operation: Release version 1 and set its traffic to 100%.
  2. Deploy the new feature

    Current status: version 1 (100% traffic), LATEST (0% traffic)
    Operation: Deploy the new feature code in the LATEST version
  3. Start the Canary Release

    Set traffic allocation: LATEST (10%), version 1 (90%)
    Result: 10% of users experience the new feature, 90% of users use the stable version

Version Rollback and Full Release

Rapid Rollback

When issues are detected in the new version, you can quickly switch traffic back to the stable version:

Emergency Rollback: Set stable version traffic to 100%, problematic version traffic to 0%

Full Release

When the new version passes verification, you can proceed with the full release:

Full Release: Set new version traffic to 100%, old version traffic to 0%

Canary Policy Recommendations

StageLATEST TrafficStable Version TrafficDescription
Initial Verification5%95%Verify basic features in a small-scale
Expanded Verification20%80%Verify performance and stability
Pre-Full Release50%50%Large-scale verification
Full Release100%0%Release completed
Recommendation
  • Recommend performing canary releases during off-peak business hours
  • Closely monitor key metrics of the new version, such as error rate and response time
  • Prepare a quick rollback plan to ensure business stability