A canary environment allows you to test a function on a specific subset of edge nodes before you release it to all global nodes. This strategy helps prevent potential bugs in your function from affecting your entire user base.
How it works
To help you manage the impact of potential issues during deployment, Edge Functions allows you to create a canary environment based on specific regions. You can select one or more regions, such as Beijing, Fujian, Hunan, and Guangdong, to serve as your canary environment. Once defined, you can publish a new code version or configuration exclusively to this environment. For example, a release to the Beijing region will only affect the edge nodes within Beijing, and only client requests routed to those nodes will run the new code. This process, known as a canary release, allows you to monitor performance and user feedback in a limited setting. If no issues arise, you can then roll out the changes to more regions or to the production environment.
After you define a canary environment by selecting specific regions, the nodes in those regions are separated from the production environment, as shown in the preceding diagram. All subsequent releases must be deployed to the canary environment independently. For example, assume you have code version V1 running in the production environment. You then define Beijing, Fujian, Hunan, and Guangdong as a canary environment. If you deploy code version V2 directly to the production environment, the edge nodes in the four canary regions will continue to run V1. To update all online nodes to V2, you must also explicitly deploy V2 to the canary environment.
If you define a canary environment, follow a sequential release process for every new code or configuration deployment: first to a testing environment, then to the canary environment, and finally to the production environment. This approach lets you take full advantage of the canary release strategy.
Configure a canary environment
Log on to the DCDN console.
NoteEdge Functions require a domain name to serve as an entry point for client requests. This domain can be accelerated by either Alibaba Cloud CDN or DCDN. Log on to the console of the service where your domain is managed.
In the navigation pane on the left, click EdgeRoutine.
Select a function and click Details. In the Add Canary Environment section, click Add Canary Environment.
NoteWhen you define a canary environment, the nodes in the selected regions are separated from the production environment. These nodes then use the configuration for the canary environment independently.
If you release a new version to the production environment, you must also deploy it to the canary environment to update all nodes.

Parameter
Description
Region
Select the regions that you want to include in the canary environment. You can repeat this step to add multiple regions.
NoteYou can choose from 35 regions worldwide to use for your canary environment.
Routine Specifications
CPU time slice: 5 ms per request; Maximum Response Time: 120 s; Memory: 128 MB
CPU time slice: 50 ms per request; Maximum Response Time: 120 s; Memory: 128 MB
CPU time slice: 100 ms per request; Maximum Response Time: 120 s; Memory: 128 MB
NoteThe fees vary based on the function specifications. For more information, see Billing of Edge Functions.
Routine Version
When you create a canary environment, it runs the same function version as the production environment by default.
Domain Name Whitelist
Specifies the domains that are allowed to invoke this function. For example, if you enter
example.com, only requests fromexample.comcan trigger the function. Requests from other domains are rejected. By default, the Domain Name Whitelist is empty, which allows any domain to invoke the function. Wildcard domains are supported.Click OK.
Use the canary environment
When you publish a function version, you can select any canary environment you configured and deploy the version exclusively to the nodes in the regions of that environment.
NoteFor example, if you release code version
1624328628932318493to the Fujian and Chongqing regions, the change affects only the edge nodes in those two regions. Only client requests routed to those nodes will run code version1624328628932318493.After you complete canary testing and want to release the code to all online nodes, you must select all your defined canary environments and the Production environment for the release. This ensures the release covers all online nodes, as shown in the following figure:
