Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Thinking in a document centric world with RavenDB by Nick Josevski

5,296 views

Published on

RavenDB presenation given at ALT.NET Melbourne Feb 2014

Published in: Technology
  • Be the first to comment

Thinking in a document centric world with RavenDB by Nick Josevski

  1. 1. Thinking in a document centric world with RavenDB
  2. 2. There’s got to be a better way, Somewhere over the…
  3. 3. We’re off to see the Wizard
  4. 4. 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
  5. 5. SOME BASIC CONCEPTS
  6. 6. 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.
  7. 7. 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
  8. 8. 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.
  9. 9. Eventual Consistency • Step 1 : Optimise for reading, • Step 2: by prioritising Availability higher than Consistency • Step 3: (Index is stale) • Step 4: Profit
  10. 10. GETTING STARTED
  11. 11. Installation
  12. 12. Raven Management Studio
  13. 13. USING RAVEN DB
  14. 14. Using Raven in your .NET Code
  15. 15. Just like any (good) ORM • Persist Document • Loading • Queries
  16. 16. Unit of Work Pattern • With IDocumentSession – Open a session of work – Make changes in memory – Persist changes
  17. 17. Search Capabilities • Search is delegated to Lucene.NET – Full text indexing
  18. 18. FETCH / QUERY
  19. 19. Session.Include • The simplest way to start retrieving documents and other associated documents
  20. 20. Session.Query • It is just LINQ • Pagination via: – .Skip() and .Take()
  21. 21. Session.Customize • As part of a query retrieve associated documents
  22. 22. 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
  23. 23. Transformers • Server side projections – with the ability load data from other documents – RavenDBs true power shining through
  24. 24. Simple Transformer
  25. 25. Real World Example
  26. 26. Real World Example
  27. 27. INDEXES
  28. 28. 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
  29. 29. Indexes • Extend Abstract Index Creation Task
  30. 30. Map / Reduce • Just like previous examples except there’s a reduce component • Most trivial examples is summing up totals/counts of items
  31. 31. Map / Reduce
  32. 32. 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
  33. 33. Multi-Map
  34. 34. Real World Example
  35. 35. PROFILING
  36. 36. Profiling is first class • Fiddler is your friend
  37. 37. 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
  38. 38. ASP.NET Profiling Integration
  39. 39. More in the REAL WORLD
  40. 40. Raven in Apps
  41. 41. Structure of our Documents • Varies and has been tuned for each use case • But can be summarised into 3 types
  42. 42. Network of Documents
  43. 43. Single Documents
  44. 44. Single Documents
  45. 45. Parent & Child Documents
  46. 46. 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
  47. 47. Deploying Indexes/Transformers
  48. 48. IOC Container Registration
  49. 49. Document Conventions
  50. 50. Projectors
  51. 51. 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
  52. 52. Thanks • Questions?

×