Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/multitenancy-isolation/concept/concept-four-multitenancy-strategies.md
T
DongHyeonkaandClaude Opus 5 b2963105a8 docs(keycloak-session-store): import the session-storage lab as a new project
The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.

Follows the import procedure in README.md.

  source/     the originating repository verbatim — 78 documents, 28 SVGs,
              8 manifests, plus .source-revision recording the commit
  final/      the SSOT
    document.md   729 lines written from the 29 experiment documents, not
                  concatenated: what was predicted, what was measured, and
                  where the measurement itself was wrong
    evidence/raw    125 outputs, flattened to <experiment>__<file> because
                    the originals collided (01-baseline.txt appeared three
                    times) and the audit only globs the top level
    evidence/meta   one per raw file; command and exitCode are null and the
                    README says why rather than inventing them
    evidence/browser  22 captures
    assets/       three diagrams through techviz
    .techviz/     their VizSpecs

A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.

Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.

verify-pipeline.py passes. audit-records.py reports no issues.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:51:59 +09:00

4.7 KiB

kind, slug, title, topic, project, status, sourceRevision, rootTreeNode, evidenceCapturedOn, assets, evidence, source
kind slug title topic project status sourceRevision rootTreeNode evidenceCapturedOn assets evidence source
CONCEPT four-multitenancy-strategies 네 가지 멀티테넌시 전략과 각각의 격리 경계 multitenancy-isolation clean-architecture-backend-template 게시 전 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 concept:four-multitenancy-strategies 2026-09-01
key file
four-multitenancy-strategies ../../../final/evidence/rendered/four-multitenancy-strategies.svg
key file
four-multitenancy-strategies-diagram ../../../final/assets/diagrams/four-multitenancy-strategies.svg
../../../final/evidence/raw/four-multitenancy-strategies.txt
원본 분석 절은 analysis/05 §13.2 이다.

네 가지 멀티테넌시 전략과 각각의 격리 경계

이 저장소는 네 전략을 각각 실험 플래그 뒤에 구현했다. 격리 경계가 다르고 실패 모드도 다르며, 넷 모두 테넌트 식별자의 형식 제약을 공통 기반으로 쓴다.

관계

  • RLS가 성립하기 위한 세 전제 두 번째 전략의 전제 조건이다.
  • tenant별 풀이 개별적으로 합리적이고 그 합이 서버 상한을 넘긴다 네 번째 전략의 실패 모드다.
  • 클래스패스에 있는 것은 실행 동의가 아니다 네 전략이 전부 플래그 뒤에 있는 이유다.

본문

이 저장소가 네 전략(discriminator column · RLS · schema-per-tenant · database-per-tenant)을 각각 플래그 뒤에 두고 구현한 구조의 설명이다.

격리 경계가 놓이는 층

:::evidence key="four-multitenancy-strategies-diagram" alt="database-per-tenant 와 schema-per-tenant 와 RLS 행 수준과 discriminator column 이 위에서 아래로 쌓여 있고 오른쪽에 격리가 얕아지는 방향 화살표가 있다" caption="격리 경계가 놓이는 층" zoom="false" :::

실패 모드가 전략마다 다르다

column은 predicate 누락이 곧 유출, RLS는 세 전제(§concept:rls-three-preconditions), schema는 search_path 잔존, database는 커넥션 예산의 곱셈이다.

네 전략이 각각 놓인 플래그

:::evidence key="four-multitenancy-strategies" alt="분석 문서 analysis/05-adapter-outbound-persistence-jpa.md 에서 이 기록의 근거 절을 그대로 잘라낸 16줄. 코드베이스를 측정한 것이 아니라 원본 판정이 무엇을 적었는지를 보여 준다." caption="analysis/05-adapter-outbound-persistence-jpa.md 발췌 — 16줄" zoom="true" :::

TenantId 정규식이 네 전략 전부의 기반인 이유

스키마 이름·set_config 값·라우팅 키에 들어가므로 ../public 같은 값이 path-traversal이 된다.

:::note

네 전략 중 어느 것도 실제로 켜서 관측하지 않았다 — 전부 experimental 플래그 뒤에 있다

:::

네 전략과 각각의 실패 모드

전략 격리 경계 실패 모드
판별 컬럼 애플리케이션 술어 술어 누락이 곧 유출
행 수준 보안 데이터베이스 정책 세 전제 중 하나만 어긋나도 무력화
테넌트별 스키마 검색 경로 세션 설정이 풀로 돌아간 커넥션에 잔존
테넌트별 데이터베이스 커넥션 자체 풀 예산의 곱셈

경계가 위로 갈수록 애플리케이션에 가깝고 아래로 갈수록 인프라에 가깝다. 그리고 실패의 성질도 달라진다. 위쪽은 코드 한 줄을 빠뜨리면 유출이고, 아래쪽은 자원 계산을 틀리면 전체 장애다.

공통 기반은 식별자의 형식이다

테넌트 식별자는 네 전략 전부에서 쓰인다. 그리고 쓰이는 자리가 위험하다.

스키마 이름이 된다 세션 설정 값이 된다 라우팅 키가 된다

그래서 식별자 타입이 형식을 정규식으로 제약한다. 그 제약이 없으면 상위 경로를 가리키는 값 같은 것이 스키마 이름 자리에 들어가 경로 순회가 된다.

:::warning

식별자 형식 제약은 네 전략 중 어느 것을 쓰든 필요하다. 전략을 바꿔도 그 값이 들어가는 자리는 여전히 위험하다.

:::

실험 플래그 뒤에 있는 이유

네 전략 전부가 게이트 뒤에 있다. 클래스패스에 있다는 것이 실행 동의가 아니라는 원칙이다.

테넌트 격리 기능이 jar 가 있다는 이유로 스스로 켜지면, 켜졌는지 모르는 상태에서 격리를 신뢰하게 된다. 게이트는 결정의 부재를 활성화가 아니라 오류로 만든다.

이 저장소에서의 상태

네 전략 중 어느 것도 실제로 켜서 관측되지 않았다. 전부 실험 플래그 뒤에 있고, 이 사이클의 확인은 코드와 마이그레이션과 그 주석에 근거한다.