Back to projects

multitenancy-microservices

Spring Boot microservices architecture demo for comparing multi-tenancy strategies. The project models tenant isolation with database-per-tenant, schema-per-tenant, and tenant-column approaches across separate services.

Brief

Spring Boot microservices demo for tenant isolation patterns

Demonstrates: Multi-tenancy trade-offs, service boundaries, tenant isolation

Key Features

  • Compares database-per-tenant, schema-per-tenant, and tenant-column isolation models
  • Splits employee, organization, device, and tenant registry responsibilities into separate services
  • Uses PostgreSQL, Consul, Docker Compose, Actuator, and tenant-header validation for local architecture testing

Problem

Compare tenant isolation strategies in a microservice system where each service has different data ownership constraints.

Architecture

Four Spring Boot services model employee, organization, device, and tenant registry boundaries. PostgreSQL demonstrates database-per-tenant, schema-per-tenant, and tenant-column isolation, with Consul and Docker Compose for local service discovery and infrastructure.

Key decisions

  • Keep isolation strategies in separate services to make trade-offs visible and comparable.
  • Use tenant headers and service boundaries instead of hiding multi-tenancy in one shared abstraction.

Trade-offs

  • Database-per-tenant improves isolation but increases operational overhead.
  • Tenant-column storage is simpler to operate but demands stricter query discipline.

My role

  • Designed the service boundaries, tenant isolation examples, local infrastructure, and validation flow.

Tech stack

JavaSpring BootSpring CloudPostgreSQLConsulDocker

Future improvements

  • Add centralized observability for tenant-aware request tracing.
  • Add security tests for tenant boundary violations.
Spring Boot backend architecture demo for comparing multi-tenancy strategies across microservices. The repository contains four services and local infrastructure for tenant-aware backend design: `employee-service`, `organization-service`, `device-service`, and `tenant-service`. The project demonstrates several tenant data-isolation approaches in one system while keeping service boundaries explicit. Employee data uses a database-per-tenant model, organization data uses schema-per-tenant isolation, device data uses tenant-column isolation, and the tenant service stores shared tenant metadata.