VISUAL STUDIO FÜR WINDOWS-ENTWICKLER
30.-31. JAN. 2012, MÜNCHEN




                                  in .NET mit RavenDB und MongoDB

31.01.2012
Dipl.-Inf. (FH) Johannes Hoppe



Partner:                                           Veranstalter:
Johannes Hoppe
  .NET Webentwickler
 www.johanneshoppe.de
01
Not only SQL
Daten




 2002   2004   2006   2008   2010   2012
Trend 1: wachsende Datenmengen
Trend 2: mehr Vernetzung (“web 2.0”)
Trend 3: mehr Individualisierung (weniger Struktur)
Scale-up
Vertikale Skalierung
Server auf mehr Leistungsfähigkeit trimmen
Scale-out
horizontale Skalierung
Einfügen von Nodes (Rechnerknoten)
verteilte und horizontale Skalierbarkeit
kein relationales Datenmodell (kein SQL)
schemafrei / schwache Schemarestriktionen
anderes Konsistenzmodell
Schemafrei
kein ALTER TABLE
kein Wartungsfenster *
Datenversionierung im Code!




* morgens ausschlafen
Anforderungen
an ein verteiltes System




                           Consistency
                                  Konsistenz




               Partition
                                           Availability
               Tolerance                       Verfügbarkeit
                Ausfalltoleranz
CAP Theorem
›   2000: E. Brewer, N. Lynch
›   You can satisfy

    at most 2 out of the 3 requirements
Consistency
›   The system is in a consistent state after an operation
›   All clients see the same data
›   Strong consistency (ACID)
    vs. eventual consistency (BASE)



    ACID: Atomicity, Consistency, Isolation and Durability
    BASE: Basically Available, Soft state, Eventually consistent
Availability
›   System is “always on”, no downtime
›   Node failure tolerance
    – all clients can find some available replica
›   Software/hardware upgrade tolerance
Partition tolerance
›   System continues to function even when
    split into disconnected subsets (network disruption)
›   Not only for reads, but writes as well
“Drum prüfe,
wer sich ewig bindet.”
Friedrich Schiller
Klassifizierung
›   Key-Value stores
›   Document stores  MongoDB & RavenDB
›   Wide Column stores
›   Graph-Datenbanken
›   und viele weitere
02
Tabellen  Dokumente
https://webnote.codeplex.com
03
MongoDB
NoSQL




   MongoDB Quick Reference Cards
   http://www.10gen.com/reference
   und zum Mitnehmen!
“Deployment”
›   Standardverzeichnis erstellen:
    c:datadb
›   Server-Start: mongod.exe
›   Shell: mongo.exe
BSON         Master/Slave
JavaScript   C# Driver
Sharding     GNU AGPL
JSON  BSON
All JSON documents are stored in a binary
format called BSON. BSON supports a
richer set of types than JSON.
http://bsonspec.org
CRUD – Create
In der Shell
› use WebNote
› db.Notes.save( {Title: 'Mittag',
                  Message: 'nicht vergessen' });

So funktioniert der Befehl
› db.Notes.save
CRUD – Read
Queries werden ebenso im Dokument-Stil spezifiziert

›   db.Notes.find();
›   db.Notes.find({ Title: /Test/i });
›   db.Notes.find({ "Categories.Color": "red"}).limit(1);
CRUD – Update
›   db.Notes.update({Title: 'Test'}, {'$set': {Categories: []}});
›   db.Notes.update({Title: 'Test'},
                     {'$push': {Categories: { Color: 'Red' }}});
CRUD – Delete
›   db.dropDatabase();
›   db.Notes.drop();
›   db.Notes.remove();
“Map Reduce is the Uzi of aggregation
tools. Everything described with count,
distinct and group can be done with
MapReduce, and more.”
Kristina Chadorow, Michael Dirolf in MongoDB – The Definitive Guide
04
RavenDB
NoSQL




   Raven Db Documentation
   http://ravendb.net/docs
JSON *                           Transaktional
LINQ                             Lucene
100% .NET                        AGPL / dual


* Newtonsoft.Json.dll  JSON DOM (Raven.Json)
“Deployment”
›   Via NuGet
›   Raven.Server.exe.config anpassen
    It’s safe by default!

›   Server-Start: Raven.Server.exe
Designed to “just work”
›   Fluent API
›   Unit of Work Pattern
›   Extensible – Plugin Support
Safe by default
›   praktische defaults
    ›   z.B. Limited page size – kein unabsichtliches SELECT *
›   ACID
    ›   Client / Server
    ›   Cross shard
