SlideShare a Scribd company logo
1 of 25
Multi-Tenancy With Django 
Scott Crespo 
Software Engineer 
Director, Orlando Data Science 
Scott@OrlandoDS.com
1. Multi-Tenant Architectures 
2. Django Tenant Schemas Explained 
3. Basic Use + Tips and Tricks
Definition 
Multi-Tenancy: 
A software architecture where a single application 
instance enables multiple organizations 
(tenants) to view their data. 
*This is a key component of XaaS (i.e. Something 
as a Service)
Architectures 
Multi-tenant architectures can be placed on a continuum 
Shared Separate
Common Approaches to Multi-Tenancy
Shared Architecutre 
One Database + One Schema 
One database instance, and one public schema 
serve all tenants. 
Pros 
- Easy to build if data layer is simple 
- Every user on same domain (might be desirable) 
- Only use if a Tenant has exactly one user. 
Cons 
- Expensive (Makes lots of calls to db for tenant 
object)
Isolated Architecture 
Multiple Databases 
Each tenant has their own database instance 
Pros 
- Most Secure 
- Easier disaster recovery 
- Not expensive for compute resources 
Cons 
- Difficult to scale 
- Expensive storage resources 
- Difficult to share data across tenants
Hybrid Architecture 
One Database – Multiple Schemas 
One database instance for all tenants. Each 
tenant gets a dedicated schema. 
Shared 'public' schema 
Dedicated 'tenant' schema
What's a Schema? 
Acts as a namespace in Postgres 
Adds an additional layer of organization/isolation 
to the database 
(Database → Schema → Table) 
ex) SELECT * FROM schema_name.table 
When a schema is not specified in the connection 
or query – only the 'public' schema is accessed 
Schemas to be queried can be specified in the 
app's database connection via 
'SEARCH_PATH' parameter
One Database – Multiple Schemas 
Pros 
- Scalable 
- Cheap 
- Simple 
- Semi-secure 
- Sharable 
Cons 
- Difficult disaster 
recovery 
- Less-secure than 
dedicated db's
Django Tenant Schemas 
Implements Multi-Schema Approach 
Requires PostgreSQL 
Installation: 
$ pip install django-tenant-schemas 
Docs: 
Django-tenant-schemas.readthedocs.org
Features 
1.Tenant-based Subdomains 
2.Postgres Support
The Tenant Object 
Stored on the 'public' schema 
Contains 2 Critical Fields 
- domain_url – the tenant's domain (foo.bar.com) 
- schema_name – the schema where the Tenant's 
isolated data is stored (tenant_jw8j23jp)
Request Routing 
1.User makes a request 
2.Middleware looks up tenant object on the public 
schema and returns schema_name 
Tenant.objects.get(domain=request.domain).schema_name 
1.Tenant_Schema's database wrapper adds 
schema_name to the connection's 
SEARCH_PATH 
cursor.execute('SET search_path = public, schema_name') 
1.Subsequent Requests include schema_name 
in the search path
Basic Use 
Settings.py 
Specify TENANT and SHARED apps 
 Caution! Don't include new tenant registration on tenants' apps 
Use the tenant_schemas postgres backend 
Use the tenant schemas middleware
Basic use 
models.py 
 Create a tenant app that contains your tenant model 
(i.e. organization, company, etc). 
 Use tenant_schema's mixin 
