SlideShare a Scribd company logo
Michał Mac
Architekt
MCPD Win Developer, MCITP DBA, Developer
Długi ogon/SaaS
Reguły biznesowe
Rozszerzalnośd danych
Pojemnik na dane
  Sql Server
$ / Klient




             Najwięksi klienci



                    Co jeśli obniżymy koszt wyprodukowania i
                    dostarczenia oprogramowania?



                         Typowi klienci

                                 Nowy rynek >> aktualny rynek
                                    Rynek (aktualnie) poza zasięgiem
7

6

5

4

3

2

1

0
    Sprzęt   Ludzie   Software
Dostawca może zainwestować w olbrzymie
Data-Center
Microsoft Data Center (Chicago, IL)
Koszt inwestycji $500m, wielkość 10 boisk football
Nie kupuje sprzętu
Nie instaluje oprogramowania
Nie ponosi dużego kosztu na starcie
   Model abonamentowy
   Reklamy
Ciągłe i stałe przychody
Lepsza ochrona własności intelektualnej
Aktualizacje aplikacji odbywają się centralnie
7

6

5

4

3

2

1

0
    Sprzęt   Ludzie   Software
7

6

5

4

3

2

1

0
    Sprzęt   Ludzie   Software
Konfigurowalność
Multitenancy
Skalowalność
Wymienialne reguły biznesowe
Rozszerzalny model danych
Konfigurowalny interfejs
Multitenancy
Wymienialne reguły biznesowe
Rozszerzalny model danych
Konfigurowalny interfejs
Multitenancy
Reużywalne
Automatyczna detekcja zależności
  Expression Trees
Reguły walidacyjne
Możliwość dodawania z zewnątrz
Prosty tekstowy język – Formula
  Antlr + Expression Trees
Realizacja
   Słownik
   ExpandoObject - .Net 4.0
Dynamiczny interfejs użytkownika
   Metadane per tenant
Same dane nie wystarczą. Wymagana
możliwość używania w regułach
biznesowych
Baza danych – w następnej części
Prosta rozszerzalność
Prosta strategia backupów
Bezpieczeństwo, izolacja
  Bankowość, branża medyczna
Większe koszty – zużyte zasoby
  Auto close może zwiększyć ten limit, ale
  pogarsza czas dostępu
Premiun approach
Łatwa implementacja i rozszerzalność
Średni poziom izolacji
Utrudniony backup/restore
Niższe koszty, bo więcej tenantów na jednej
bazie
Operacje DDL, które blokują katalog
systemowy
Najniższe koszty sprzętu per tenant
  Możliwość dostarczenia drogich mechanizmów
  wysokiej dostępności po korzystnych cenach.
Problemy z backupe/restorem
Większe koszty produkcji aplikacji
  Należy zapewnić bezpieczeństwo, nawet w
  przypadku nieprzewidzianego błędu
    Tenant Data Encryption
    Tenant View Filter
Możliwość partycjonowania per tenant
Realizacja
Framework agnostic
Transparentność
Bezpieczeństwo
  Ewentualny błąd programisty nie może ujawnić
  danych innego
Używanie pooli połączeń
Wydajność
CREATE USER TenantA WITHOUT LOGIN
      WITH DEFAULT_SCHEMA = Secured;

GRANT SELECT, EXECUTE, INSERT, UPDATE, DELETE
      ON SCHEMA::[Secured] TO TenantA;
CREATE TABLE Products
(
      ProductId INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL REFERENCES Warehouses,
);
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL REFERENCES Warehouses,
);
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL REFERENCES Warehouses,
);
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1),
      PRIMARY KEY(TenantId, ProductId),
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL REFERENCES Warehouses,
);
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1),
      PRIMARY KEY(TenantId, ProductId),
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL REFERENCES Warehouses,
);
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1),
      PRIMARY KEY(TenantId, ProductId),
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL,
      FOREIGN KEY ( TenantId, WarehouseId )
            REFERENCES Warehouses
);
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1),
      PRIMARY KEY(TenantId, ProductId),
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL,
      FOREIGN KEY ( TenantId, WarehouseId )
            REFERENCES Warehouses
);
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1),
      PRIMARY KEY(TenantId, ProductId),
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL,
      FOREIGN KEY ( TenantId, WarehouseId )
            REFERENCES Warehouses
);
CREATE VIEW Secured.vProducts
AS
      SELECT ProductId, Name, Price, WarehouseId
      FROM Products
      WHERE TenantId = DATABASE_PRINCIPAL_ID();
CREATE TABLE Products
(
      TenantId INT NOT NULL
            DEFAULT (DATABASE_PRINCIPAL_ID()),
      ProductId INT NOT NULL IDENTITY(1,1),
      PRIMARY KEY(TenantId, ProductId),
      Name NVARCHAR(64) NOT NULL,
      Price DECIMAL(19,4) NOT NULL,
      WarehouseId INT NOT NULL,
      FOREIGN KEY ( TenantId, WarehouseId )
            REFERENCES Warehouses
);
CREATE VIEW Secured.vProducts
AS
      SELECT ProductId, Name, Price, WarehouseId
      FROM Products
      WHERE TenantId = DATABASE_PRINCIPAL_ID();
