Skip to main content

Traffic Routing

Use traffic routing commands to configure and view traffic distribution across cloud function versions, enabling gradual release and version rollback.

Configure Version Traffic

Use the tcb fn config-route command to configure traffic distribution for function versions:

tcb fn config-route <functionName> <version1> <traffic1> [version2] [traffic2]

Parameter Description:

ParameterDescriptionRequired
functionNameFunction nameYes
version1First version number, can be a specific version or $LATESTYes
traffic1Traffic percentage for the first version, range 0-100Yes
version2Second version numberNo
traffic2Traffic percentage for the second versionNo

Usage Examples:

# Allocate 10% traffic to version 2, remaining 90% to $LATEST
tcb fn config-route app 2 10

# Allocate 30% traffic to version 1, 70% to version 2
tcb fn config-route app 1 30 2 70

# Switch 100% traffic to version 3
tcb fn config-route app 3 100

View Traffic Configuration

Use the tcb fn get-route command to view traffic configuration for function versions:

tcb fn get-route <functionName>

Usage Example:

# View traffic configuration for app function
tcb fn get-route app

Important Notes

  • If only one version and traffic percentage is specified, the remaining traffic is allocated to the $LATEST version
  • If two versions are specified, the traffic percentages must sum to 100
  • Traffic routing configuration takes effect immediately, adjustments will impact live traffic instantly
  • It is recommended to perform traffic adjustments during off-peak business hours