- domain_url 
- schema_name 
from tenant_schemas.models import TenantMixin 
class Company(TenantMixin) 
company_name =models.CharField(max_length=255L) 
about = models.TextField(blank=True) 
auto_create_schema = True
The app containing your tenant model should 
remain in the project's root directory. Otherwise 
tenant_schemas can't find it. 
|-- apps 
| |-- __init__.py 
| |-- app1 
| |-- app2 
| |-- app3 
|-- Project 
| |-- __init__.py 
| |-- settings.py 
| |-- settings.pyc 
| |-- urls.py 
| `-- wsgi.py 
|-- manage.py 
`-- tenant 
|-- admin.py 
|-- __init__.py 
|-- models.py 
|-- tests.py 
`-- views.py 
* you could try simlinks as a work-around, but not recommended
Basic Use 
Command Line & DNS 
Use tenant_schemas command wrapper for 
db commands 
 Use sync_schemas and 
migrate_schemas 
 DO NOT use syncdb or migrate 
Server & DNS 
- Make sure to use subdomain wildcards
Basic Use 
Custom Commands 
Create a 'make_tenants' custom command 
- Must create a public tenant and a 
private tenant to complete creation of 
the database
Custom Command: 
make_tenants.py 
from lawfirm.models import LawFirm 
from django.core.management.base import NoArgsCommand 
import os 
if os.environ['DJANGO_SETTINGS_MODULE'] == 'settings.base': 
from settings.base import BASE_URL 
else: 
from settings.dev import BASE_URL 
class Command(NoArgsCommand): 
def handle_noargs(self,**options): 
# create your public tenant 
LawFirm(domain_url=BASE_URL, 
schema_name='public', 
firm_name='LawCRM', 
).save() 
#test tenant to verify sub-domain routing 
LawFirm(domain_url='test.'+BASE_URL, 
schema_name='test', 
firm_name='Test Firm', 
).save()
Schema Naming Schemes 
Auto-generate tenant schema names and 
enforce uniqueness. 
Prefix with 'tenant_' 
Append a hash to the end 
*Schema name must begin with a letter, $, or 
underscore 
Example Database: 
- public 
- test 
dev
Modify Search Path on the Fly 
(this took time to figure out) 
from django.db import connection 
connection.set_tenant(tenant) 
# set_tenant() accepts tenant object, NOT 
# tenant_name!
Important Decision 
Tenant Model on 
Public Schema 
User Model on Public 
Schema 
- Easy 
- Less Secure 
- User More Portable 
Tenant Model on 
Public Schema 
User Model on Private 
Schema 
- Not so easy 
- More secure 
- User Less Portable 
VS
Thanks! 
Scott Crespo 
scott@orlandods.com

More Related Content

What's hot

Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...Amazon Web Services Korea
 
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Edureka!
 
Amazon Aurora Deep Dive (김기완) - AWS DB Day
Amazon Aurora Deep Dive (김기완) - AWS DB DayAmazon Aurora Deep Dive (김기완) - AWS DB Day
Amazon Aurora Deep Dive (김기완) - AWS DB DayAmazon Web Services Korea
 
AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)
AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)
AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)Amazon Web Services Korea
 
Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017
Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017
Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017Amazon Web Services Korea
 
Microsoft Azure Traffic Manager
Microsoft Azure Traffic ManagerMicrosoft Azure Traffic Manager
Microsoft Azure Traffic ManagerIdo Katz
 
금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017
금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017
금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017Amazon Web Services Korea
 
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB DayAmazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB DayAmazon Web Services Korea
 
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...Amazon Web Services Korea
 
Amazon EFS (Elastic File System) 이해하고사용하기
Amazon EFS (Elastic File System) 이해하고사용하기Amazon EFS (Elastic File System) 이해하고사용하기
Amazon EFS (Elastic File System) 이해하고사용하기Amazon Web Services Korea
 
Microservices and docker
Microservices and dockerMicroservices and docker
Microservices and dockerAlex Ivy
 
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016Amazon Web Services Korea
 
놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021Amazon Web Services Korea
 
Confluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CM
Confluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CMConfluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CM
Confluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CMconfluent
 
Bootstrapping state in Apache Flink
Bootstrapping state in Apache FlinkBootstrapping state in Apache Flink
Bootstrapping state in Apache FlinkDataWorks Summit
 
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon Web Services Korea
 
글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)
글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)
글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)Amazon Web Services Korea
 

What's hot (20)

Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
 
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
 
Cloudformation101
Cloudformation101Cloudformation101
Cloudformation101
 
Amazon Aurora Deep Dive (김기완) - AWS DB Day
Amazon Aurora Deep Dive (김기완) - AWS DB DayAmazon Aurora Deep Dive (김기완) - AWS DB Day
Amazon Aurora Deep Dive (김기완) - AWS DB Day
 
AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)
AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)
AWS Batch를 통한 손쉬운 일괄 처리 작업 관리하기 - 윤석찬 (AWS 테크에반젤리스트)
 
Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017
Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017
Amazon Aurora 성능 향상 및 마이그레이션 모범 사례 - AWS Summit Seoul 2017
 
Microsoft Azure Traffic Manager
Microsoft Azure Traffic ManagerMicrosoft Azure Traffic Manager
Microsoft Azure Traffic Manager
 
AWS CloudFormation Masterclass
AWS CloudFormation MasterclassAWS CloudFormation Masterclass
AWS CloudFormation Masterclass
 
금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017
금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017
금융권을 위한 AWS Direct Connect 기반 하이브리드 구성 방법 - AWS Summit Seoul 2017
 
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB DayAmazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
 
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
AWS 기반 클라우드 아키텍처 모범사례 - 삼성전자 개발자 포털/개발자 워크스페이스 - 정영준 솔루션즈 아키텍트, AWS / 유현성 수석,...
 
Amazon EFS (Elastic File System) 이해하고사용하기
Amazon EFS (Elastic File System) 이해하고사용하기Amazon EFS (Elastic File System) 이해하고사용하기
Amazon EFS (Elastic File System) 이해하고사용하기
 
Microservices and docker
Microservices and dockerMicroservices and docker
Microservices and docker
 
2020.02.06 우리는 왜 glue를 버렸나?
2020.02.06 우리는 왜 glue를 버렸나?2020.02.06 우리는 왜 glue를 버렸나?
2020.02.06 우리는 왜 glue를 버렸나?
 
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
 
놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
놀면 뭐하니? 같이 개인 방송 서비스 만들어보자! - 김승준 현륜식 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
 
Confluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CM
Confluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CMConfluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CM
Confluent Cloud로 이벤트 기반 마이크로서비스 10배 확장하기 with 29CM
 
Bootstrapping state in Apache Flink
Bootstrapping state in Apache FlinkBootstrapping state in Apache Flink
Bootstrapping state in Apache Flink
 
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
 
글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)
글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)
글로벌 고객 사례를 통하여 소개하는 혁신적인 데이터 웨어하우스 - 김형일 (AWS 솔루션즈 아키텍트)
 

Viewers also liked

Developing Software As A Service App with Python & Django
Developing Software As A Service App with Python & DjangoDeveloping Software As A Service App with Python & Django
Developing Software As A Service App with Python & DjangoAllan Mangune
 
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to ServicesCraig Kerstiens
 
Django multi-tier
Django multi-tierDjango multi-tier
Django multi-tiersmirolo
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of DjangoJacob Kaplan-Moss
 
Django Multi-DB in Anger
Django Multi-DB in AngerDjango Multi-DB in Anger
Django Multi-DB in AngerLoren Davie
 
12 tips on Django Best Practices
12 tips on Django Best Practices12 tips on Django Best Practices
12 tips on Django Best PracticesDavid Arcos
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humansCraig Kerstiens
 
2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro pythonAdam Hitchcock
 
Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014jlbaldwin
 
Django shop
Django shopDjango shop
Django shopTribaal
 
Django workshop : let's make a blog
Django workshop : let's make a blogDjango workshop : let's make a blog
Django workshop : let's make a blogPierre Sudron
 
Django Interview Questions and Answers
Django Interview Questions and AnswersDjango Interview Questions and Answers
Django Interview Questions and AnswersPython Devloper
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to djangoIlian Iliev
 
Big o notation
Big o notationBig o notation
Big o notationkeb97
 
ZCA: A component architecture for Python
ZCA: A component architecture for PythonZCA: A component architecture for Python
ZCA: A component architecture for PythonTimo Stollenwerk
 
Dev/Test Scenarios in the DevOps World
Dev/Test Scenarios in the DevOps WorldDev/Test Scenarios in the DevOps World
Dev/Test Scenarios in the DevOps WorldPranav Ainavolu
 
LCNUG 2015 - what's new for agile teams in TFS 2015
LCNUG 2015 -  what's new for agile teams in TFS 2015LCNUG 2015 -  what's new for agile teams in TFS 2015
LCNUG 2015 - what's new for agile teams in TFS 2015Angela Dugan
 

Viewers also liked (20)

Developing Software As A Service App with Python & Django
Developing Software As A Service App with Python & DjangoDeveloping Software As A Service App with Python & Django
Developing Software As A Service App with Python & Django
 
Moving from Django Apps to Services
Moving from Django Apps to ServicesMoving from Django Apps to Services
Moving from Django Apps to Services
 
Django multi-tier
Django multi-tierDjango multi-tier
Django multi-tier
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
Django Multi-DB in Anger
Django Multi-DB in AngerDjango Multi-DB in Anger
Django Multi-DB in Anger
 
12 tips on Django Best Practices
12 tips on Django Best Practices12 tips on Django Best Practices
12 tips on Django Best Practices
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humans
 
2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python
 
Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014
 
dJango
dJangodJango
dJango
 
Django shop
Django shopDjango shop
Django shop
 
Django workshop : let's make a blog
Django workshop : let's make a blogDjango workshop : let's make a blog
Django workshop : let's make a blog
 
Django in Windows
Django in WindowsDjango in Windows
Django in Windows
 
Django Interview Questions and Answers
Django Interview Questions and AnswersDjango Interview Questions and Answers
Django Interview Questions and Answers
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to django
 
Big o notation
Big o notationBig o notation
Big o notation
 
ZCA: A component architecture for Python
ZCA: A component architecture for PythonZCA: A component architecture for Python
ZCA: A component architecture for Python
 
Dev/Test Scenarios in the DevOps World
Dev/Test Scenarios in the DevOps WorldDev/Test Scenarios in the DevOps World
Dev/Test Scenarios in the DevOps World
 
LCNUG 2015 - what's new for agile teams in TFS 2015
LCNUG 2015 -  what's new for agile teams in TFS 2015LCNUG 2015 -  what's new for agile teams in TFS 2015
LCNUG 2015 - what's new for agile teams in TFS 2015
 
Intro django
Intro djangoIntro django
Intro django
 

Similar to Multi Tenancy With Python and Django

Getting data into Rudder
Getting data into RudderGetting data into Rudder
Getting data into RudderRUDDER
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloudpetriojala123
 
Infrastructure as Code with Terraform
Infrastructure as Code with TerraformInfrastructure as Code with Terraform
Infrastructure as Code with TerraformPedro J. Molina
 
Centralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache ZookeeperCentralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache ZookeeperRyan Gardner
 
Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHPPaul Jones
 
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdfSchema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdfseo18
 
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...Srikanth Prathipati
 
Configuration Management and Transforming Legacy Applications in the Enterpri...
Configuration Management and Transforming Legacy Applications in the Enterpri...Configuration Management and Transforming Legacy Applications in the Enterpri...
Configuration Management and Transforming Legacy Applications in the Enterpri...Docker, Inc.
 
Practical advice on deployment and management of enterprise workloads
Practical advice on deployment and management of enterprise workloadsPractical advice on deployment and management of enterprise workloads
Practical advice on deployment and management of enterprise workloadsJarek Miszczyk
 
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty ProfileAAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty ProfileWASdev Community
 
Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02arghya007
 
Using puppet
Using puppetUsing puppet
Using puppetAlex Su
 
Domain Access Module
Domain Access ModuleDomain Access Module
Domain Access ModuleRyan Cross
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 
Achieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudAchieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudScott Miao
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsMarcelo Pinheiro
 
Solid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User GroupSolid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User GroupShapeBlue
 
CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire NetApp
 

Similar to Multi Tenancy With Python and Django (20)

Getting data into Rudder
Getting data into RudderGetting data into Rudder
Getting data into Rudder
 
Cloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the CloudCloud Meetup - Automation in the Cloud
Cloud Meetup - Automation in the Cloud
 
Infrastructure as Code with Terraform
Infrastructure as Code with TerraformInfrastructure as Code with Terraform
Infrastructure as Code with Terraform
 
Pyramid patterns
Pyramid patternsPyramid patterns
Pyramid patterns
 
Centralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache ZookeeperCentralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache Zookeeper
 
Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHP
 
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdfSchema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
 
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
Case Study _Cloud Native Transformation Deploying Integration workloads to AK...
 
Configuration Management and Transforming Legacy Applications in the Enterpri...
Configuration Management and Transforming Legacy Applications in the Enterpri...Configuration Management and Transforming Legacy Applications in the Enterpri...
Configuration Management and Transforming Legacy Applications in the Enterpri...
 
Practical advice on deployment and management of enterprise workloads
Practical advice on deployment and management of enterprise workloadsPractical advice on deployment and management of enterprise workloads
Practical advice on deployment and management of enterprise workloads
 
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty ProfileAAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
 
Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02
 
Using puppet
Using puppetUsing puppet
Using puppet
 
Django
DjangoDjango
Django
 
Domain Access Module
Domain Access ModuleDomain Access Module
Domain Access Module
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Achieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudAchieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloud
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Solid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User GroupSolid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User Group
 
CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire
 

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Multi Tenancy With Python and Django

  • 1. Multi-Tenancy With Django Scott Crespo Software Engineer Director, Orlando Data Science Scott@OrlandoDS.com
  • 2. 1. Multi-Tenant Architectures 2. Django Tenant Schemas Explained 3. Basic Use + Tips and Tricks
  • 3. Definition Multi-Tenancy: A software architecture where a single application instance enables multiple organizations (tenants) to view their data. *This is a key component of XaaS (i.e. Something as a Service)
  • 4. Architectures Multi-tenant architectures can be placed on a continuum Shared Separate
  • 5. Common Approaches to Multi-Tenancy
  • 6. Shared Architecutre One Database + One Schema One database instance, and one public schema serve all tenants. Pros - Easy to build if data layer is simple - Every user on same domain (might be desirable) - Only use if a Tenant has exactly one user. Cons - Expensive (Makes lots of calls to db for tenant object)
  • 7. Isolated Architecture Multiple Databases Each tenant has their own database instance Pros - Most Secure - Easier disaster recovery - Not expensive for compute resources Cons - Difficult to scale - Expensive storage resources - Difficult to share data across tenants
  • 8. Hybrid Architecture One Database – Multiple Schemas One database instance for all tenants. Each tenant gets a dedicated schema. Shared 'public' schema Dedicated 'tenant' schema
  • 9. What's a Schema? Acts as a namespace in Postgres Adds an additional layer of organization/isolation to the database (Database → Schema → Table) ex) SELECT * FROM schema_name.table When a schema is not specified in the connection or query – only the 'public' schema is accessed Schemas to be queried can be specified in the app's database connection via 'SEARCH_PATH' parameter
  • 10. One Database – Multiple Schemas Pros - Scalable - Cheap - Simple - Semi-secure - Sharable Cons - Difficult disaster recovery - Less-secure than dedicated db's
  • 11. Django Tenant Schemas Implements Multi-Schema Approach Requires PostgreSQL Installation: $ pip install django-tenant-schemas Docs: Django-tenant-schemas.readthedocs.org
  • 13. The Tenant Object Stored on the 'public' schema Contains 2 Critical Fields - domain_url – the tenant's domain (foo.bar.com) - schema_name – the schema where the Tenant's isolated data is stored (tenant_jw8j23jp)
  • 14. Request Routing 1.User makes a request 2.Middleware looks up tenant object on the public schema and returns schema_name Tenant.objects.get(domain=request.domain).schema_name 1.Tenant_Schema's database wrapper adds schema_name to the connection's SEARCH_PATH cursor.execute('SET search_path = public, schema_name') 1.Subsequent Requests include schema_name in the search path
  • 15.
  • 16. Basic Use Settings.py Specify TENANT and SHARED apps  Caution! Don't include new tenant registration on tenants' apps Use the tenant_schemas postgres backend Use the tenant schemas middleware
  • 17. Basic use models.py  Create a tenant app that contains your tenant model (i.e. organization, company, etc).  Use tenant_schema's mixin - domain_url - schema_name from tenant_schemas.models import TenantMixin class Company(TenantMixin) company_name =models.CharField(max_length=255L) about = models.TextField(blank=True) auto_create_schema = True
  • 18. The app containing your tenant model should remain in the project's root directory. Otherwise tenant_schemas can't find it. |-- apps | |-- __init__.py | |-- app1 | |-- app2 | |-- app3 |-- Project | |-- __init__.py | |-- settings.py | |-- settings.pyc | |-- urls.py | `-- wsgi.py |-- manage.py `-- tenant |-- admin.py |-- __init__.py |-- models.py |-- tests.py `-- views.py * you could try simlinks as a work-around, but not recommended
  • 19. Basic Use Command Line & DNS Use tenant_schemas command wrapper for db commands  Use sync_schemas and migrate_schemas  DO NOT use syncdb or migrate Server & DNS - Make sure to use subdomain wildcards
  • 20. Basic Use Custom Commands Create a 'make_tenants' custom command - Must create a public tenant and a private tenant to complete creation of the database
  • 21. Custom Command: make_tenants.py from lawfirm.models import LawFirm from django.core.management.base import NoArgsCommand import os if os.environ['DJANGO_SETTINGS_MODULE'] == 'settings.base': from settings.base import BASE_URL else: from settings.dev import BASE_URL class Command(NoArgsCommand): def handle_noargs(self,**options): # create your public tenant LawFirm(domain_url=BASE_URL, schema_name='public', firm_name='LawCRM', ).save() #test tenant to verify sub-domain routing LawFirm(domain_url='test.'+BASE_URL, schema_name='test', firm_name='Test Firm', ).save()
  • 22. Schema Naming Schemes Auto-generate tenant schema names and enforce uniqueness. Prefix with 'tenant_' Append a hash to the end *Schema name must begin with a letter, $, or underscore Example Database: - public - test dev
  • 23. Modify Search Path on the Fly (this took time to figure out) from django.db import connection connection.set_tenant(tenant) # set_tenant() accepts tenant object, NOT # tenant_name!
  • 24. Important Decision Tenant Model on Public Schema User Model on Public Schema - Easy - Less Secure - User More Portable Tenant Model on Public Schema User Model on Private Schema - Not so easy - More secure - User Less Portable VS
  • 25. Thanks! Scott Crespo scott@orlandods.com