EXECUTE AS USER = 'TenantA';

SELECT * FROM vProducts;
INSERT vProducts VALUES('Basketball', 55, 2);
CREATE PROC Secured.GetProductsWithState
      @State INT
AS
BEGIN
...
END
Tylko osobne bazy/osobny schemat
Prostota
Operacje DDL
Nie potrzeba metadanych, ale może być
trudniejsze do realizacji po stronie aplikacji
   Osobne codebase’y
Predefiniowane pola
  np. 3 stringi 2 liczby
Niepotrzebne zużycie miejsca, gdy któryś z
tenantów nie używa pola
  SPARE Columns
A co gdy tenant potrzebuje 4 stringi?
Wariacje:
  Trzymanie danych jako string + metadane typu
Skomplikowane, ale podobnego
mechanizmu używa SalesForce
Dane trzymane są nie w jednym wierszu, ale
w kilku
  brak ograniczenia na liczbę dodatkowych pól
Gorsza wydajność, niż w Zaalokowanych
polach
  występuje dużo randomowych operacji w bazie
  danych
Słabe wsparcie narzędzi, np. raportów
Dobre, gdy konfiguracja jest wymagana na
poziomie instancji encji
Dobre dla danych „rzadkich”
Prosta implementacja
PaaS - Platform As A Service
HaaS - Hardware As A Service
IaaS - Infrastructure As A Service
“Blue Cloud” by IBM
Simple Storage Service (Amazon S3),
Elastic Computing Cloud (Amazon EC2)
Google computing services
Microsoft Azure
SaaS
  Wymaga obniżenia kosztu produkcji
  4 modele dojrzałości
  Wyzwania dla architektury:
       Konfiguracja – reguły, elastyczny model danych
       Multitenancy – jedna instancja, wielu klientów
       Skalowalność
http://www.sztronka.com
http://code.google.com/p/businessframework/
http://www.salesforce.com/au/assets/pdf/Forc
e.com_Multitenancy_WP_101508.pdf
http://msdn.microsoft.com/en-
us/library/aa479086.aspx
http://www.antlr.org/
kontakt@machmichal.pl
www.macmichal.pl

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

