tencent cloud

Tencent Cloud EdgeOne

Code Replica

PDF
Focus Mode
Font Size
Last updated: 2026-04-10 15:55:15
Code replicas are primarily used for modifying edge functions code to safely validate new code logic without impacting live traffic, thereby reducing release risks.

Overview

When edge functions are used to handle business requests, each code iteration (such as adding new business logic, fixing defects, optimizing performance) carries the risk of directly going live and affecting production traffic. EdgeOne edge functions support creating code replicas, you can deploy the new version of code to be validated to the replica, and by configuring specified request header EO-Function-Replica-Name: <replica name>, route specific test traffic to this replica version for validation, while regular production traffic is still handled by the official version function, with both being completely isolated and not affecting each other.
Through the code replicas feature, you can:
Zero-risk validation: The new code only takes effect for test requests carrying specific request headers, with production traffic completely unaffected;
Flexible iteration: You can modify the replica code and test repeatedly at any time without publishing to the official version every time;
Rapid launch: Once validated, the replica code is directly promoted to the official version, completing the release efficiently.

Prerequisites

1. Have logged in to EdgeOne and completed site addition.
2. Have already created at least one edge function in Edge Functions > Function Management.

Operation Introduction

Create a code replica

1. Log in to EdgeOne, in the left menu bar, click edge functions > Function Management, and go to the function list page;
2. In the function list, click the function name that needs to be updated to go to the function details page.
3. In the function details page, click New Replica to copy production code or create a custom replica;
4. After the code editing is completed, click Save, then enter a replica name to finish creation. The replica name must contain 1-50 characters using a-z, 0-9, or -, where hyphens cannot be used alone or consecutively, nor placed at the beginning or end. The name cannot be modified after creation.
Note:
1. A single function supports up to two code replicas.
2. Replica code is completely isolated from production code; modifications to replicas will not affect the normal operation of live functions.
3. Environment variables and secret keys are equally applicable to replica code.

Send test requests by carrying request headers to verify the effect of the code

Scenario Assumption

The console has created a function named test-2xkazsasyf6k-1206341531. The default access domain name is:
https://test-2xkazsasyf6k-1206341531.eo-edgefunctions.com, configure the trigger rule as HOST = www.example.com AND URL_Path = /pic, with the replica name as test-replica. Carry the specified request header EO-Function-Replica-Name: test-replica, and send a request to the function's custom domain path or default access domain name to route specific test traffic to this replica version for validation.

Directions

1. Use curl, Postman, or other HTTP client tools to send requests to the function's custom domain path or default access domain name, carrying the EO-Function-Replica-Name request header. Using curl as an example:
# Testing via Custom Domain Path
curl -H "EO-Function-Replica-Name: test-replica" https://www.example.com/pic

# Testing via Default Access Domain Name
curl -H "EO-Function-Replica-Name: test-replica" https://test-2xkazlasyf6k-1306341531.eo-edgefunctions.com
2. Observe the response content and confirm whether the execution result of the replica code meets expectations.
Note:
1. Request header names and values are case-sensitive. Ensure that the request header sent during testing exactly matches the configuration here.
2. Regular requests without the specified request header will continue to be processed by production code. The entire testing process does not affect production code and can be conducted with confidence.

Verification passed. Synchronize the replica code to production code

1. In the Code Replica module on the function details page, select the verified replica and click Compare and Sync to Production Code;
2. After confirming everything is correct, click Confirm Sync;
3. After secondary confirmation, the code in the replica will overwrite the production code and start processing all production traffic.
Note:
1. After the production code is synced, the original code will be replaced and cannot be undone. Backing up before making changes is recommended.
2. If you wish to gradually roll out the new version of the code to the production environment after replica verification, refer to Canary Release and Region-Specific Execution for Edge Functions.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback