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!
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
Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world
There’s got to be a better way,
Somewhere over the…
• Partition Tolerance
• When you suffer a network partition between stores.
• You decide how much Consistency OR Availability you would
like to have.
Documents are not flat
• A single document can be a complex object
• 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
More info on this at: http://ravendb.net/docs/theory/document-structure-design
• In RavenDB
– Writes occur against the document store.
– Queries occur against the index store.
– Single Load operations go directly to the
• RavenDB is more consistent than others
• Also: not all viewers of data should be
• Step 1 : Optimise for reading,
• Step 2:
by prioritising Availability
higher than Consistency
• Step 3:
(Index is stale)
• Step 4:
• The simplest way to start retrieving
documents and other associated documents
• It is just LINQ
• Pagination via:
– .Skip() and .Take()
• As part of a query retrieve associated
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
• Server side projections
– with the ability load data from other documents
– RavenDBs true power shining through
• 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
More Info / Sources
Tekpub (series now on Pluralsight)
RavenDB High Performance by Brian Ritchie
NoSQL video from Martin Fowler
• Reach out to me Nick Josevski
– 1st video recording of this: