Think Big, Skalierbare Anwendungen mit Azure

Werbung
Persönlichkeiten bei bluehands
Aydin Mir Mohammadi
bluehands
Think Big
Technologien bei bluehands
Aydin Mir Mohammadi
bluehands
Think Big
Think Big
Skalierbare Anwendungen mit Windows Azure
Aydin Mir Mohammadi
bluehands GmbH & co.mmunication KG
[email protected]; posts.bluehands.de/am
1
2
3
4
5
6
7
8
9
Immer mehr…
bluehands
Mehr Performance
Mehr Menge
Mehr Verfügbarkeit
Aydin Mir Mohammadi
Think Big
Skalierung
bluehands
http://www.flickr.com/photos/39901968@N04/4864698533/
Vertikale Skalierung
Aydin Mir Mohammadi
Horizontale Skalierung
Think Big
Agenda
bluehands
Pattern
Azure Basics
Map-Reduce
Request/Response
Batch-Processing - Messaging
Demo
Storage
Chatty/Chunky
Datenbank Skalierung
CAP-Theorem
Strategien
Zahlen
spiele
Daten
nähe
Sharding
Federation
Aydin Mir Mohammadi
Verteilte Daten
RDBMS
Think Big
bluehands
Pattern
1
2
3
4
5
6
7
8
9
Think Big
Pipes & Filter
bluehands
Web
Legacy App
Channel4
Channel3
Translator
Adapter
Channel1
Router/
Orchestration
Channel5
Storage
Channel2
From Jörg Jooss & Holger Sirtl
Aydin Mir Mohammadi
Endpoint
Service App
Think Big
Pattern: Request/Response
bluehands
Load-Balancer
Service App
Service App
Service App
Cache
State & Data Storage
Aydin Mir Mohammadi
Think Big
Pattern: Request/Response
bluehands
• Absoluter Klassiker
• Application-State am besten beim
Client
– Alternative: Session-Server (Cache)
– Alternative: Instanz nicht balancen
• Daten im Cache, sonst Storage
Aydin Mir Mohammadi
Think Big
Pattern: Request/Response
bluehands
• Skalierung wird verlagert auf
– Cache
– Storage
• Größtes Problem
– Cache Invalidisierung
Aydin Mir Mohammadi
Think Big
Pattern: Request/Response
Load-Balancer
Immer
dabei
Web-Role,
App-Fabric,
Service Bus
Service App
Cache
bluehands
App-Fabric
Cache, Table
Sql, Table, Blob
Storage
Und viel
mehr
Aydin Mir Mohammadi
Think Big
Pattern: Messaging
bluehands
Load-Balancer
Service App
Service App
Service App
Queue
Worker
Sql-Azure
Aydin Mir Mohammadi
Worker
Worker
Table-Storage
Worker
Worker
Blob-Storage
Think Big
Pattern: Messaging
bluehands
• Absoluter Klassiker
• Beste Skalierung
• Kann mit Request/Response
kombiniert werden
• Auch hier gilt: Skalierung hängt am
Storage
Aydin Mir Mohammadi
Think Big
bluehands
Demo
Azur Basics
1
2
3
4
5
6
7
8
9
Think Big
Binsenweisheit
bluehands
• Am Ende hängt es an den Daten
– Klassische Datenbanken skalieren nicht
Aydin Mir Mohammadi
Think Big
RDBMS: Performance no. clients
bluehands
3 Instances
5,00
4,00
3,00
2,00
1,00
12 Instances
0,00
5,00
4,50
4,00
3,50
3,00
2,50
2,00
1,50
1,00
0,50
0,00
Aydin Mir Mohammadi
Think Big
RDBMS: Performance no. clients
bluehands
2,00
1,80
1,60
1,40
1,20
1,00
0,80
0,60
0,40
0,20
0,00
1
Aydin Mir Mohammadi
3
6
12
Think Big
Binsenweisheit
bluehands
• Man muss die Daten „verteilen“
– Willkommen in der Hölle
Aydin Mir Mohammadi
Think Big
CAP-Theorem
bluehands
• Betrifft ein System mit verteilten
Daten.
• Betrachtet folgende Eigenschaften
– Consistency: Alle sehen gleichzeitig das
gleiche
– Availability: Alle können lesen & schreiben
– Partition Tolerance: Ausfall eines Knotens
führt nicht zum Ausfall des Systems
Aydin Mir Mohammadi
Think Big
CAP-Theorem: Wähle 2 aus 3
Consitency
bluehands
ACID oder
eventualy
Consistent
Antwort
Verhalten
Availabilty
Aydin Mir Mohammadi
Partion
Tolerance
Think Big
CAP-Theorem: Beispiele
bluehands
• Oracle Cluster (RAC)
– Kein CAP-Theorem, da nicht verteilt
• Datenbank Mirroring (Log-Shipping)
– Synchrone Commits: CA
– Asynchrone Commits & Sync: AP
• Partitionierung
– Sharding & Federation: CA
Aydin Mir Mohammadi
Think Big
State & Pub/Sub Server:
Async Commit
Client
<Cmd>
Client
<Query>
<Cmd>
State/Data
Aydin Mir Mohammadi
Client
<Cmd>
<Cmd>
<Cmd>
<Cmd>
Prozessor
bluehands
Prozessor
<Cmd>
State/Data
Prozessor
<Cmd>
State/Data
Think Big
bluehands
Sql Azure
1
2
3
4
5
6
7
8
9
Think Big
RDBMS: Sql-Azure
bluehands
• Sql-Server in Azure
• Immer drei Knoten
– 1 Primary, 2 Standby
– 1 Sync commit, 1 async commit
• Funktional eingeschränkt
– Kein Xml
– Kein CLR
– Kein OleDB (not supported)
• It just works
Aydin Mir Mohammadi
Think Big
DBMS: Sql-Azure
bluehands
• Latenz beachten
• Licht braucht 1,8 ms
• Sql Ping ca. 15 ms
Aydin Mir Mohammadi
Think Big
Sharding
bluehands
Für Join und ref.
Integrität müssen
Mütter verteilt
werden.
Storage
Mutter
Mutter
Mutter
Storage
Kind
Mutter
Mutter
Mutter
Kind
Storage
Mutter
Mutter
Mutter
Kind
Geeignete
Aufteilung
finden
Aydin Mir Mohammadi
Think Big
Sql-Azure: Skalierung (CA)
bluehands
• Manuelles Sharding
– Daten werden auf mehrere Knoten
verteilt. Zugriff wird im Client gesteuert.
• Sql Azure Federation
– Eingebautes Sharding. Zugriff wird im
Server gesteuert, jedoch nicht
transparent.
Aydin Mir Mohammadi
Think Big
Federation
bluehands
• Limits
– Keine Transaktionen über shards. Verteilte
Transaktionen sind in Sql-Azure nicht
supported
– Kein Auto-Increment
• Vorteile gegenüber manuelles Sharding
– Online Split, Management
– Datenbank kennt die Verteilung. Shard
kann abgefragt werden
Aydin Mir Mohammadi
Think Big
Federation
bluehands
• Federation „key“ überlegen
– Über welche Eigenschaft einer Tabelle wird
verteilt
• Federations erstellen
– Man kann die einzelnen Shards immer wieder
splitten
• Sql-Statements anpassen
– Vor jedem Statement: Use Federation xxx
(key=value),with filtering=off, reset
Aydin Mir Mohammadi
Think Big
bluehands
Table Storage
1
2
3
4
5
6
7
8
9
Think Big
Table-Storage
bluehands
• Schemalos.
• Partitioniert. Jede Partition kann auf
eine andere Maschine gehalten
werden.
• Jede Entität hat ein PartitionKey und
ein RowKey
• Versionierung über Timestamp
Aydin Mir Mohammadi
Think Big
Table-Storage: How to use
bluehands
• Queries nur auf RowKey und PartionKey mit „=„
– Table-Storage ist eine Hash-Table.
– Alle andere Operationen machen einen Full-Scan.
– Evtl. PartitionKey und danach Properties
• Limits beachten
– 64k pro Eigenschaft, 1 MB pro Entität
– 5000/sec auf Account und 500/sec auf Partition
Aydin Mir Mohammadi
Think Big
Table-Storage: How to use
bluehands
• Komplizierte denormalisierte Objekte
– Z.B.: Profile, Settings
– Eher statische Entitäten
• Vorberechnete Sichten. Daten
werden je nach Anwendung
vorbereitet.
– In RDBMS: Mehrere Clustered Indizes
Aydin Mir Mohammadi
Think Big
bluehands
Blob Stroage
1
2
3
4
5
6
7
8
9
Think Big
Blob-Storage
bluehands
• „Filesystem“ in der Cloud
• Content ist von überall abrufbar
• Über http als Ressource einbinden
Aydin Mir Mohammadi
Think Big
bluehands
Query
1
2
3
4
5
6
7
8
9
Think Big
Map-Reduce
bluehands
• Idee
– Query in kleine Teile aufteilen
– Auf viele Knoten ausführen
• Voraussetzung
– Code und Daten sind nah
– D.h. Map-Reduce auf einer zentralen DB
macht in der Regel keinen Sinn
Aydin Mir Mohammadi
Think Big
Map-Reduce
bluehands
• In Linq
– map --> Enumerable.Select
– reduce --> Enumerable.Aggregate
• Mehrere Implementierungen (deprecated)
– DryadLINQ
– Daytona
• Hadoop
Aydin Mir Mohammadi
Think Big
bluehands
Kosten
1
2
3
4
5
6
7
8
9
Think Big
Kosten
bluehands
• Nicht geschenkt!
– 3 Dienste => 6 kleine Server (510,63$)
– 1 DB =>150 GB (160,12$)
– Speicher => 1.000 GB & Transkation (159,58$)
– Netzwerk => 2.000 GB (170,21$)
– Cache, Authentifizierung (~100$)
– Summe: 1.100$/Monat
• Deutlich billiger als interne IT
• Mini Website: 16$/Monat
• Table & Blob Storage deutlich billiger als Sql Azure
Aydin Mir Mohammadi
Think Big
Fazit
bluehands
• Skalierung wird einfacher
– Gleich mit designen
• Infrastruktur wird besser
– Datenbanken gehen mit
• Think Big
Aydin Mir Mohammadi
Think Big
bluehands
Fragen?
1
2
3
4
5
6
7
8
9
Think Big
Links
bluehands
• http://things.smarx.com/
• http://azuresamples.com/
• http://azurestoragesamples.codeplex.com/
• http://research.microsoft.com/enus/projects/daytona/default.aspx
• http://blogs.msdn.com/b/windowsazurestorage/archive/2010/11/
06/how-to-get-most-out-of-windows-azure-tables.aspx
• http://social.technet.microsoft.com/wiki/contents/articles/2281.fe
derations-building-scalable-elastic-and-multi-tenant-databasesolutions-with-sql-azure.aspx
• http://blogs.msdn.com/b/cbiyikoglu/
• http://developer.yahoo.com/hadoop/tutorial/index.html
Aydin Mir Mohammadi
Think Big
Herunterladen