Indexe
›   Als Linq Queries definiert
›   Indiziert mit Lucene .NET
APIs
›   Native .NET Client API
›   HTTP API (Pseudo REST)
HTTP API
›   Caching
›   E-Tags
›   Lucene Queries möglich

C:>curl -X GET http://localhost:8080/docs/Categories/1 -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
ETag: 00000000-0000-0200-0000-000000000004
{
         "Name" : "Normal Importance",
         "Color" : "green"
}
Lucene Style Queries

Classic Linq Style                       Lucene Style
var notes = session                      var notes = session.Advanced
.Query<Note>()                           .LuceneQuery<Note>()
.Where(n => n.Category == “Important")   .Where(“Category:Important")
.ToArray();                              .ToArray();
NoSQL: Einstieg in die Welt nicht-      MongoDB:
relationaler Web 2.0 Datenbanken        The Definitive Guide




 RavenDB Mythology Documentation        MongoDB in Action
 https://s3.amazonaws.com/
 daily-builds/RavenDBMythology-11.pdf
https://webnote.codeplex.com/
VISUAL STUDIO FÜR WINDOWS-ENTWICKLER
30.-31. JAN. 2012, MÜNCHEN




                    FRAGEN?

Partner:                                       Veranstalter:
Wir sehen uns wieder!

                 Advanced Developers Conference C++
                    3. – 4. Mai 2012, Zugspitzland
                    Development for C++ Professionals!
                     www.adcpp.de



                 SharePoint Konferenz in Wien
                     19. – 20. Juni 2012, Wien
                     ppedv-Konferenz in Kooperation mit
                     Microsoft Österreich
                     www.SharePointKonferenz.at




Partner:                                          Veranstalter:
VISUAL STUDIO FÜR WINDOWS-ENTWICKLER
30.-31. JAN. 2012, MÜNCHEN




           Hat Ihnen mein Vortrag gefallen?
           Ich freue mich auf Ihr Feedback!




Partner:                                       Veranstalter:
VISUAL STUDIO FÜR WINDOWS-ENTWICKLER
30.-31. JAN. 2012, MÜNCHEN




                 Vielen Dank
                             Johannes Hoppe




Partner:                                           Veranstalter:
https://webnote.codeplex.com/
Bildnachweise
Ausgewählter Ordner © Spectral-Design – Fotolia.com
Warnhinweis-Schild © Sascha Tiebel – Fotolia.com
Liste abhaken © Dirk Schumann – Fotolia.com
Stressed businessman © Selecstock – Fotolia.com

