SlideShare une entreprise Scribd logo
1  sur  30
Being RDBMS Free
DAVID HOERSTER
2014
About Me
C# MVP (Since April 2011)
Sr. Director of Web Solutions at RGP
Conference Director for Pittsburgh TechFest
Co-Founder of BrainCredits (braincredits.com)
Past President of Pittsburgh .NET Users Group and organizer of recent Pittsburgh Code
Camps and other Tech Events
Twitter - @DavidHoerster
Blog – http://geekswithblogs.net/DavidHoerster
Email – david@agileways.com
Traditional Architecture
Data persistence is central to application
Generally monolithic
Jack of all trades; master of none
Traditional Architecture
Client
Web
Server
App
Server
Data
Repository
Data Tables
Session
Cache (?)
FT Search
What if…
We could break some pieces out
◦ Flatten structures for querying
◦ Highly efficient search services
◦ Pub/sub hubs
◦ Remote caching with excellent performance
◦ Session management outside a DB for load balanced environments
How would app then be architected?
Search
How do you search?
◦ LIKE ‘%blah%’ ?
◦ Dynamic SQL
◦ Full-Text
LIKE and Dynamic SQL can be quick to create
◦ Tough to maintain
Full-Text gives power
◦ Limited in search options
Search
Number of search services out there like
◦ Lucene
◦ Solr
Lucene is a search engine
◦ Embed in apps
◦ .NET port (Lucene.NET)
Solr is search service
◦ Built on Lucene
◦ Connect apps to it
Searching with Solr
Disconnected from your application
Search content via HTTP REST calls
Can use SolrNet as a client
◦ https://github.com/mausch/SolrNet
Document-based
Searching with Solr
private readonly ISolrOperations<T> _solr;
public SolrSearchProvider(ISolrOperations<T> solr) { _solr = solr; }
public IEnumerable<T> Query(String searchString) {
var options = new QueryOptions() {
Fields = new List<String> {"title", "body", "lastModified" }.ToArray(),
Highlight = new HighlightingParameters() {
BeforeTerm = "<strong><em>",
AfterTerm = "</em></strong>",
Fields = new List<String> { "title", "body" }.ToArray(),
Fragsize = 100
}
};
var results = _solr.Query(new SolrQuery(searchString), options);
return results;
}
Evolving Architecture
Client
Web
Server
App
Server
Data
Repository
Data Tables
Session
Cache (?)
Search
Service
Query
Write
Data Storage
Typically, RDBMS is the de facto standard
◦ SQL Server
◦ MySQL
◦ PostgreSQL
◦ Oracle (Yikes!!)
But do you really need it?
Data Storage
Get all the orders for user ‘David’ in last 30 days
SELECT c.FirstName, c.MiddleName, c.LastName, soh.SalesOrderID, soh.OrderDate,
sod.UnitPrice, sod.OrderQty, sod.LineTotal,
p.Name as 'ProductName', p.Color, p.ProductNumber,
pm.Name as 'ProductModel',
pc.Name as 'ProductCategory',
pcParent.Name as 'ProductParentCategory'
FROM SalesLT.Customer c INNER JOIN SalesLT.SalesOrderHeader soh
ON c.CustomerID = soh.CustomerID
INNER JOIN SalesLT.SalesOrderDetail sod ON soh.SalesOrderID = sod.SalesOrderID
INNER JOIN SalesLT.Product p ON sod.ProductID = p.ProductID
INNER JOIN SalesLT.ProductModel pm ON p.ProductModelID = pm.ProductModelID
INNER JOIN SalesLT.ProductCategory pc ON p.ProductCategoryID = pc.ProductCategoryID
INNER JOIN SalesLT.ProductCategory pcParent ON pc.ParentProductCategoryID = pcParent.ProductCategoryID
WHERE c.FirstName = 'David'
AND soh.OrderDate > (GETDATE()-30)
Data Storage
Wouldn’t it be great if it were something like this?
SELECT FirstName, MiddleName, LastName, SalesOrderID, OrderDate,
UnitPrice, OrderQty, LineTotal, ProductName, Color, ProductNumber,
ProductModel, ProductCategory, ProductParentCategory
FROM CustomerSales
WHERE FirstName = 'David'
AND OrderDate > (GETDATE()-30)
Data Storage
Maybe a document database can be of use
Number out there
◦ MongoDB
◦ RavenDB
◦ Couchbase
Flattened structures without relational ties to other collections
Essentially object databases
Looking at MongoDB
Server can have databases
Databases contain collections (like a table)
Collections contain documents (like rows)
Documents can be structured, have constraints, have primary key
Working with Mongo’s C# Client
public class MongoContext<T> : IContext<T> where T : class, new() {
private IDictionary<String, String> _config;
private readonly MongoCollection<T> _coll;
public MongoContext(IDictionary<String, String> config) {
_config = config;
var client = new MongoClient(config["mongo.serverUrl"]);
var server = client.GetServer();
var database = server.GetDatabase(config["mongo.database"]);
_coll = database.GetCollection<T>(config["mongo.collection"]);
}
public IQueryable<T> Items {
get { return _coll.FindAll().AsQueryable(); }
}
}
Working with Mongo’s C# Client
Encapsulate my queries and commands
public class FindPageById : ICriteria<Page> {
private readonly String _id;
public FindPageById(String pageId)
{
_id = pageId;
}
public IEnumerable<Page> Execute(IContext<Page> ctx)
{
return ctx.Items.Where(p => p.Id == _id).AsEnumerable();
}
}
Working with Mongo’s C# Client
Invoke my query/command
public class TemplateController : IportalBaseController {
private readonly IContext<Page> _pages;
public TemplateController(IContext<Page> ctx) : base() {
_pages = ctx;
}
[HttpGet]
public async Task<IportalPageMetadata> Section(String cat, String page) {
var id = String.Format("{0}/{1}", cat, page);
var thePage = new FindPageById(id)
.Execute(_pages)
.FirstOrDefault();
...
}
}
Working with Mongo’s C# Client
Writing to Mongo is just as simple...
[HttpPost]
public async Task<Boolean> Post(Page page)
{
var userId = await GetUserId();
new CreatePage(page, userId)
.Execute(_pages);
_searchPage.Insert(page);
return true;
}
Evolving Architecture
Client
Web
Server
App
Server
Data
Repository
Some data (?)
Session
Cache (?)
Search
Service
Query
Write
Document
Repository
Write
Query
Session and Cache Data
Generally short-lived for users
Fairly static for cached data
Key/value stores can serve us well here
◦ Redis
Redis has two good .NET client libraries
◦ StackExchange.Redis
◦ ServiceStack.Redis
Using Redis
public class RedisSessionManager : ISessionManager {
private static ConnectionMultiplexer _redis = null;
private readonly IDictionary<String, String> _config;
public RedisSessionManager(IDictionary<String, String> config) {
if (_redis == null) {
_redis = ConnectionMultiplexer.Connect(config["session.serverUrl"].ToString());
}
_config = config;
}
public async Task<Boolean> CreateSession(String portalId, String userId, String fullName) {
var time = DateTime.UtcNow.ToString();
var timeout = _config.ContainsKey("session.timeout");
var vals = new HashEntry[] {
new HashEntry("userid", userId), new HashEntry("login", time),
new HashEntry("lastAction", time), new HashEntry("fullName", fullName)
};
await RedisDatabase.HashSetAsync(portalId, vals);
return await RedisDatabase.KeyExpireAsync(portalId, TimeSpan.FromMinutes(timeout));
}
}
Using Redis
public async Task<Boolean> ExtendSession(String portalId) {
var timeout = _config.ContainsKey("session.timeout");
await RedisDatabase.HashSetAsync(portalId, "lastAction", DateTime.UtcNow.ToString());
return await RedisDatabase.KeyExpireAsync(portalId, TimeSpan.FromMinutes(timeout));
}
public async Task<Boolean> ExpireSession(String portalId) {
return await RedisDatabase.KeyDeleteAsync(portalId);
}
Using Redis
At login:
await Session.CreateSession(portalid, UserHandle, fullName);
Upon log out:
await Session.ExpireSession(portalCookie.Value);
Evolving Architecture
Client
Web
Server
App
Server
Data
Repository
Some data (?)
Search
Service
Query
Write
Document
Repository
Write
Query
Session/
Cache
Service
Why Data Store
We’re left with a database with not much use
◦ Transactional data in document store
◦ Search documents in Solr
◦ Session, caching, etc. in key/value or caching service like Redis
What it probably ends up acting as is…
Evolving Architecture
Client
Web
Server
App
Server
Event Store
2-3 flat tables
Event data
Search
Service
Query
Write
Document
Repository
Write
Query
Session/
Cache
Service
Queue?
(D)Evolved Architecture
Client
Web
Server
App
Server
Event
Store
Search
Service
Query
Write
Doc
Repo
Write
Query
Session/
Cache
Service
Queue?
(D)Evolved Architecture
Pick and choose what components work best
Don’t use them just to use them
Proof-of-Concept / Prototype
Why look to be RDBMS free
Searching
◦ More than just full-text needs
Data
◦ Choose a system that you can model the business
◦ Not the other way around
Caching / Session Values / PubSub
◦ Offload necessary?
◦ Ensure performance
Maintenance and support big factors to consider

