How Replicas Work
When you create replicas of an app, Phala Cloud provisions separate CVMs that share a singleapp_id. All replicas use the same compose file and encrypted secrets. If you update the compose or environment, every replica picks up the change.
Each replica gets its own CVM ID, endpoint URL, and TEE attestation. Traffic is not automatically load-balanced between replicas — add an external load balancer or DNS-based routing to distribute requests.
Deploy with Terraform
Terraform is the most straightforward way to manage replicas declaratively. Set thereplicas attribute on a phala_app resource and Terraform handles creation, updates, and teardown.
replicas value and run terraform apply. The provider adds or removes CVMs to match.
Scaling down deletes the newest replicas. Make sure your application handles graceful shutdown, since in-flight requests on removed replicas will be interrupted.
Deploy with SDKs
The SDKs expose areplicateCvm method that creates a copy of an existing CVM. Call it multiple times to create the number of replicas you need.
Deploy with CLI
The CLI doesn’t have a dedicated replica command, but you can deploy the same compose file multiple times with different names. Each deployment creates an independent CVM.Monitor Replica Health
Once your replicas are running, check their status from the dashboard or CLI. Dashboard: Navigate to your app in the CVMs page. Each replica appears as a separate CVM entry with its own status indicator. CLI:When to Use Replicas
Replicas are useful when you need high availability or want to distribute workloads across regions. They work best for stateless services like APIs, proxies, and workers. For stateful applications, consider whether your data layer supports multi-instance access before scaling out.Related
- Terraform
phala_appResource — full attribute reference includingreplicas - CVM Lifecycle (JS SDK) —
replicateCvmmethod reference - CVM Lifecycle (Python SDK) —
replicate_cvmmethod reference - Deploy Your First CVM — getting started with a single CVM