SaaS - Architektura Multitenant

  • 1. Michał Mac Architekt MCPD Win Developer, MCITP DBA, Developer
  • 2.
  • 3. Długi ogon/SaaS Reguły biznesowe Rozszerzalnośd danych Pojemnik na dane Sql Server
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. $ / Klient Najwięksi klienci Co jeśli obniżymy koszt wyprodukowania i dostarczenia oprogramowania? Typowi klienci Nowy rynek >> aktualny rynek Rynek (aktualnie) poza zasięgiem
  • 10.
  • 11.
  • 12. 7 6 5 4 3 2 1 0 Sprzęt Ludzie Software
  • 13. Dostawca może zainwestować w olbrzymie Data-Center
  • 14. Microsoft Data Center (Chicago, IL) Koszt inwestycji $500m, wielkość 10 boisk football
  • 15. Nie kupuje sprzętu Nie instaluje oprogramowania Nie ponosi dużego kosztu na starcie Model abonamentowy Reklamy
  • 16. Ciągłe i stałe przychody Lepsza ochrona własności intelektualnej Aktualizacje aplikacji odbywają się centralnie
  • 17. 7 6 5 4 3 2 1 0 Sprzęt Ludzie Software
  • 18. 7 6 5 4 3 2 1 0 Sprzęt Ludzie Software
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 25.
  • 26.
  • 27. Wymienialne reguły biznesowe Rozszerzalny model danych Konfigurowalny interfejs Multitenancy
  • 28.
  • 29.
  • 30. Wymienialne reguły biznesowe Rozszerzalny model danych Konfigurowalny interfejs Multitenancy
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. Reużywalne Automatyczna detekcja zależności Expression Trees Reguły walidacyjne Możliwość dodawania z zewnątrz Prosty tekstowy język – Formula Antlr + Expression Trees
  • 36.
  • 37.
  • 38. Realizacja Słownik ExpandoObject - .Net 4.0 Dynamiczny interfejs użytkownika Metadane per tenant Same dane nie wystarczą. Wymagana możliwość używania w regułach biznesowych Baza danych – w następnej części
  • 39.
  • 40.
  • 41. Prosta rozszerzalność Prosta strategia backupów Bezpieczeństwo, izolacja Bankowość, branża medyczna Większe koszty – zużyte zasoby Auto close może zwiększyć ten limit, ale pogarsza czas dostępu Premiun approach
  • 42.
  • 43. Łatwa implementacja i rozszerzalność Średni poziom izolacji Utrudniony backup/restore Niższe koszty, bo więcej tenantów na jednej bazie Operacje DDL, które blokują katalog systemowy
  • 44.
  • 45. Najniższe koszty sprzętu per tenant Możliwość dostarczenia drogich mechanizmów wysokiej dostępności po korzystnych cenach. Problemy z backupe/restorem Większe koszty produkcji aplikacji Należy zapewnić bezpieczeństwo, nawet w przypadku nieprzewidzianego błędu Tenant Data Encryption Tenant View Filter Możliwość partycjonowania per tenant
  • 46.
  • 48. Framework agnostic Transparentność Bezpieczeństwo Ewentualny błąd programisty nie może ujawnić danych innego Używanie pooli połączeń Wydajność
  • 49.
  • 50. CREATE USER TenantA WITHOUT LOGIN WITH DEFAULT_SCHEMA = Secured; GRANT SELECT, EXECUTE, INSERT, UPDATE, DELETE ON SCHEMA::[Secured] TO TenantA;
  • 51. CREATE TABLE Products ( ProductId INT NOT NULL IDENTITY(1,1) PRIMARY KEY, Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL REFERENCES Warehouses, );
  • 52. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1) PRIMARY KEY, Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL REFERENCES Warehouses, );
  • 53. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1) PRIMARY KEY, Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL REFERENCES Warehouses, );
  • 54. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1), PRIMARY KEY(TenantId, ProductId), Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL REFERENCES Warehouses, );
  • 55. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1), PRIMARY KEY(TenantId, ProductId), Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL REFERENCES Warehouses, );
  • 56. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1), PRIMARY KEY(TenantId, ProductId), Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL, FOREIGN KEY ( TenantId, WarehouseId ) REFERENCES Warehouses );
  • 57. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1), PRIMARY KEY(TenantId, ProductId), Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL, FOREIGN KEY ( TenantId, WarehouseId ) REFERENCES Warehouses );
  • 58. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1), PRIMARY KEY(TenantId, ProductId), Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL, FOREIGN KEY ( TenantId, WarehouseId ) REFERENCES Warehouses ); CREATE VIEW Secured.vProducts AS SELECT ProductId, Name, Price, WarehouseId FROM Products WHERE TenantId = DATABASE_PRINCIPAL_ID();
  • 59. CREATE TABLE Products ( TenantId INT NOT NULL DEFAULT (DATABASE_PRINCIPAL_ID()), ProductId INT NOT NULL IDENTITY(1,1), PRIMARY KEY(TenantId, ProductId), Name NVARCHAR(64) NOT NULL, Price DECIMAL(19,4) NOT NULL, WarehouseId INT NOT NULL, FOREIGN KEY ( TenantId, WarehouseId ) REFERENCES Warehouses ); CREATE VIEW Secured.vProducts AS SELECT ProductId, Name, Price, WarehouseId FROM Products WHERE TenantId = DATABASE_PRINCIPAL_ID();
  • 60. EXECUTE AS USER = 'TenantA'; SELECT * FROM vProducts; INSERT vProducts VALUES('Basketball', 55, 2);
  • 61. CREATE PROC Secured.GetProductsWithState @State INT AS BEGIN ... END
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67. Tylko osobne bazy/osobny schemat Prostota Operacje DDL Nie potrzeba metadanych, ale może być trudniejsze do realizacji po stronie aplikacji Osobne codebase’y
  • 68.
  • 69. Predefiniowane pola np. 3 stringi 2 liczby Niepotrzebne zużycie miejsca, gdy któryś z tenantów nie używa pola SPARE Columns A co gdy tenant potrzebuje 4 stringi? Wariacje: Trzymanie danych jako string + metadane typu Skomplikowane, ale podobnego mechanizmu używa SalesForce
  • 70.
  • 71. Dane trzymane są nie w jednym wierszu, ale w kilku brak ograniczenia na liczbę dodatkowych pól Gorsza wydajność, niż w Zaalokowanych polach występuje dużo randomowych operacji w bazie danych
  • 72.
  • 73. Słabe wsparcie narzędzi, np. raportów Dobre, gdy konfiguracja jest wymagana na poziomie instancji encji Dobre dla danych „rzadkich” Prosta implementacja
  • 74.
  • 75. PaaS - Platform As A Service HaaS - Hardware As A Service IaaS - Infrastructure As A Service “Blue Cloud” by IBM Simple Storage Service (Amazon S3), Elastic Computing Cloud (Amazon EC2) Google computing services Microsoft Azure
  • 76. SaaS Wymaga obniżenia kosztu produkcji 4 modele dojrzałości Wyzwania dla architektury: Konfiguracja – reguły, elastyczny model danych Multitenancy – jedna instancja, wielu klientów Skalowalność
  • 77.

Editor's Notes

  1. Większe możliwości sprzętowe producenta – high availability