Skip to main content

Multi-tenant Architecture

Vibe Coding platforms usually need to provide isolated environments for each end user. This document describes CloudBase's multi-tenant isolation solution.


Tenant Isolation Model

CloudBase adopts a one-tenant-one-environment model: every user corresponds to an independent CloudBase environment, so compute, data, storage, and networking are naturally isolated.

Key design points:

DimensionDesign
Agent and Sandbox separationThe Agent runs in the production environment (with credentials), while the Sandbox runs without credentials and is invoked remotely over RPC. This separation reduces security risk.
Multi-tenant isolationThe one-tenant-one-environment model gives each user a dedicated CloudBase environment with natural isolation of compute, data, storage, and network.
Elastic scalingThe Agent service layer is stateless and can scale horizontally. Sandboxes can be created and destroyed on demand. CloudBase environments use pay-as-you-go billing.
Cold-start optimizationPreheated Sandbox snapshots + template environment cloning reduce the wait time for first use.
Cost optimizationIdle Sandbox instances can be reclaimed automatically and restored on demand, with environment-level resource quota control.

Permission Isolation Options

CloudBase issues an API Key for each user environment. The API Key is bound to a specific environment ID on the CloudBase platform and enforced server-side, so even if leaked, it can only access that user's own environment, providing environment-level isolation (see Get an Environment API Key for details):

DimensionOption: Environment-level API Key
Core ideaThe platform creates an isolated environment for each user and issues an API Key
User accountPlatform-owned account (can integrate with SSO / LDAP), invisible to Tencent Cloud
Brand visibilityFully white-label, users only interact with the platform's product
Manual managementReview through APIs and logs
SSO integration✅ Supports the platform's own account system
Suitable scenariosAI Coding / Vibe Coding platforms, ToC products, multi-tenant SaaS

Credential security:

HolderCredentialPurpose
Agent RuntimeLLM API KeyCall large models
CloudBase SecretId / SecretKeyCall management APIs and authenticate Sandbox RPC
SandboxEnvironment-level temporary credential (for MCP only)Can operate only on the current user's own CloudBase environment

Environment Management (Automation)

// Use the management SDK to create an environment for a new user
const cloudbaseManager = require('@cloudbase/manager-node');

async function createUserEnv(userId) {
// 1. Create the environment
const result = await tcbApi.CreateEnv({
Alias: `user-${userId}`,
PackageId: 'baas_personal',
Resources: ['flexdb', 'storage', 'function'],
Tags: [{ Key: 'userId', Value: userId }]
});

// 2. Poll until the environment is ready
await waitForEnvReady(result.EnvId);

// 3. Persist the mapping between the user and the environment
await saveUserEnvMapping(userId, result.EnvId);

return result.EnvId;
}

Cost Estimation

ItemUnit PriceQuantityMonthly Cost
Management environment (CloudBase Personal Edition)¥19.9 / month1¥19.9
User environment (CloudBase Personal Edition)¥19.9 / monthN¥19.9 × N
  • 10 users: ¥19.9 × 11 = ¥219 / month
  • 50 users: ¥19.9 × 51 = ¥1,015 / month
  • 100 users: ¥19.9 × 101 = ¥2,020 / month