NoSQL & RavenDB with .NET

22
NoSQL & RavenDB with .NET Venkat Somula Lead Architect WoltersKluwer (CLS – Corporate Legal Services) @vsomula September 24, 2013

description

NoSQL & RavenDB with .NET(C#) examples

Transcript of NoSQL & RavenDB with .NET

Page 1: NoSQL & RavenDB with .NET

NoSQL & RavenDB with

.NET

Venkat SomulaLead ArchitectWoltersKluwer (CLS – Corporate Legal Services)@vsomula

September 24, 2013

Page 2: NoSQL & RavenDB with .NET

What is NoSQL? NoSQL is a brand name for Non-Relational(RDBMS) databases Means

Not Only SQL No schema No relationships between entities No joins and sub queries

Some of the Characteristics of NoSQL databases Not a relational database No Schema Open Source Highly scalable and available High retrieval performance

Page 3: NoSQL & RavenDB with .NET

Why NoSQL? Flexible data model for being Schema-less Simple – just serialize objects as-is Avoid impedance mismatch between the code(object) and

data (table). One size(RDBMS) does not fit all Scalability(data distribution across multiple servers) When performance is the key - no joins To store and retrieve(quickly) millions of records with no

relations Integrated Caching Cost reduction – mostly work commodity servers Easy to program

Page 4: NoSQL & RavenDB with .NET

NoSQL Types• RavenDB• MongoDB• CouchDB• MarkLogic

DocumentDatabases

• Redis• SimpleDB(Amazon)• Dynamo

Key/Value Stores

• Cassandra• BigTable(Google)• HBase

Tabular/Wide Column

Databases

• Neo4J• Infinite Graph• InfoGrid

GraphDatabases

NoSQLDatabases

Page 5: NoSQL & RavenDB with .NET

http://ravendb.net

Page 6: NoSQL & RavenDB with .NET

What is RavenDB? A NoSQL Database Document based – data is stored as JSON Open Source Built on C# REST based Schema less Simple and feature rich

Page 7: NoSQL & RavenDB with .NET

RavenDB Features Support for multiple database hosting .NET client API for .NET platform REST API for non .NET platform Horizontal Scaling Supports ACID transactions Built-in full-text search Built-in caching Built-in sharding(split data across different servers) Built-in replication(copies of data in multiple servers) Storing of binary data(attachments, images, etc..) Support for Replication to SQL Server, Oracle, MySQL, etc.. Embedded database makes automated testing a breeze

Page 8: NoSQL & RavenDB with .NET

High Level Architecture

.NET Client App

Non .NET Client App

RavenDB Server

RESTAPI

RavenDB Server

RESTAPI

RavenDB Server

RESTAPI

DataReplication

Tasks

IndexingTasks

RavenDB

.NET Client

API

http

RavenDBManagement

Studio

Page 9: NoSQL & RavenDB with .NET

System Requirements Software

Windows .NET Framework 4.0

Hardware Minimum

2 GB of RAM 1 GHz Dual Core 1 GB of disk space

Recommended (more is better) 4 GB RAM 2 GHz Quad Core 50 GB of disk space

Page 10: NoSQL & RavenDB with .NET

RavenDB Installation RavenDB has 2 parts (RavenDB Server and RavenDB client API) Download RavenDB Server or RavenDB Embedded from

http://ravendb.net/download 4 ways to Run RavenDB server

Console application from command Prompt(Raven.Server.exe) Windows Service(Raven.Server.exe /install) Website (Configure RavenDB-Build-xxxx/Web folder as website or

virtual directory) Embedded as part of .NET application(embedded version only)

Download RavenDB client from http://ravendb.net/download OR Download as Nuget Package(search for RavenDB)

Page 11: NoSQL & RavenDB with .NET

RavenDB Management Studio

Is accessible at http://localhost:port#/raven/studio.html Available features

Create, Import, Export, and Backup database View/Edit/Delete documents Query documents Manage indexes View usage and recent queries etc.. Manage Authentication, replication, and sharding

Page 12: NoSQL & RavenDB with .NET

Data Modeling In relational modeling, every entity is stored in its own

table(to avoid duplicate data) and joins are necessary where as in NoSQL world all related information is stored in single document for fast retrieval

Relational databases are optimized for writes where as NoSQL is optimized for reads

Relational NoSQL(RavenDB-JSON)

Order Order Item

ShippingInfo

BillingInfo

TrakcingInfo

Page 13: NoSQL & RavenDB with .NET

Indexes Indexes play an important role in query performance Supports dynamic as well as static indexes Dynamic indexes get created by database automatically based

on queries but indexes are not persisted Static indexes are permanent, and can be created using code

or in the management studio(UI) Can define indexes using Linq queries Supports Map/Reduce functionality Indexes run in the background so no impact to the operations Indexes can be stale

Page 14: NoSQL & RavenDB with .NET

Security Available only with commercial license Supports 2 types of authentication

Windows Authentication OAuth Authentication(API key authentication)

Page 15: NoSQL & RavenDB with .NET

Basic Operations (using .NET Client API)

Initialize Database

Add Employee

Stored As JSON

Page 16: NoSQL & RavenDB with .NET

Basic Operations …

Load Employee

Update Employee

Page 17: NoSQL & RavenDB with .NET

Basic Operations …

Delete Employee

Query/Search Employees

Page 18: NoSQL & RavenDB with .NET

Basic Operations …Paging

Page 19: NoSQL & RavenDB with .NET

Best Practices Setup RavenDB server as IIS Website for granular

administration(load balancing, scalability, security, isolation, administration, start/stop, etc..)

Use .NET client API for .NET consumers Create static indexes for all known queries Keep in mind that indexes can be stale and design you

applications accordingly Use Includes feature to load related objects to avoid chatty

interface to database Use replication feature for high availability

Page 20: NoSQL & RavenDB with .NET

Licensing Available freely as open source under AGPL license Refer to http://ravendb.net/licensing for commercial purposes

Page 21: NoSQL & RavenDB with .NET

Use Cases Store server logs, errors, instrumentation/profiling Blogs – with comments, notes, tags, etc.. Shopping cart Complex objects with hierarchy(orders, product catalogue) High volume data (tweets, chat, comments, etc..) where query

performance is critical Click streams Big Data

Page 22: NoSQL & RavenDB with .NET

Resources Site: http://ravendb.net Twitter: @RavenDB GitHub: https://github.com/ravendb/ravendb