5. What is RavenDB?
•
•
•
•
•
•
•
It is a Document Store
Built with .NET
Fast
Easy to use / program against
Currently only runs on Windows
If you’re wondering it supports MSDTC
Open source
7. CAP Theorem
• Consistency
• Availability
• Partition Tolerance
• When you suffer a network partition between stores.
• You decide how much Consistency OR Availability you would
like to have.
8. Documents are not flat
• A single document can be a complex object
graph.
• It’s no longer a challenge to store your data
• You’re no longer in a relational world
– Schema-free data store
– Does not mean chaos as some would lead you to
believe
More info on this at: http://ravendb.net/docs/theory/document-structure-design
9. Eventual Consistency
• In RavenDB
– Writes occur against the document store.
– Queries occur against the index store.
– Single Load operations go directly to the
document store.
• RavenDB is more consistent than others
• Also: not all viewers of data should be
considered equal.
10. Eventual Consistency
• Step 1 : Optimise for reading,
• Step 2:
by prioritising Availability
higher than Consistency
• Step 3:
(Index is stale)
• Step 4:
Profit
23. Safe by Default
• 3 magic numbers to help you out
– Default page size limit 128
– Take(n > 1024) is still 1024
– Requests 30
• Why so many calls?
•
Overridable via configuration, for those SELECT * FROM addicts
24. Transformers
• Server side projections
– with the ability load data from other documents
– RavenDBs true power shining through
29. Indexes
• With the power of schema-less store
• Comes great (some) responsibility
• Raven doesn’t know about fields on your
document by default
• So if you haven’t set up indexes raven will help
you out
33. Multi-Map
• Querying Unlike Documents
• To build up something that doesn’t exist
• We’re working with documents
– No need for left/inner/outer/right/middle joins
38. ASP.NET Profiling Integration
• For your ASP.NET MVC App
1.
2.
3.
•
In Global.asax.cs
In _layout.cshtml
Demo app up at: https://github.com/NickJosevski/ravendb-presentation
47. 4th type and no longer used
• When we started with Raven
• We started down a path of “Summary”
Documents
– Which became a problem to maintain
• Replaced with Transformers outputting
SummaryDTOs
52. More Info / Sources
•
•
•
•
http://ravendb.net/
Tekpub (series now on Pluralsight)
RavenDB High Performance by Brian Ritchie
NoSQL video from Martin Fowler
– http://www.youtube.com/watch?v=qI_g07C_Q5I
• Reach out to me Nick Josevski
– 1st video recording of this:
– http://www.youtube.com/watch?v=u3kUpFlf76M
Solutions to a lot of software development problems still get solved using relational databases as a default
I’m going to take you on a journey
There’s a wonderful place where interacting with your DataStore is no longer a frustration.
Document Store.NETFast & Easy to use/program against
It’s not one over the other.It can’t be a talk in the noSQL space without bringing this up.
Does not mean ChaosSpend the time to think about structureSchema-free data store, that doesn't mean that you shouldn't take some time to consider how to design your documents to ensure that you can access all the data that you need to serve user requests efficiently, reliably and with as little maintainability cost as possible.
Explain the 2 stores.Writes are ASYNCPerformance gain – Writes don’t hold up reads use the apple inventory example here.Index is set as stale when a write has happened, and Raven is updating the index. Not the same EC like in Casandra where in those it's about writes.It is optimized for reads by prioritizing Availability higher than Consistency. RavenDB is not unique in this regard, but it is somewhat special in that it still has the ability to be consistent. If you are retrieving single document, such as reviewing an order or an end user viewing their profile, these operations are ACID compliant, and are not affected by the "eventual consistency" design.
To summariseRemember this does not mean “lack of consistency” it simply means prioritised over.A sales person goes to a "products list" page that is sorted alphabetically.On the first page, they see that "Apples" aren't currently being sold.So they click "add product", and go to a new page where they enter "Apples".They are then returned to the "products list" page and they still don't see any Apples because the index is stale. WTF - right?Embrace this and you’ll be a much happier software developer!
Open up raven management studio
NUGET and you’re done!
Sesion is Raven.Client.IDocumentSessionQueries with Linq. In fact you don’t need an ORM like EF/Nhib you just write linqepressions after you include the Raven.Client assembly.If you’ve ever used any kind of ORM, this is very straight forwardBasicsStore,Retrieve,Query
Use of raven document session followsUnit of Work pattern
Delegated to LucenePowerful search engine (a whole different talk)
Not joins, forget about joins.On like 24 we’re linking to a very common external document, one that represents a user (in this case an assignee)On line 25 we’re linking out to another separately stored document participants
Standard paging by usingResults Per Page & Page Number
Show fiddlerNEED A LESS CONFUSING LIST OF .Customize() calls
Don’t shoot your own foot off128 = default page size1024 = page size limit as per safe by default30 is the hey why are you talking to raven so much over the wire
Are awesome!Server side projectionsWith loading!Run inside raven!
Simple Mapping
We can come back to this slide if people are interested.I wanted to include it, if this came up as a question, or at least to give a glimpse of their power
The nested transformer
Remember at the start I mentioned we have the ‘document store’ and the ‘index store’
You should set up your own indexes, here’s how you do it
Need a more interesting example
Sorry but this is it, our example of map reduce is quite complex
Like a viewOur library (DAM) is a good example, a variety of items get organised into buckets, but we need to show them all together, the user doesn’t care what it technically is while browsing around
That leads into Multi-Map
Fiddler is your friend
This is where you go and find your indexes that extend Abstract Index Creation TaskAnd the transformers
Autofac registration code.The lines of note are 86 – pulling from a configuration the location of the databaseLine 92 our replication setup96-100 port exhaustion issue we saw in production109-111 regular Autofac lifetime management
With the help of IoC when an event occurs in our CQRS style applicationA projector will get given the correct document from raven, we simply manipulate that documentWhen the raven session ends (request ends) the changes get savedLines of note 31: our tie/link to an event stream aggregate33-36 onevent handlers39 simplest example45 one of these per