2012-01-31 NoSQL in .NET

  • 1.
    VISUAL STUDIO FÜRWINDOWS-ENTWICKLER 30.-31. JAN. 2012, MÜNCHEN in .NET mit RavenDB und MongoDB 31.01.2012 Dipl.-Inf. (FH) Johannes Hoppe Partner: Veranstalter:
  • 2.
    Johannes Hoppe .NET Webentwickler www.johanneshoppe.de
  • 3.
  • 4.
    Daten 2002 2004 2006 2008 2010 2012
  • 5.
    Trend 1: wachsendeDatenmengen Trend 2: mehr Vernetzung (“web 2.0”) Trend 3: mehr Individualisierung (weniger Struktur)
  • 7.
    Scale-up Vertikale Skalierung Server aufmehr Leistungsfähigkeit trimmen
  • 8.
  • 9.
    verteilte und horizontaleSkalierbarkeit kein relationales Datenmodell (kein SQL) schemafrei / schwache Schemarestriktionen anderes Konsistenzmodell
  • 10.
    Schemafrei kein ALTER TABLE keinWartungsfenster * Datenversionierung im Code! * morgens ausschlafen
  • 11.
    Anforderungen an ein verteiltesSystem Consistency Konsistenz Partition Availability Tolerance Verfügbarkeit Ausfalltoleranz
  • 12.
    CAP Theorem › 2000: E. Brewer, N. Lynch › You can satisfy at most 2 out of the 3 requirements
  • 13.
    Consistency › The system is in a consistent state after an operation › All clients see the same data › Strong consistency (ACID) vs. eventual consistency (BASE) ACID: Atomicity, Consistency, Isolation and Durability BASE: Basically Available, Soft state, Eventually consistent
  • 14.
    Availability › System is “always on”, no downtime › Node failure tolerance – all clients can find some available replica › Software/hardware upgrade tolerance
  • 15.
    Partition tolerance › System continues to function even when split into disconnected subsets (network disruption) › Not only for reads, but writes as well
  • 16.
    “Drum prüfe, wer sichewig bindet.” Friedrich Schiller
  • 17.
    Klassifizierung › Key-Value stores › Document stores  MongoDB & RavenDB › Wide Column stores › Graph-Datenbanken › und viele weitere
  • 18.
  • 20.
  • 23.
  • 24.
    NoSQL MongoDB Quick Reference Cards http://www.10gen.com/reference und zum Mitnehmen!
  • 25.
    “Deployment” › Standardverzeichnis erstellen: c:datadb › Server-Start: mongod.exe › Shell: mongo.exe
  • 28.
    BSON Master/Slave JavaScript C# Driver Sharding GNU AGPL
  • 29.
    JSON  BSON AllJSON documents are stored in a binary format called BSON. BSON supports a richer set of types than JSON. http://bsonspec.org
  • 30.
    CRUD – Create Inder Shell › use WebNote › db.Notes.save( {Title: 'Mittag', Message: 'nicht vergessen' }); So funktioniert der Befehl › db.Notes.save
  • 31.
    CRUD – Read Querieswerden ebenso im Dokument-Stil spezifiziert › db.Notes.find(); › db.Notes.find({ Title: /Test/i }); › db.Notes.find({ "Categories.Color": "red"}).limit(1);
  • 32.
    CRUD – Update › db.Notes.update({Title: 'Test'}, {'$set': {Categories: []}}); › db.Notes.update({Title: 'Test'}, {'$push': {Categories: { Color: 'Red' }}});
  • 33.
    CRUD – Delete › db.dropDatabase(); › db.Notes.drop(); › db.Notes.remove();
  • 34.
    “Map Reduce isthe Uzi of aggregation tools. Everything described with count, distinct and group can be done with MapReduce, and more.” Kristina Chadorow, Michael Dirolf in MongoDB – The Definitive Guide
  • 35.
  • 36.
    NoSQL Raven Db Documentation http://ravendb.net/docs
  • 37.
    JSON * Transaktional LINQ Lucene 100% .NET AGPL / dual * Newtonsoft.Json.dll  JSON DOM (Raven.Json)
  • 38.
    “Deployment” › Via NuGet › Raven.Server.exe.config anpassen It’s safe by default! › Server-Start: Raven.Server.exe
  • 40.
    Designed to “justwork” › Fluent API › Unit of Work Pattern › Extensible – Plugin Support
  • 41.
    Safe by default › praktische defaults › z.B. Limited page size – kein unabsichtliches SELECT * › ACID › Client / Server › Cross shard
  • 42.
    Indexe › Als Linq Queries definiert › Indiziert mit Lucene .NET
  • 43.
    APIs › Native .NET Client API › HTTP API (Pseudo REST)
  • 44.
    HTTP API › Caching › E-Tags › Lucene Queries möglich C:>curl -X GET http://localhost:8080/docs/Categories/1 -i HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 ETag: 00000000-0000-0200-0000-000000000004 { "Name" : "Normal Importance", "Color" : "green" }
  • 45.
    Lucene Style Queries ClassicLinq Style Lucene Style var notes = session var notes = session.Advanced .Query<Note>() .LuceneQuery<Note>() .Where(n => n.Category == “Important") .Where(“Category:Important") .ToArray(); .ToArray();
  • 46.
    NoSQL: Einstieg indie Welt nicht- MongoDB: relationaler Web 2.0 Datenbanken The Definitive Guide RavenDB Mythology Documentation MongoDB in Action https://s3.amazonaws.com/ daily-builds/RavenDBMythology-11.pdf
  • 47.
  • 48.
    VISUAL STUDIO FÜRWINDOWS-ENTWICKLER 30.-31. JAN. 2012, MÜNCHEN FRAGEN? Partner: Veranstalter:
  • 49.
    Wir sehen unswieder! Advanced Developers Conference C++ 3. – 4. Mai 2012, Zugspitzland Development for C++ Professionals! www.adcpp.de SharePoint Konferenz in Wien 19. – 20. Juni 2012, Wien ppedv-Konferenz in Kooperation mit Microsoft Österreich www.SharePointKonferenz.at Partner: Veranstalter:
  • 50.
    VISUAL STUDIO FÜRWINDOWS-ENTWICKLER 30.-31. JAN. 2012, MÜNCHEN Hat Ihnen mein Vortrag gefallen? Ich freue mich auf Ihr Feedback! Partner: Veranstalter:
  • 51.
    VISUAL STUDIO FÜRWINDOWS-ENTWICKLER 30.-31. JAN. 2012, MÜNCHEN Vielen Dank Johannes Hoppe Partner: Veranstalter:
  • 52.
  • 53.
    Bildnachweise Ausgewählter Ordner ©Spectral-Design – Fotolia.com Warnhinweis-Schild © Sascha Tiebel – Fotolia.com Liste abhaken © Dirk Schumann – Fotolia.com Stressed businessman © Selecstock – Fotolia.com