SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Multi-tenancy
 with PostgreSQL
Requirements
Three ways
bit.ly/msn-multitenant-arch
Shared Database, Shared Namespace
Separate Databases
Shared Database,
Separate Namespace
has
schemas
has
namespaces
Guy Naor on Multi-tenancy
http://bit.ly/guy-naor-multitenant-2009
App
carding.app.com/products/1-grapes
SET SEARCH_PATH = 'carding'
'carding'


SELECT * FROM products
where id = 1;
Common Tables
"public"
'carding'


SELECT * FROM public.invoices
where tenant_id = 1;
Apartment
github.com/bradrobertson/apartment
bob.sql




carding




alice.sql
carding
carding   assimo
assimo
Storey
github.com/ramontayag/storey
Gotchas
Problem: Testing
●   transactions do not play well with
    schemas
Answer: Testing
●   in tests, treat the public schema as a
    tenant
Problem: Migrations
●   migrate every schema
Answer: Apartment/Storey
●   loops through the namespaces and
    migrates each one
Problem: Background Jobs
●   how do the workers know which
    schema contains the data?
Answer: Pass schema name
 ●   Pass the schema name along with the
     rest of the job arguments
Questions?

Contenu connexe

Similaire à Multi tenancy with PostgreSQL

Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Codemotion
 
Tales from the Field
Tales from the FieldTales from the Field
Tales from the FieldMongoDB
 
Understanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQLUnderstanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQLHyderabad Scalability Meetup
 
Front Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesFront Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesJon Meredith
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowMateuszSzczyrzyca
 
Modeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeModeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeDavid Boike
 
Schema Evolution Patterns - Velocity SJ 2019
Schema Evolution Patterns - Velocity SJ 2019Schema Evolution Patterns - Velocity SJ 2019
Schema Evolution Patterns - Velocity SJ 2019Alex Rasmussen
 
Off the Treadmill: Building a Drupal Platform for Your Organization
Off the Treadmill: Building a Drupal Platform for Your OrganizationOff the Treadmill: Building a Drupal Platform for Your Organization
Off the Treadmill: Building a Drupal Platform for Your OrganizationRick Vugteveen
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Matthew Barlocker
 
Magical Methods for Batch Data Processing
Magical Methods for Batch Data ProcessingMagical Methods for Batch Data Processing
Magical Methods for Batch Data ProcessingSafe Software
 
Ken Bragg: Batch data processing in FME
Ken Bragg: Batch data processing in FMEKen Bragg: Batch data processing in FME
Ken Bragg: Batch data processing in FMEGIM_nv
 
Productionalizing ML : Real Experience
Productionalizing ML : Real ExperienceProductionalizing ML : Real Experience
Productionalizing ML : Real ExperienceIhor Bobak
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 

Similaire à Multi tenancy with PostgreSQL (20)

Protocol Buffers
Protocol BuffersProtocol Buffers
Protocol Buffers
 
Sql and Go
Sql and GoSql and Go
Sql and Go
 
Full stack development
Full stack developmentFull stack development
Full stack development
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
 
Tales from the Field
Tales from the FieldTales from the Field
Tales from the Field
 
Scaling your website
Scaling your websiteScaling your website
Scaling your website
 
Rails data migrations
Rails data migrationsRails data migrations
Rails data migrations
 
Understanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQLUnderstanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQL
 
Front Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesFront Range PHP NoSQL Databases
Front Range PHP NoSQL Databases
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracow
 
Modeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeModeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught Me
 
Schema Evolution Patterns - Velocity SJ 2019
Schema Evolution Patterns - Velocity SJ 2019Schema Evolution Patterns - Velocity SJ 2019
Schema Evolution Patterns - Velocity SJ 2019
 
Athena & Glue
Athena & GlueAthena & Glue
Athena & Glue
 
Off the Treadmill: Building a Drupal Platform for Your Organization
Off the Treadmill: Building a Drupal Platform for Your OrganizationOff the Treadmill: Building a Drupal Platform for Your Organization
Off the Treadmill: Building a Drupal Platform for Your Organization
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1
 
Magical Methods for Batch Data Processing
Magical Methods for Batch Data ProcessingMagical Methods for Batch Data Processing
Magical Methods for Batch Data Processing
 
Ken Bragg: Batch data processing in FME
Ken Bragg: Batch data processing in FMEKen Bragg: Batch data processing in FME
Ken Bragg: Batch data processing in FME
 
Productionalizing ML : Real Experience
Productionalizing ML : Real ExperienceProductionalizing ML : Real Experience
Productionalizing ML : Real Experience
 
Three Ruby usages
Three Ruby usagesThree Ruby usages
Three Ruby usages
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 

Multi tenancy with PostgreSQL