SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
MULTI-TENANCY
in Java applications

@ladislavGazo
gazo@seges.sk
THE APPLICATION
user
|
bunch of JavaScript
|
service
|
domain model
IMPLICATION
user1 ... userN
|
same bunch of JavaScript
|
service
|
ONE database
ONE APPLICATION TO RULE THEM ALL
The term multi-tenancy in general is applied to software
development to indicate an architecture in which a single running
instance of an application simultaneously serves multiple clients
(tenants).
This is highly common in SaaS solutions.
Isolating information (data, customizations, etc) pertaining to the
various tenants is a particular challenge in these systems.
SPLIT ME NOW!
user1 -> BA, user2 -> BA, user 3 -> KE, user 4 -> ZA
|
again the same JavaScript
|
(almost) the same service
|
DB (BA), DB (KE), DB (ZA)
a lot of "tenant" dependent data - high volumes
performance
separation -> easier backup and restore
scalability of front-end and service layer
HIBERNATE IS THE EASIEST
MULTI-TENANT CONFIGURATION
<rprynm=hbraemlieac"vle"AAAE /
poet ae"ient.utTnny au=DTBS" >
<rprynm=hbraetnn_dniirrsle"vle"ksgshodlnecniuainMlieatdniireovr /
poet ae"ient.eatietfe_eovr au=s.ee.rdeei.ofgrto.utTnnIetfeRsle" >

<rprynm=hbraemlitnn_oncinpoie"vle"r.ient.evc.dccnetossi
poet ae"ient.ut_eatcneto_rvdr au=oghbraesriejb.oncin.p.
DtSucBsdutTnnCnetoPoieIp"/
aaoreaeMlieatoncinrvdrml >

<rprynm=hbraecneto.aaore vle"aacm/n/dch"/
poet ae"ient.oncindtsuc" au=jv:opevjb/r >

<rprynm=hbraemlitnn.aaoreietfe_o_n"vle"eal"/
poet ae"ient.ut_eatdtsuc.dniirfray au=dfut >
SWITCH IT ON

hbraemlieac
ient.utTnny
CONFIGURE WHERE TO LOOK FOR THE
CURRENT TENANT IDENTIFIER

hbraetnn_dniirrsle
ient.eatietfe_eovr
WHERE ARE MY CONNECTIONS?

hbraemlitnn_oncinpoie
ient.ut_eatcneto_rvdr

Hibernate's
DataSourceBasedMultiTenantConnectionProviderImpl
utilizes JNDI lookups
POINT TO JNDI ROOT FOR DATASOURCES

hbraecneto.aaore
ient.oncindtsuc
... AND THE DEFAULT

hbraemlitnn.aaoreietfe_o_n
ient.ut_eatdtsuc.dniirfray

So in the end =

