2011-12-13 nosql aus der praxis
Post on 27-Jan-2015
110 Views
Preview:
DESCRIPTION
TRANSCRIPT
13.12.2011 Dipl.-Inf. (FH) Johannes Hoppe M.Sc. Johannes Hofmeister
aus der Praxis
Johannes Hofmeister .NET Domänenexperte
www.twitter.com/pro_cessor
Not only SQL
01
2002 2004 2006 2008 2010 2012
Daten
Daten › Facebook hat 60k Server (2010)
› Google hat 450k Server (2006)
› Microsoft: hat 100k - 500k Server (seit Azure)
Facebook Server Footprint
Trend 1: increasing data sizes
Trend 2: more connectedness (“web 2.0”)
Trend 3: more individualization (fever structure)
verteilte und horizontale Skalierbarkeit
kein relationales Datenmodell (kein SQL)
schemafrei / schwache Schemarestriktionen
anderes Konsistenzmodell
Scale-up Vertikale Skalierung
Server auf mehr Leistungsfähigkeit trimmen
Scale-out horizontale Skalierung
Einfügen von Nodes (Rechnerknoten)
Schemafrei kein ALTER TABLE
kein Wartungsfenster *
Datenversionierung im Code!
* morgens ausschlafen
Anforderungen
an ein verteiltes System
Consistency Konsistenz
AvailabilityVerfügbarkeit
Partition
Tolerance 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
Kategorisierung › Key-Value stores
› Document stores
› Wide Column stores
› Graphdatenbanken
› weitere
MongoDB
02
“Deployment” › Standardverzeichnis erstellen: c:\data\db
› 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 the shell)
› db.people.save({name: 'Smith', age: 30});
See how the save command works:
› db.foo.save
CRUD – Create …with a bit JavaScript
for(i=0; i<1000; i++) {
['quiz', 'essay', 'exam'].forEach(function(name) {
var score = Math.floor(Math.random() * 50) + 50;
db.scores.save({student: i, name: name, score: score});
});
}
db.scores.count();
CRUD – Read Queries are specified using a document-style syntax!
› db.scores.find();
› db.scores.find({score: 50});
› db.scores.find({score: {"$gte": 70}});
› db.scores.find({score: {"$gte": 70}});
CRUD – Update
› db.people.update({name: 'Smith'}, {'$set': {interests: []}});
› db.people.update({name: 'Smith'},
{'$push': {interests: ['chess']}});
CRUD – Delete
› db.dropDatabase();
› db.foo.drop();
› db.foo.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
https://webnote.codeplex.com
RavenDB
03
NoSQL
Raven Db Documentation – All you need to know
http://beta.ravendb.net/docs
JSON Transactional
LINQ Lucene
100% .NET AGPL / dual
RavenDb › Written by Oren Eini aka Ayende Rahien
› Hibernating Rhinos
› Rhino Mocks & Rhino.ServiceBus
› Written in C#
Deployment › Get it via NuGet
› Change defaults in Raven.Server.exe.config
› It’s safe by default
› Just run the Raven.Server.exe in the /server/ folder
Safe by default › Useful defaults
› E.g. Limited page size – No Accidental SELECT *
› ACID
› Client / Server
› Cross shard
Units › Documents
› Collections
› Indexes
› Attachments
Designed to “just work” › Schema Free
› Hardly any mapping required
› dynamic (C# 4) yields great power
Designed to “just work” › Sleek Client API
› Fluent API
› Unit of Work Pattern
› Extensible – Plugin Support
Makes developers happy › Testable
› Interfaces all over
› In-Memory Database
› Extensible – Plugin Support
APIs › Native .NET Client API
› HTTP API (Pseudo REST)
Indexes › Written as Linq Queries
› Indexed with Lucene .NET
› Lucene Syntax for querying
“While being RESTful is a goal of the
HTTP API, it is secondary to the goal of
exposing easy to use and powerful
functionality” Ayende Rahien on the HTTP API - http://ravendb.net/documentation/docs-http-api-restful
HTTP API › Caching
› E-Tags
› Lucene Queries possible
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
Lucene Style var notes = session.Advanced .LuceneQuery<Note>() .Where(“Category:Important") .ToArray();
Classic Linq Style var notes = session .Query<Note>() .Where(n => n.Category == “Important") .ToArray();
Tabellen Dokumente
04
Key and Index Strategies
05
FRAGEN?
Vielen Dank! Johannes Hoppe
Johannes Hofmeister
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
top related