Contenu connexe

Tendances

Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.Ravi Teja
 
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...MongoDB
 
Content Management with MongoDB by Mark Helmstetter
 Content Management with MongoDB by Mark Helmstetter Content Management with MongoDB by Mark Helmstetter
Content Management with MongoDB by Mark HelmstetterMongoDB
 
Deciphering Explain Output
Deciphering Explain Output Deciphering Explain Output
Deciphering Explain Output MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBJustin Smestad
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDBNorberto Leite
 
Responsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at ScaleResponsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at Scalescottjehl
 
Webinar: Schema Design
Webinar: Schema DesignWebinar: Schema Design
Webinar: Schema DesignMongoDB
 
Content Mangement Systems and MongoDB
Content Mangement Systems and MongoDBContent Mangement Systems and MongoDB
Content Mangement Systems and MongoDBMitch Pirtle
 
Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Dbchriskite
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMongoDB
 
Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDBAlex Sharp
 
Starting with MongoDB
Starting with MongoDBStarting with MongoDB
Starting with MongoDBDoThinger
 
MongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB
 
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...George McGeachie
 
Addressing Your Backup Needs Using Ops Manager and Atlas
Addressing Your Backup Needs Using Ops Manager and AtlasAddressing Your Backup Needs Using Ops Manager and Atlas
Addressing Your Backup Needs Using Ops Manager and AtlasMongoDB
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema DesignMongoDB
 

