Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

テナント分離

テナント分離の方法

マルチテナントSaaSにおいて、テナントごとにデータを分離する方法は主に3つある

  1. アプリケーションの実行環境ごと完全に分離する

  2. データベースのみをインスタンスやスキーマで分離する

  3. データベースのインスタンスやスキーマはマルチテナントとして、テーブル内のテナントIDで分離する

上のものほど安全に分離できるが、リソース効率が悪くなる。

Row Level Security (RLS)

Row Level Security (RLS)は、テーブル内の行へのアクセスを制御する機能。

RLS を利用すると、SELECT 文などに暗黙的な WHERE 句 (where tenant_id = xxx) が追加されたような挙動が実現できる。

注意点

info - Unknown Directive
AWSによる、PostgreSQLでのRLSの例

[aws-samples/aws-saas-factory-postgresql-rls](https://github.com/aws-samples/aws-saas-factory-postgresql-rls)

([PostgreSQL の行レベルのセキュリティを備えたマルチテナントデータの分離 | Amazon Web Services ブログ](https://aws.amazon.com/jp/blogs/news/multi-tenant-data-isolation-with-postgresql-row-level-security/))