Wener Notes

SaaS

约 3 分钟阅读

Database

数据库策略

特性数据库分离表分离共享数据库
数据定制化YYN
安全YNN
内部依赖和性能YYN
可扩展模型NYN
Customer OnboardingNNY

Tenant

PostgreSQL

  • RLS
  • Schema
  • DB
  • tid=
sql
CREATE POLICY tenant_isolation_policy ON student USING (tid = current_setting('auth.current_tenant_id')::int);

预留后缀

  • .keys
  • .gpg
  • .rss
  • .atom
  • .png

API

支持多 租户、多环境

  • Header 增加区分
    • X-Tenant-Id
    • Pros
      • URL 干净
      • 中间件、网关方便统一处理
    • Cons
      • 每次都需要设置 Header
  • 域名区分
    • https://tenant1.example.com
  • 路径区分
    • https://example.com/tenant1/api
  • 查询参数区分
    • https://example.com/api?tenant=tenant1
  • 请求体区分
    • POST https://example.com/api
      • tenant: tenant1

关联信息

反向链接、本文链接的其他页面和外部资料。

References

Wikipedia1 条
Hacker News1 条
其他外链17 条
最近更新commit 906e816Edit

On this page