Configuração e medição por locatário
Aprenda a gerenciar configurações por locatário, permissões de funcionalidades e medição de uso que viabilizam faturamento e personalização em software como serviço avançado e multi-tenant.
Configuração e medição por locatário é uma aula grátis de SaaS Architecture & Startup Engineering no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de SaaS Architecture & Startup Engineering, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de SaaS Architecture & Startup Engineering inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
Tenants Are Not Identical
In advanced multi-tenancy, each tenant has different needs: plan limits, enabled features, and branding. The system must track per-tenant configuration cleanly.
This lesson covers configuration, entitlements, and usage metering.
Tenant Configuration Store
Per-tenant settings live in a configuration store keyed by tenant ID. It holds plan, limits, feature flags, and preferences.
const tenantConfig = {
'42': { plan: 'pro', seats: 25, features: ['sso', 'audit_log'] },
'43': { plan: 'free', seats: 3, features: [] }
};Entitlements
An entitlement is the set of features and limits a tenant is allowed based on their plan. Code checks entitlements before granting access to a capability.
function canUse(tenant, feature) {
return tenant.features.includes(feature);
}
if (!canUse(t, 'sso')) throw new Error('Upgrade required');Plan Limits and Quotas
Limits cap resource use per tenant: API calls per month, storage, seats, or projects. Enforcing quotas prevents one tenant from overusing shared infrastructure.
When a quota is reached, you block the action or prompt an upgrade.
Why Meter Usage
Metering records how much each tenant consumes. It powers usage-based billing, quota enforcement, and capacity planning.
Accurate metering is the foundation of fair, transparent charging.
Recording Usage Events
Each billable action emits a usage event tagged with tenant, metric, quantity, and timestamp.
function recordUsage(tenantId, metric, qty) {
events.push({ tenantId, metric, qty, ts: Date.now() });
}
recordUsage('42', 'api_calls', 1);Aggregating Usage
Raw events are aggregated per tenant per billing period. The aggregate feeds both the quota check and the invoice.
function totalFor(tenantId, metric) {
return events
.filter(e => e.tenantId === tenantId && e.metric === metric)
.reduce((sum, e) => sum + e.qty, 0);
}Soft vs Hard Limits
Limits come in two flavors:
- Soft limit — warn the tenant but keep serving (then bill overage)
- Hard limit — block further use until upgrade or reset
Choosing well affects both revenue and customer satisfaction.
Feature Flags Per Tenant
Per-tenant feature flags let you roll out features to specific tenants, run pilots, or sell features as add-ons.
The same code path can behave differently per tenant based on flag evaluation.
Configuration Caching
Tenant config is read on nearly every request, so it must be fast. Cache it in memory or a distributed cache, and invalidate on plan changes.
Stale config can wrongly grant or deny features, so invalidation must be reliable.
Auditing Config Changes
Changes to entitlements and limits should be audited: who changed what, when, and why. This supports billing disputes, compliance, and debugging.
An immutable change log builds trust with enterprise customers.
Quick Check
Test your understanding of per-tenant management.
Recap
You learned per-tenant management:
- Configuration stores and entitlements per tenant
- Quotas, soft vs hard limits, and per-tenant feature flags
- Usage metering via events and aggregation for billing
- Caching with invalidation and auditing of changes
Perguntas Frequentes
A aula “Configuração e medição por locatário” é grátis?
Sim — o texto completo de “Configuração e medição por locatário” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de SaaS Architecture & Startup Engineering, atualize para CoddyKit PRO. O curso de SaaS Architecture & Startup Engineering inclui 4 aulas no total.
O que vou aprender em “Configuração e medição por locatário”?
Aprenda a gerenciar configurações por locatário, permissões de funcionalidades e medição de uso que viabilizam faturamento e personalização em software como serviço avançado e multi-tenant. Você pratica SaaS Architecture & Startup Engineering com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar SaaS Architecture & Startup Engineering?
Nenhuma experiência prévia é necessária. SaaS Architecture & Startup Engineering no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.
Quanto tempo leva a aula “Configuração e medição por locatário”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de SaaS Architecture & Startup Engineering?
Sim. Cada aula de SaaS Architecture & Startup Engineering inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Estratégias de isolamento de clientes
- Técnicas de fragmentação de bancos de dados
- Projeto de personalização e extensibilidade
- Configuração e medição por locatário