8. CAP Theorem
2000: E. Brewer, N. Lynch
You can satisfy
at most 2
out of the 3 requirements
9. 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
10. AvailabilitySystem is “always on”, no downtime
Node failure tolerance
– all clients can find some available replica
Software/hardware upgrade tolerance
12. CAP Theorem CA› Single site clusters
(easier to ensure all nodes are always in contact)
› When a partition occurs, the system blocks
› e.g. usable for two-phase commits (2PC) which
already require/use blocks
13. CAP Theorem CA› Single site clusters
(easier to ensure all nodes are always in contact)
› When a partition occurs, the system blocks
› e.g. usable for two-phase commits (2PC) which
already require/use blocks
Obviously, any horizontal scaling strategy is based on data partitioning;
therefore, we are forced to decide between consistency and
availability.
14. CAP Theorem CP› Some data may be inaccessible (availability
sacrificed), but the rest is still consistent/accurate
› e.g. sharded database
15. CAP Theorem AP› System is still available under partitioning,
but some of the data returned my be inaccurate
› Need some conflict resolution strategy
› e.g. Master/Slave replication
26. GET & SET
In der Shell
› SET note1:title "Mittag"
› SET note1:message "nicht vergessen"
› KEYS note1:*
› GET note1:title
› DEL note1:title note1:message
37. Designed to “just work”
Schema Free
› Hardly any mapping required
› dynamic (C# 4) yields great power
38. Designed to “just work” (with .NET)
Fluent API
Unit of Work Pattern
Extensible – Plugin Support
39. Makes developers happy
› Testable
› Interfaces all over
› In-Memory Database
› Extensible – Plugin Support
40. In Memory Instance
Embedded Mode
using (var documentStore = new EmbeddableDocumentStore{
RunInMemory = true}.Initialize())
{
using (var session = documentStore.OpenSession())
{
// Run complex test scenarious
}
}
41. APIs
› Native .NET Client API
› HTTP API (Pseudo REST)
Indexes
› Written as Linq Queries
› Indexed with Lucene .NET
› Lucene Syntax for querying
42. “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
43. 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"
}
49. Database Timeline
IBM’s
IMS
Codd publishes
relational model paper
in 1970
1966 1969 1970 1985 2000 2004 2007
Agile becoming more
popular
1990’s 2009
CODASYL model
published
Term “object-oriented
database” appears
Brewer’s
CAP born
Google
BigTable
Amazon
Dynamo
Apache Cassandra
initial release
2008
MongoDB initial
release
1973 1974
INGRES
SQL
invented
1977
Oracle
founded
10gen
founded
NoSQL
Movement
74. Exercises
1. Find all scores less than 65.
2. Find the lowest quiz score. Find the highest quiz score.
3. Write a query to find all digg stories where the view
count is greater than 1000.
4. Query for all digg stories whose media type is either
'news' or 'images' and where the topic name is
'Comedy’.
5. Find all digg stories where the topic name is
'Television' or the media type is 'videos'. Skip the first 5
results, and limit the result set to 10.
76. Exercises
1. Set the proper 'grade' attribute for all scores. For
example, users with scores greater than 90 get an 'A.'
Set the grade to ‘B’ for scores falling between 80 and
90.
2. You're being nice, so you decide to add 10 points to
every score on every “final” exam whose score is
lower than 60. How do you do this update?
77. “MapReduce 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
83. “MapReduce is slower and is not
supposed to be used in ‘real time’.
You ran MapReduce as a background
job.”
Kristina Chadorow, Michael Dirolf in MongoDB – The Definitive Guide
120. Usual Problems
with Integration Tests
comfortable
managers, business constraints,
pragmatic solutions, own laziness…
Bugs will come back to haunt you!
4.
124. In Memory Instance
Embedded Mode
using (var documentStore = new EmbeddableDocumentStore{
RunInMemory = true}.Initialize())
{
using (var session = documentStore.OpenSession())
{
// Run complex test scenarious
}
}
126. NoSQL: Einstieg in die Welt
nicht-
relationaler Web 2.0
Datenbanken
MongoDB:
The Definitive Guide
MongoDB in ActionRavenDB Mythology Documentation
https://s3.amazonaws.com/
daily-builds/RavenDBMythology-11.pdf