Tendances (20)

Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.Building a Location-based platform with MongoDB from Zero.
Building a Location-based platform with MongoDB from Zero.
 
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
MongoDB .local Chicago 2019: Best Practices for Working with IoT and Time-ser...
 
Content Management with MongoDB by Mark Helmstetter
 Content Management with MongoDB by Mark Helmstetter Content Management with MongoDB by Mark Helmstetter
Content Management with MongoDB by Mark Helmstetter
 
jQuery
jQueryjQuery
jQuery
 
Deciphering Explain Output
Deciphering Explain Output Deciphering Explain Output
Deciphering Explain Output
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Responsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at ScaleResponsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at Scale
 
MongoDB and Schema Design
MongoDB and Schema DesignMongoDB and Schema Design
MongoDB and Schema Design
 
Webinar: Schema Design
Webinar: Schema DesignWebinar: Schema Design
Webinar: Schema Design
 
Content Mangement Systems and MongoDB
Content Mangement Systems and MongoDBContent Mangement Systems and MongoDB
Content Mangement Systems and MongoDB
 
Intro To Mongo Db
Intro To Mongo DbIntro To Mongo Db
Intro To Mongo Db
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDB
 
Starting with MongoDB
Starting with MongoDBStarting with MongoDB
Starting with MongoDB
 
MongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and ImplicationsMongoDB Schema Design: Practical Applications and Implications
MongoDB Schema Design: Practical Applications and Implications
 
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...
SAP PowerDesigner Masterclass for the UK SAP Database & Technology User Group...
 
Addressing Your Backup Needs Using Ops Manager and Atlas
Addressing Your Backup Needs Using Ops Manager and AtlasAddressing Your Backup Needs Using Ops Manager and Atlas
Addressing Your Backup Needs Using Ops Manager and Atlas
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 

Similaire à Freeing Yourself from an RDBMS Architecture

[MongoDB.local Bengaluru 2018] Keynote
[MongoDB.local Bengaluru 2018] Keynote[MongoDB.local Bengaluru 2018] Keynote
[MongoDB.local Bengaluru 2018] KeynoteMongoDB
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceDavid Hoerster
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Maxime Beugnet
 
Microsoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMicrosoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMark Kromer
 
Creating a Single View: Overview and Analysis
Creating a Single View: Overview and AnalysisCreating a Single View: Overview and Analysis
Creating a Single View: Overview and AnalysisMongoDB
 
Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Ido Green
 
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...Sparkhound Inc.
 
Firestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabiFirestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabiShashank Kakroo
 
Keynote - Speaker: Grigori Melnik
Keynote - Speaker: Grigori Melnik Keynote - Speaker: Grigori Melnik
Keynote - Speaker: Grigori Melnik MongoDB
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB
 
Big Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft AzureBig Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft AzureMark Kromer
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery GuideMark Rackley
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Codemotion
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revisedMongoDB
 
Eagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessEagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessMongoDB
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020Thodoris Bais
 
MongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same treeMongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same treeMongoDB
 
Simplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseSimplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseFeatureByte
 

Similaire à Freeing Yourself from an RDBMS Architecture (20)

MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
[MongoDB.local Bengaluru 2018] Keynote
[MongoDB.local Bengaluru 2018] Keynote[MongoDB.local Bengaluru 2018] Keynote
[MongoDB.local Bengaluru 2018] Keynote
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data Persistence
 
Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...Simplifying & accelerating application development with MongoDB's intelligent...
Simplifying & accelerating application development with MongoDB's intelligent...
 
Microsoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMicrosoft Azure Big Data Analytics
Microsoft Azure Big Data Analytics
 
Creating a Single View: Overview and Analysis
Creating a Single View: Overview and AnalysisCreating a Single View: Overview and Analysis
Creating a Single View: Overview and Analysis
 
Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)Big Query - Women Techmarkers (Ukraine - March 2014)
Big Query - Women Techmarkers (Ukraine - March 2014)
 
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
Optimizing Code Reusability for SharePoint using Linq to SharePoint & the MVP...
 
Firestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabiFirestore MENA digital days : GDG Abu dhabi
Firestore MENA digital days : GDG Abu dhabi
 
Keynote - Speaker: Grigori Melnik
Keynote - Speaker: Grigori Melnik Keynote - Speaker: Grigori Melnik
Keynote - Speaker: Grigori Melnik
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
 
Big Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft AzureBig Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft Azure
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revised
 
Eagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessEagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational Awareness
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020
 
MongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same treeMongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same tree
 
MongoDB + Spring
MongoDB + SpringMongoDB + Spring
MongoDB + Spring
 
Simplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseSimplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data Warehouse
 

Plus de David Hoerster

Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?David Hoerster
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!David Hoerster
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetDavid Hoerster
 
A Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed ApplicationA Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed ApplicationDavid Hoerster
 
Greenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureGreenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureDavid Hoerster
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRSDavid Hoerster
 
jQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherjQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherDavid Hoerster
 

Plus de David Hoerster (9)

Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnet
 
Mongo Baseball .NET
Mongo Baseball .NETMongo Baseball .NET
Mongo Baseball .NET
 
A Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed ApplicationA Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed Application
 
Greenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureGreenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows Azure
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRS
 
jQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherjQuery and OData - Perfect Together
jQuery and OData - Perfect Together
 

Dernier

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 

Dernier (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 

Freeing Yourself from an RDBMS Architecture

  • 1. Being RDBMS Free DAVID HOERSTER 2014
  • 2. About Me C# MVP (Since April 2011) Sr. Director of Web Solutions at RGP Conference Director for Pittsburgh TechFest Co-Founder of BrainCredits (braincredits.com) Past President of Pittsburgh .NET Users Group and organizer of recent Pittsburgh Code Camps and other Tech Events Twitter - @DavidHoerster Blog – http://geekswithblogs.net/DavidHoerster Email – david@agileways.com
  • 3. Traditional Architecture Data persistence is central to application Generally monolithic Jack of all trades; master of none
  • 5. What if… We could break some pieces out ◦ Flatten structures for querying ◦ Highly efficient search services ◦ Pub/sub hubs ◦ Remote caching with excellent performance ◦ Session management outside a DB for load balanced environments How would app then be architected?
  • 6. Search How do you search? ◦ LIKE ‘%blah%’ ? ◦ Dynamic SQL ◦ Full-Text LIKE and Dynamic SQL can be quick to create ◦ Tough to maintain Full-Text gives power ◦ Limited in search options
  • 7. Search Number of search services out there like ◦ Lucene ◦ Solr Lucene is a search engine ◦ Embed in apps ◦ .NET port (Lucene.NET) Solr is search service ◦ Built on Lucene ◦ Connect apps to it
  • 8. Searching with Solr Disconnected from your application Search content via HTTP REST calls Can use SolrNet as a client ◦ https://github.com/mausch/SolrNet Document-based
  • 9. Searching with Solr private readonly ISolrOperations<T> _solr; public SolrSearchProvider(ISolrOperations<T> solr) { _solr = solr; } public IEnumerable<T> Query(String searchString) { var options = new QueryOptions() { Fields = new List<String> {"title", "body", "lastModified" }.ToArray(), Highlight = new HighlightingParameters() { BeforeTerm = "<strong><em>", AfterTerm = "</em></strong>", Fields = new List<String> { "title", "body" }.ToArray(), Fragsize = 100 } }; var results = _solr.Query(new SolrQuery(searchString), options); return results; }
  • 11. Data Storage Typically, RDBMS is the de facto standard ◦ SQL Server ◦ MySQL ◦ PostgreSQL ◦ Oracle (Yikes!!) But do you really need it?
  • 12. Data Storage Get all the orders for user ‘David’ in last 30 days SELECT c.FirstName, c.MiddleName, c.LastName, soh.SalesOrderID, soh.OrderDate, sod.UnitPrice, sod.OrderQty, sod.LineTotal, p.Name as 'ProductName', p.Color, p.ProductNumber, pm.Name as 'ProductModel', pc.Name as 'ProductCategory', pcParent.Name as 'ProductParentCategory' FROM SalesLT.Customer c INNER JOIN SalesLT.SalesOrderHeader soh ON c.CustomerID = soh.CustomerID INNER JOIN SalesLT.SalesOrderDetail sod ON soh.SalesOrderID = sod.SalesOrderID INNER JOIN SalesLT.Product p ON sod.ProductID = p.ProductID INNER JOIN SalesLT.ProductModel pm ON p.ProductModelID = pm.ProductModelID INNER JOIN SalesLT.ProductCategory pc ON p.ProductCategoryID = pc.ProductCategoryID INNER JOIN SalesLT.ProductCategory pcParent ON pc.ParentProductCategoryID = pcParent.ProductCategoryID WHERE c.FirstName = 'David' AND soh.OrderDate > (GETDATE()-30)
  • 13. Data Storage Wouldn’t it be great if it were something like this? SELECT FirstName, MiddleName, LastName, SalesOrderID, OrderDate, UnitPrice, OrderQty, LineTotal, ProductName, Color, ProductNumber, ProductModel, ProductCategory, ProductParentCategory FROM CustomerSales WHERE FirstName = 'David' AND OrderDate > (GETDATE()-30)
  • 14. Data Storage Maybe a document database can be of use Number out there ◦ MongoDB ◦ RavenDB ◦ Couchbase Flattened structures without relational ties to other collections Essentially object databases
  • 15. Looking at MongoDB Server can have databases Databases contain collections (like a table) Collections contain documents (like rows) Documents can be structured, have constraints, have primary key
  • 16. Working with Mongo’s C# Client public class MongoContext<T> : IContext<T> where T : class, new() { private IDictionary<String, String> _config; private readonly MongoCollection<T> _coll; public MongoContext(IDictionary<String, String> config) { _config = config; var client = new MongoClient(config["mongo.serverUrl"]); var server = client.GetServer(); var database = server.GetDatabase(config["mongo.database"]); _coll = database.GetCollection<T>(config["mongo.collection"]); } public IQueryable<T> Items { get { return _coll.FindAll().AsQueryable(); } } }
  • 17. Working with Mongo’s C# Client Encapsulate my queries and commands public class FindPageById : ICriteria<Page> { private readonly String _id; public FindPageById(String pageId) { _id = pageId; } public IEnumerable<Page> Execute(IContext<Page> ctx) { return ctx.Items.Where(p => p.Id == _id).AsEnumerable(); } }
  • 18. Working with Mongo’s C# Client Invoke my query/command public class TemplateController : IportalBaseController { private readonly IContext<Page> _pages; public TemplateController(IContext<Page> ctx) : base() { _pages = ctx; } [HttpGet] public async Task<IportalPageMetadata> Section(String cat, String page) { var id = String.Format("{0}/{1}", cat, page); var thePage = new FindPageById(id) .Execute(_pages) .FirstOrDefault(); ... } }
  • 19. Working with Mongo’s C# Client Writing to Mongo is just as simple... [HttpPost] public async Task<Boolean> Post(Page page) { var userId = await GetUserId(); new CreatePage(page, userId) .Execute(_pages); _searchPage.Insert(page); return true; }
  • 20. Evolving Architecture Client Web Server App Server Data Repository Some data (?) Session Cache (?) Search Service Query Write Document Repository Write Query
  • 21. Session and Cache Data Generally short-lived for users Fairly static for cached data Key/value stores can serve us well here ◦ Redis Redis has two good .NET client libraries ◦ StackExchange.Redis ◦ ServiceStack.Redis
  • 22. Using Redis public class RedisSessionManager : ISessionManager { private static ConnectionMultiplexer _redis = null; private readonly IDictionary<String, String> _config; public RedisSessionManager(IDictionary<String, String> config) { if (_redis == null) { _redis = ConnectionMultiplexer.Connect(config["session.serverUrl"].ToString()); } _config = config; } public async Task<Boolean> CreateSession(String portalId, String userId, String fullName) { var time = DateTime.UtcNow.ToString(); var timeout = _config.ContainsKey("session.timeout"); var vals = new HashEntry[] { new HashEntry("userid", userId), new HashEntry("login", time), new HashEntry("lastAction", time), new HashEntry("fullName", fullName) }; await RedisDatabase.HashSetAsync(portalId, vals); return await RedisDatabase.KeyExpireAsync(portalId, TimeSpan.FromMinutes(timeout)); } }
  • 23. Using Redis public async Task<Boolean> ExtendSession(String portalId) { var timeout = _config.ContainsKey("session.timeout"); await RedisDatabase.HashSetAsync(portalId, "lastAction", DateTime.UtcNow.ToString()); return await RedisDatabase.KeyExpireAsync(portalId, TimeSpan.FromMinutes(timeout)); } public async Task<Boolean> ExpireSession(String portalId) { return await RedisDatabase.KeyDeleteAsync(portalId); }
  • 24. Using Redis At login: await Session.CreateSession(portalid, UserHandle, fullName); Upon log out: await Session.ExpireSession(portalCookie.Value);
  • 25. Evolving Architecture Client Web Server App Server Data Repository Some data (?) Search Service Query Write Document Repository Write Query Session/ Cache Service
  • 26. Why Data Store We’re left with a database with not much use ◦ Transactional data in document store ◦ Search documents in Solr ◦ Session, caching, etc. in key/value or caching service like Redis What it probably ends up acting as is…
  • 27. Evolving Architecture Client Web Server App Server Event Store 2-3 flat tables Event data Search Service Query Write Document Repository Write Query Session/ Cache Service Queue?
  • 29. (D)Evolved Architecture Pick and choose what components work best Don’t use them just to use them Proof-of-Concept / Prototype
  • 30. Why look to be RDBMS free Searching ◦ More than just full-text needs Data ◦ Choose a system that you can model the business ◦ Not the other way around Caching / Session Values / PubSub ◦ Offload necessary? ◦ Ensure performance Maintenance and support big factors to consider