All Products
Search
Document Center

Dynamic Content Delivery Network:Staging environment

Last Updated:Nov 15, 2023

A staging environment is generated when you create a routine. The staging environment allows you to simulate the configurations of the production environment, debug code, and retest the previous versions of code. The staging environment is isolated from the production environment (the business environment). Therefore, operations in the staging environment do not affect your workloads. After you test your routine in the staging environment, you can publish the routine to the production environment.

Configure the staging environment

The staging environment can simulate the configurations of the production environment and the canary release environment, but is isolated from both environments. We recommend that you modify the configurations of the staging environment and test services in the staging environment before you modify the configurations of the production environment and canary release environment to minimize potential risks.

  1. Log on to the DCDN console.

  2. In the left-side navigation pane, click EdgeRoutine.

  3. Find the routine that you want to manage and click Details in the Actions column.

  4. Select Settings and click Modify in the Test Environment section. You can configure the Routine Specifications and Domain Name Whitelist parameters based on your business requirements.生产

    Parameter

    Description

    Routine Specifications

    • CPU Time Slice for Individual Requests: 5 ms, Maximum Real Time: 120s, Memory: 128 MB

    • CPU Time Slice for Individual Requests: 50 ms, Maximum Real Time: 120s, Memory: 128 MB

    • CPU Time Slice for Individual Requests: 100 ms, Maximum Real Time: 120s, Memory: 128 MB

    Note

    The fees vary based on routine specifications. For more information, see Billing rules.

    Domain Name Whitelist

    The domain names that can be associated with the routine. For example, if you set the Domain Name Whitelist parameter to example.com, only requests from example.com can trigger the routine. Requests from other domain names are rejected by the routine. By default, the Domain Name Whitelist parameter is empty. Requests from all domain names can be associated with the routine. Wildcard domain names are supported.

  5. Click OK.

Debug code

  1. Log on to the DCDN console.

  2. In the left-side navigation pane, click EdgeRoutine.

  3. Find the routine that you want to manage and click Details in the Actions column.

  4. On the Details page, click Code.

  5. After you finish coding, click Publish to Test Environment.image01

  6. Add the IP address of the staging environment that is provided on the Publish to Test Environment page to the local hosts file. Then, you can use the domain name to access the staging environment and test the code.

    Note

    Add the following content to the hosts file:

    • IP address: replace the IP address with one of the IP addresses that are displayed in Step 5.

    • Domain name: the Alibaba CDN-accelerated or DCDN-accelerated domain name that is associated with the routine. For more information, see Associate domain names with a routine.

    Example: 10.10.10.10 example.com.

Test the code of a previous version

You can use the staging environment to retest the code of a previous version. For example, you want to roll back the production environment to a previous version, but you are unsure whether errors exist in the code of the previous version. You can publish the previous version to the staging environment. After you test the code, you can roll back the production environment to the previous version.

  1. Log on to the DCDN console.

  2. In the left-side navigation pane, click EdgeRoutine.

  3. Find the routine that you want to manage and click Details in the Actions column.

  4. On the Details page, click Versions.

  5. On the Versions page, publish a previous version to the staging environment for testing.