jv:opevjb/rdfut
aacm/n/dch/eal
BUT THERE ARE THINGS THAT DON'T WORK
EHCache configuration from previous version is different
Hibernate's internal schema update does not work
NPE !!! ........ who would have said that
MIGRATION
HIBERNATE EXPORTER
is not helpful
DO YOU HAVE ENVERS?
then you need custom exporter
IT IS EASY TO WRITE
but don't forget the AuditConfiguration
EbCniuainjaofgrto =nwEbCniuain)cniue
j3ofgrto pCniuain
e j3ofgrto(.ofgr(
uiNm,nl)
ntae ul;
Cniuainhbraeofgrto =jaofgrto
ofgrto ientCniuain
pCniuain
.eHbraeofgrto(;
gtientCniuain)
hbraeofgrto.ulMpig(;
ientCniuainbidapns)
Adtofgrto adtofgrto =Adtofgrto.eFr
uiCniuain uiCniuain
uiCniuaingto(
hbraeofgrto)
ientCniuain;

and use EnversSchemaGenerator at last
GET RID OF NPE BUG

{"ient.utTnny,
hbraemlieac"
"ient.eatietfe_eovr,
hbraetnn_dniirrsle"
"ient.ut_eatcneto_rvdr,
hbraemlitnn_oncinpoie"
"ient.oncindtsuc"
hbraecneto.aaore,
"ient.ut_eatdtsuc.dniirfray }
hbraemlitnn.aaoreietfe_o_n"
RUN THE EXPORTER FROM MAVEN
COMBINE IT WITH LIQUIBASE

version 3.0.6 contains feature to populate all tenant databases
Mlieatpigiubs
utTnnSrnLqiae
DON'T FORGET...
it is maintenable but generated SQL needs to be checked
existing databases must be moved to "point 0"
A BIT OF LOGGING
http://www.slf4j.org/faq.html#logging_performance
Importance of logging - using MDC to track requests
MCpt"eat,cinOg)
D.u(tnn" letrz;

lgjapne.totlyu.ovrinatr =AP[dIO61]-%5
o4.pedrsdu.aotCnesoPten
P %{S80}
-p
[t%{eat|Xrqetd]%:M%3.0{}-%%
%|Xtnn}%{eusI} F% -03c1
mn
AND THE MOST BORING...

DESIGN
your app to be multi-tenant
SEND TENANT IDENTIFICATION
in HTTP Header
use Filter to get it out
in Service parameters
using ThreadLocal variable
via tenant-URL-based service calls
rmi://localhost:12345/<tenant>/<service>
etc...
THANKS FOR LISTENING

@ladislavGazo
gazo@seges.sk

Weitere ähnliche Inhalte

Was ist angesagt?

[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...
[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...
[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...
confluent
 

Was ist angesagt? (20)

Common issues with Apache Kafka® Producer
Common issues with Apache Kafka® ProducerCommon issues with Apache Kafka® Producer
Common issues with Apache Kafka® Producer
 
Amazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for Kubernetes
 
Coordinating Microservices with AWS Step Functions.pdf
Coordinating Microservices with AWS Step Functions.pdfCoordinating Microservices with AWS Step Functions.pdf
Coordinating Microservices with AWS Step Functions.pdf
 
DevOps at Amazon: A Look at Our Tools and Processes
 DevOps at Amazon: A Look at Our Tools and Processes DevOps at Amazon: A Look at Our Tools and Processes
DevOps at Amazon: A Look at Our Tools and Processes
 
Principles of Monitoring Microservices
Principles of Monitoring MicroservicesPrinciples of Monitoring Microservices
Principles of Monitoring Microservices
 
Event Storming and Implementation Workshop
Event Storming and Implementation WorkshopEvent Storming and Implementation Workshop
Event Storming and Implementation Workshop
 
AWS API Gateway
AWS API GatewayAWS API Gateway
AWS API Gateway
 
[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...
[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...
[Confluent] 실시간 하이브리드, 멀티 클라우드 데이터 아키텍처로 빠르게 혀...
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
TiDB at PayPay
TiDB at PayPayTiDB at PayPay
TiDB at PayPay
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
The People Model and Cloud Transformation | AWS Public Sector Summit 2016
The People Model and Cloud Transformation | AWS Public Sector Summit 2016The People Model and Cloud Transformation | AWS Public Sector Summit 2016
The People Model and Cloud Transformation | AWS Public Sector Summit 2016
 
Azure Application insights - An Introduction
Azure Application insights - An IntroductionAzure Application insights - An Introduction
Azure Application insights - An Introduction
 
클라우드 비용, 어떻게 줄일 수 있을까? - 구본민, AWS 클라우드 파이넌셜 매니저 :: AWS Builders 100
클라우드 비용, 어떻게 줄일 수 있을까? - 구본민, AWS 클라우드 파이넌셜 매니저 :: AWS Builders 100클라우드 비용, 어떻게 줄일 수 있을까? - 구본민, AWS 클라우드 파이넌셜 매니저 :: AWS Builders 100
클라우드 비용, 어떻게 줄일 수 있을까? - 구본민, AWS 클라우드 파이넌셜 매니저 :: AWS Builders 100
 
Development and Test on AWS
Development and Test on AWSDevelopment and Test on AWS
Development and Test on AWS
 
Developing applications with a microservice architecture (SVforum, microservi...
Developing applications with a microservice architecture (SVforum, microservi...Developing applications with a microservice architecture (SVforum, microservi...
Developing applications with a microservice architecture (SVforum, microservi...
 
Microservices Architecture for e-Commerce
Microservices Architecture for e-CommerceMicroservices Architecture for e-Commerce
Microservices Architecture for e-Commerce
 
Publish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event AggregatorPublish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event Aggregator
 
AWS Containers Day.pdf
AWS Containers Day.pdfAWS Containers Day.pdf
AWS Containers Day.pdf
 
02 api gateway
02 api gateway02 api gateway
02 api gateway
 

Andere mochten auch

How to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring EditionHow to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring Edition
Stephan Hochdörfer
 
Multi-Tenant SOA Middleware for Cloud Computing
Multi-Tenant SOA Middleware for Cloud ComputingMulti-Tenant SOA Middleware for Cloud Computing
Multi-Tenant SOA Middleware for Cloud Computing
Srinath Perera
 
Testing untestable code - phpday
Testing untestable code - phpdayTesting untestable code - phpday
Testing untestable code - phpday
Stephan Hochdörfer
 
How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11
Stephan Hochdörfer
 

Andere mochten auch (20)

JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EEJavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
 
Multi Tenancy In The Cloud
Multi Tenancy In The CloudMulti Tenancy In The Cloud
Multi Tenancy In The Cloud
 
How to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring EditionHow to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring Edition
 
Multi-Tenant Approach
Multi-Tenant ApproachMulti-Tenant Approach
Multi-Tenant Approach
 
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
 
Multi-tenancy in the cloud
Multi-tenancy in the cloudMulti-tenancy in the cloud
Multi-tenancy in the cloud
 
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EEConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
 
JVM Multitenancy (JavaOne 2012)
JVM Multitenancy (JavaOne 2012)JVM Multitenancy (JavaOne 2012)
JVM Multitenancy (JavaOne 2012)
 
Making Apache Tomcat Multi-tenant, Elastic and Metered
Making Apache Tomcat Multi-tenant, Elastic and MeteredMaking Apache Tomcat Multi-tenant, Elastic and Metered
Making Apache Tomcat Multi-tenant, Elastic and Metered
 
Multi-tenancy In the Cloud
Multi-tenancy In the CloudMulti-tenancy In the Cloud
Multi-tenancy In the Cloud
 
Multi-Tenant SOA Middleware for Cloud Computing
Multi-Tenant SOA Middleware for Cloud ComputingMulti-Tenant SOA Middleware for Cloud Computing
Multi-Tenant SOA Middleware for Cloud Computing
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EE
 
A Multi-tenant Architecture for Business Process Executions
A Multi-tenant Architecture for Business Process ExecutionsA Multi-tenant Architecture for Business Process Executions
A Multi-tenant Architecture for Business Process Executions
 
RESTful API Design, Second Edition
RESTful API Design, Second EditionRESTful API Design, Second Edition
RESTful API Design, Second Edition
 
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
 
Testing untestable code - phpday
Testing untestable code - phpdayTesting untestable code - phpday
Testing untestable code - phpday
 
How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11
 
Java EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e MudançasJava EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e Mudanças
 
Component Level Security
Component Level SecurityComponent Level Security
Component Level Security
 
Storage Multi-Tenancy For Cloud Service Providers
Storage Multi-Tenancy For Cloud Service ProvidersStorage Multi-Tenancy For Cloud Service Providers
Storage Multi-Tenancy For Cloud Service Providers
 

Ähnlich wie Multi-tenancy in Java

Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
FITC
 
Re:code, frp vs async await ( Peter Ovchinnikov )
Re:code, frp vs async await ( Peter Ovchinnikov )Re:code, frp vs async await ( Peter Ovchinnikov )
Re:code, frp vs async await ( Peter Ovchinnikov )
Iryna Datsyshyn
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
sam2sung2
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001
jucaab
 

Ähnlich wie Multi-tenancy in Java (20)

SAP ABAP Lock concept and enqueue
SAP ABAP Lock concept and enqueueSAP ABAP Lock concept and enqueue
SAP ABAP Lock concept and enqueue
 
UEMB240: Managing Your User Profile Data at Scale
UEMB240: Managing Your User Profile Data at ScaleUEMB240: Managing Your User Profile Data at Scale
UEMB240: Managing Your User Profile Data at Scale
 
Liberating web apps from the server
Liberating web apps from the serverLiberating web apps from the server
Liberating web apps from the server
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
 
Katello on TorqueBox
Katello on TorqueBoxKatello on TorqueBox
Katello on TorqueBox
 
RxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programmingRxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programming
 
The Very Very Latest in Database Development - Oracle Open World 2012
The Very Very Latest in Database Development - Oracle Open World 2012The Very Very Latest in Database Development - Oracle Open World 2012
The Very Very Latest in Database Development - Oracle Open World 2012
 
The Very Very Latest In Database Development - Lucas Jellema - Oracle OpenWor...
The Very Very Latest In Database Development - Lucas Jellema - Oracle OpenWor...The Very Very Latest In Database Development - Lucas Jellema - Oracle OpenWor...
The Very Very Latest In Database Development - Lucas Jellema - Oracle OpenWor...
 
Testing Delphix: easy data virtualization
Testing Delphix: easy data virtualizationTesting Delphix: easy data virtualization
Testing Delphix: easy data virtualization
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
Re:code, frp vs async await ( Peter Ovchinnikov )
Re:code, frp vs async await ( Peter Ovchinnikov )Re:code, frp vs async await ( Peter Ovchinnikov )
Re:code, frp vs async await ( Peter Ovchinnikov )
 
A sane approach to microservices
A sane approach to microservicesA sane approach to microservices
A sane approach to microservices
 
JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)JavaFX Enterprise (JavaOne 2014)
JavaFX Enterprise (JavaOne 2014)
 
Optimizing apps for better performance extended
Optimizing apps for better performance extended Optimizing apps for better performance extended
Optimizing apps for better performance extended
 
Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...
Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...
Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...
 

Mehr von seges (8)

Spring Boot and Microservices
Spring Boot and MicroservicesSpring Boot and Microservices
Spring Boot and Microservices
 
Automated Tomcat Management
Automated Tomcat ManagementAutomated Tomcat Management
Automated Tomcat Management
 
Javist Being Cheftain
Javist Being CheftainJavist Being Cheftain
Javist Being Cheftain
 
OSGi experiments
OSGi experimentsOSGi experiments
OSGi experiments
 
Internetová prítomnosť a content management
Internetová prítomnosť a content managementInternetová prítomnosť a content management
Internetová prítomnosť a content management
 
AngularJS first steps
AngularJS first stepsAngularJS first steps
AngularJS first steps
 
GWT Workshop
GWT WorkshopGWT Workshop
GWT Workshop
 
Ako sme zistili ze asi robime Scrum
Ako sme zistili ze asi robime ScrumAko sme zistili ze asi robime Scrum
Ako sme zistili ze asi robime Scrum
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Multi-tenancy in Java

  • 2. THE APPLICATION user | bunch of JavaScript | service | domain model
  • 3. IMPLICATION user1 ... userN | same bunch of JavaScript | service | ONE database
  • 4. ONE APPLICATION TO RULE THEM ALL The term multi-tenancy in general is applied to software development to indicate an architecture in which a single running instance of an application simultaneously serves multiple clients (tenants). This is highly common in SaaS solutions. Isolating information (data, customizations, etc) pertaining to the various tenants is a particular challenge in these systems.
  • 5. SPLIT ME NOW! user1 -> BA, user2 -> BA, user 3 -> KE, user 4 -> ZA | again the same JavaScript | (almost) the same service | DB (BA), DB (KE), DB (ZA)
  • 6. a lot of "tenant" dependent data - high volumes performance separation -> easier backup and restore scalability of front-end and service layer
  • 8. MULTI-TENANT CONFIGURATION <rprynm=hbraemlieac"vle"AAAE / poet ae"ient.utTnny au=DTBS" > <rprynm=hbraetnn_dniirrsle"vle"ksgshodlnecniuainMlieatdniireovr / poet ae"ient.eatietfe_eovr au=s.ee.rdeei.ofgrto.utTnnIetfeRsle" > <rprynm=hbraemlitnn_oncinpoie"vle"r.ient.evc.dccnetossi poet ae"ient.ut_eatcneto_rvdr au=oghbraesriejb.oncin.p. DtSucBsdutTnnCnetoPoieIp"/ aaoreaeMlieatoncinrvdrml > <rprynm=hbraecneto.aaore vle"aacm/n/dch"/ poet ae"ient.oncindtsuc" au=jv:opevjb/r > <rprynm=hbraemlitnn.aaoreietfe_o_n"vle"eal"/ poet ae"ient.ut_eatdtsuc.dniirfray au=dfut >
  • 10. CONFIGURE WHERE TO LOOK FOR THE CURRENT TENANT IDENTIFIER hbraetnn_dniirrsle ient.eatietfe_eovr
  • 11. WHERE ARE MY CONNECTIONS? hbraemlitnn_oncinpoie ient.ut_eatcneto_rvdr Hibernate's DataSourceBasedMultiTenantConnectionProviderImpl utilizes JNDI lookups
  • 12. POINT TO JNDI ROOT FOR DATASOURCES hbraecneto.aaore ient.oncindtsuc
  • 13. ... AND THE DEFAULT hbraemlitnn.aaoreietfe_o_n ient.ut_eatdtsuc.dniirfray So in the end = jv:opevjb/rdfut aacm/n/dch/eal
  • 14. BUT THERE ARE THINGS THAT DON'T WORK EHCache configuration from previous version is different Hibernate's internal schema update does not work NPE !!! ........ who would have said that
  • 17. DO YOU HAVE ENVERS? then you need custom exporter
  • 18. IT IS EASY TO WRITE but don't forget the AuditConfiguration EbCniuainjaofgrto =nwEbCniuain)cniue j3ofgrto pCniuain e j3ofgrto(.ofgr( uiNm,nl) ntae ul; Cniuainhbraeofgrto =jaofgrto ofgrto ientCniuain pCniuain .eHbraeofgrto(; gtientCniuain) hbraeofgrto.ulMpig(; ientCniuainbidapns) Adtofgrto adtofgrto =Adtofgrto.eFr uiCniuain uiCniuain uiCniuaingto( hbraeofgrto) ientCniuain; and use EnversSchemaGenerator at last
  • 19. GET RID OF NPE BUG {"ient.utTnny, hbraemlieac" "ient.eatietfe_eovr, hbraetnn_dniirrsle" "ient.ut_eatcneto_rvdr, hbraemlitnn_oncinpoie" "ient.oncindtsuc" hbraecneto.aaore, "ient.ut_eatdtsuc.dniirfray } hbraemlitnn.aaoreietfe_o_n"
  • 20. RUN THE EXPORTER FROM MAVEN
  • 21. COMBINE IT WITH LIQUIBASE version 3.0.6 contains feature to populate all tenant databases Mlieatpigiubs utTnnSrnLqiae
  • 22. DON'T FORGET... it is maintenable but generated SQL needs to be checked existing databases must be moved to "point 0"
  • 23. A BIT OF LOGGING http://www.slf4j.org/faq.html#logging_performance Importance of logging - using MDC to track requests MCpt"eat,cinOg) D.u(tnn" letrz; lgjapne.totlyu.ovrinatr =AP[dIO61]-%5 o4.pedrsdu.aotCnesoPten P %{S80} -p [t%{eat|Xrqetd]%:M%3.0{}-%% %|Xtnn}%{eusI} F% -03c1 mn
  • 24. AND THE MOST BORING... DESIGN your app to be multi-tenant
  • 25. SEND TENANT IDENTIFICATION in HTTP Header use Filter to get it out in Service parameters using ThreadLocal variable via tenant-URL-based service calls rmi://localhost:12345/<tenant>/<service> etc...