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.

Document Databases & RavenDB


Published on

Document Databases & RavenDB

Update -- check out my new book:
RavenDB High Performance

  • Dating direct: ❤❤❤ ❤❤❤
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❤❤❤ ❤❤❤
    Are you sure you want to  Yes  No
    Your message goes here
  • Thanks skelley24. I'm glad you like it. If you're interested in more reading, I just published a book on the topic called RavenDB High Performance.
    Are you sure you want to  Yes  No
    Your message goes here
  • Big Data is here to stay. Familiar with Mongo DB, but not so much Raven DB. Slide 19 cuts to the chase with the big data comparisons.

    I also appreciate the history and explanation of where big data is currently , where it's going, and how Raven DB fits in. Thanks.
    Are you sure you want to  Yes  No
    Your message goes here

Document Databases & RavenDB

  1. 1. Brian Ritchie Chief Architect Payformance Corporation Email: Blog: Web:
  2. 2. <ul><li>When most people say database, they mean relational database.    </li></ul><ul><li>  Why would we need to broaden our definition of a database? </li></ul><ul><li>What industry trends are challenging this venerable technology? </li></ul>
  3. 3. <ul><li>Internet Scale Systems & Large Data growth are overwhelming existing systems </li></ul>Source: IDC 2008
  4. 4. <ul><li>Data is no longer simple rows & columns </li></ul><ul><ul><li>XML </li></ul></ul><ul><ul><li>JSON </li></ul></ul><ul><li>Need flexible schemas for multi-tenant systems (SaaS) </li></ul><ul><li>Trend accelerated by individual content generation (“web 2.0”) </li></ul>
  5. 5. <ul><li>Data should be stored to meet the needs of the service not forced into a rigid structure. </li></ul>Application Application Application Application Mainframe Client-Server Database as Integration Point Service Service Service Oriented
  6. 7. <ul><li>According to </li></ul><ul><li>Next Generation Databases address some of the following points: being non-relational, distributed, open-source and horizontal scalable. The original intention has been modern web-scale databases. The movement began early 2009 and is growing rapidly. Often more characteristics apply as: schema-free, replication support, easy API, eventually consistency, and more. So the misleading term &quot;NOSQL&quot; (the community now translates it mostly with &quot;not only sql&quot;) should be seen as an alias to something like the definition above. </li></ul>
  7. 9. <ul><li>Cheap, easy to implement </li></ul><ul><li>Removes impedance mismatch between objects and tables </li></ul><ul><li>Quickly process large amounts of data </li></ul><ul><li>Data Modeling Flexibility (including schema evolution) </li></ul><ul><li>New Technology </li></ul><ul><li>Data is generally duplicated, potential for inconsistency </li></ul><ul><li>No standard language or format for queries </li></ul><ul><li>Depends on the application layer to enforce data integrity </li></ul>
  8. 10. <ul><li>Document (MongoDB, CouchDB, RavenDB) </li></ul><ul><li>Graph (Neo4J, Sones) </li></ul><ul><li>Key/Value (Cassandra, SimpleDB, Dynamo, Voldemort) </li></ul><ul><li>Tabular/Wide Column (BigTable, Apache Hbase) </li></ul><ul><li> </li></ul>
  9. 11. <ul><li>Documents </li></ul><ul><ul><li>JSON, or derivatives </li></ul></ul><ul><ul><li>XML </li></ul></ul><ul><li>Schema free </li></ul><ul><li>Documents are independent </li></ul><ul><li>Non relational </li></ul><ul><li>Run on large number of machines </li></ul><ul><li>Data is partitioned and replicated among these machines </li></ul>
  10. 12. <ul><li>A document can contain any number of fields of any length can be added to a document. Fields can also contain multiple pieces of data. </li></ul><ul><li>Examples of documents: </li></ul><ul><ul><li>FirstName=&quot;Bob&quot;, Address=&quot;5 Oak St.&quot;, Hobby=&quot;sailing&quot; </li></ul></ul><ul><ul><li>FirstName=&quot;Jonathan&quot;, Address=&quot;15 Wanamassa Point Road&quot;, Children=(&quot;Michael,10&quot;, &quot;Jennifer,8&quot;, &quot;Samantha,5&quot;, &quot;Elena,2&quot;) </li></ul></ul><ul><li> </li></ul>
  11. 13. <ul><li>A few of the top document databases are CouchDB, RavenDB, and MongoDB. </li></ul><ul><li>CouchDB is an Apache project created by Damien Katz (built using Erlang) and just reached a 1.0 status.  </li></ul><ul><li>RavenDB is built on using C# and has some interesting extension capabilities using .NET classes.  RavenDB was created by Ayende Rahien. </li></ul><ul><li>MongoDB is written in C++ and provides some unique querying capabilities.  MongoDB was originally developed by 10gen. </li></ul>
  12. 14. <ul><li>Objects can be stored as documents </li></ul><ul><li>Documents can be complex </li></ul><ul><li>Documents are independent </li></ul><ul><li>Open Formats </li></ul><ul><li>Schema free </li></ul>
  13. 15. <ul><li>A few examples… </li></ul><ul><li>Large Data Sets </li></ul><ul><li>Web Related Data </li></ul><ul><li>Customizable Dynamic Entities </li></ul><ul><li>Persisted View Models </li></ul>
  14. 16. <ul><li>Instead of recreating the view model from scratch on every request, you can store it in its final form </li></ul>Utilized by CQRS (Command Query Responsibility Segregation)
  15. 17. <ul><li>Built on existing infrastructure (ESENT) that is known to scale to amazing sizes </li></ul><ul><li>Not just a server. You can easily (trivially) embed Raven inside your application. </li></ul><ul><li>It’s transactional. That means ACID, if you put data in it, that data is going to stay there. </li></ul><ul><li>Supports System.Transactions and can take part in distributed transactions. </li></ul><ul><li>Allows you to define indexes using Linq queries. </li></ul><ul><li>Supports map/reduce operations on top of your documents using Linq. </li></ul><ul><li>Comes with a fully functional .NET client API, which implements Unit of Work, change tracking, read and write optimizations, and a bunch more. </li></ul>
  16. 18. <ul><li>Nice web interface allowing you to see, manipulate and query your documents. </li></ul><ul><li>Is REST based, so you can access it via the java script API directly. </li></ul><ul><li>Can be extended by writing MEF plugins. </li></ul><ul><li>Has trigger support that allow you to do some really nifty things, like document merges, auditing, versioning and authorization. </li></ul><ul><li>Supports partial document updates, so you don’t have to send full documents over the wire. </li></ul><ul><li>Supports sharding out of the box. </li></ul><ul><li>Is available in both OSS and commercial modes. </li></ul><ul><li> </li></ul>
  17. 21. <ul><li>HTTP </li></ul><ul><li>.NET with JSON </li></ul><ul><li>.NET with objects </li></ul>
  18. 22. <ul><li>HTTP API </li></ul><ul><li>curl -X PUT http://localhost:8080/docs/bob -d &quot;{ Name: 'Bob', HomeState: 'Maryland', ObjectType: 'User' }&quot; </li></ul><ul><li>curl -X GET http://localhost:8080/docs/bob </li></ul><ul><li>DEMO </li></ul>
  19. 23. <ul><li>C# JSON API </li></ul><ul><li>var client = new ServerClient(&quot; http://localhost:8080 &quot;, null, null); </li></ul><ul><li>client.Put(&quot;bob&quot;, null, JObject.Parse(&quot;{ Name: 'Bob', HomeState: 'Maryland', ObjectType: 'User' }&quot;), null); </li></ul><ul><li>JsonDocument jo = client.Get(“bob”); </li></ul><ul><li>DEMO </li></ul>
  20. 24. <ul><li>C# Class API </li></ul><ul><li>var ds = new DocumentStore() { Url = &quot;http://localhost:8080&quot; }; </li></ul><ul><li>var entity = new User() { Name = &quot;Bob&quot;, HomeState = &quot;Maryland&quot; }; </li></ul><ul><li>using (var session = ds.OpenSession()) </li></ul><ul><li>{ </li></ul><ul><li>session.Store(entity); </li></ul><ul><li>session.SaveChanges(); </li></ul><ul><li>} </li></ul><ul><li>DEMO </li></ul>
  21. 25. <ul><li>Brings order in schema-free world </li></ul><ul><li>Materialized views </li></ul><ul><li>Built in the background </li></ul><ul><li>Allow stale reads </li></ul><ul><li>Don’t slow down CRUD ops </li></ul><ul><li>MapReduce functions using LINQ </li></ul>
  22. 26. [ Blue ] [ Red ] [ Blue,1 ] [ Red,1 ] [ Orange ] [ Blue ] [ Blue ] [ Orange ] [ Orange,2 ] [ Blue,2 ] [ Red,1 ] [ Orange,2 ] [ Blue,3 ]
  23. 28. <ul><li>The CAP theorem ( Brewer ) states that you have to pick two of Consistency , Availability , Partition tolerance : You can't have the three at the same time and get an acceptable latency. </li></ul><ul><ul><li>Consistency means that each client always has the same view of the data. </li></ul></ul><ul><ul><li>Availability means that all clients can always read and write. </li></ul></ul><ul><ul><li>Partition tolerance means that the system works well across physical network partitions. </li></ul></ul><ul><li>Eventual consistency relaxes consistency for availability & partition tolerance. By doing this it also gains scalability. </li></ul>
  24. 30. <ul><li>Replication </li></ul><ul><li>Sharding </li></ul><ul><li>Extensibility </li></ul>
  25. 31. <ul><li>Implemented as a plug-in (Raven.Bundles.Replication.dll) </li></ul><ul><ul><li>Tracks the server the document was originally written on. </li></ul></ul><ul><ul><li>The replication bundle uses this information to determine if a replicated document is conflicting with the existing document. </li></ul></ul><ul><li>Supported by the client API </li></ul><ul><ul><li>Detects that an instance is replicating to another set of instances. </li></ul></ul><ul><ul><li>When that instance is down, will automatically shift to the other instances. </li></ul></ul>
  26. 32. Given this document… And this index… Gives this table output
  27. 33. <ul><li>Sharding refers to horizontal partitioning of data across multiple machines. </li></ul><ul><li>The idea is to split the load across many commodity machines, instead of buying huge expensive machines. </li></ul><ul><li>Raven has full support for sharding, and you can utilize sharding out of the box. </li></ul>
  28. 34. <ul><li>MEF (Managed Extensibility Framework) </li></ul><ul><li>Triggers </li></ul><ul><ul><li>PUT triggers </li></ul></ul><ul><ul><li>DELETE triggers </li></ul></ul><ul><ul><li>Read triggers </li></ul></ul><ul><ul><li>Index update triggers </li></ul></ul><ul><li>Request Responders </li></ul><ul><li>Custom Serialization/Deserialization </li></ul>
  29. 35. <ul><li>Raven DB Home Page </li></ul><ul><li>Raven DB: An Introduction </li></ul><ul><li>Herding Code 83: Ayende Rahien on RavenDB </li></ul><ul><li>Raven posts from Ayende Rahien </li></ul><ul><li>Raven posts from Rob Ashton </li></ul><ul><li>My blog </li></ul><ul><li>ESENT (Raven DB’s storage engine) </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul>