SlideShare a Scribd company logo
Kevin Wright
Jonathan Roeder
   Kevin Wright (The long-haired hippie one)
    ◦ Over 100 years of experience! (Just look at this
      PowerPoint Template!)
    ◦ Worked on the Space Station!
    ◦ 2 years of Mongo experience


   Jonathan Roeder (The short-haired hipster
    one)
    ◦ 10 years of High Scale eCommerce / CMS / Search
    ◦ 1.5 years of Mongo experience
   Founded in 1999
   SaaS eCommerce and related services
   40,000+ Online stores
   330+ Employees
   $2.8B processed on our platform in 2012
Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C#
   Dog Fridays
   Guys in suspenders!
   Just who are you guys?
WHY write one?

The world needed ONE MORE!?!

Critical focus on
 Multi-Tenancy
 Focus on Small footprint / Efficient scaling
What it is:
 .NET REST Service
 Standard use case of enabling CMS users to
  define Meta schemas (Content & Property
  Types)
 CRUD operations on Data that conforms to
  the Meta schemas (Content)
 Structures for organizing Content (Content
  Lists and Folders)
   Initial approach programmatically provisioned
    a Mongo Database for each Tenant.
   Reinventing the wheel with database
    management.
   Suffering from two minute incremental boot
    up time per Database was untenable (get it!).
   New approach: Embrace Sharding as the
    appropriate scale out approach
   Opt-in per Collection
   Don’t do it to earn your Sharding merit badge
   Read the documentation three times.
   Implement four times. (a.k.a Prototype)
   The Along Came Polly joke will never get old
   .NET static type system + MongoDB dynamic
    schema is like mixing Simon and Garfunkel
    …(it can be great if you don’t Garfunkel it up)

   Driver allows for pure dynamic schema
    interaction but is maturing to allow type safe
    access via Lambdas and LINQ.
    ◦ Aggregation framework tbd [CSHARP-601]
KEVIN WILL DEMO
 Mongo SHELL
 MONGOVUE
 LINQPAD
   Be as static as you can be.
    ◦ POCO types for each MongoDB Document schema
      (Data Transfer Object, DTO pattern)
    ◦ Leverage compile-time safety. The newest driver
      makes it easy with Generics and Lambdas
    ◦ Duck-typing and magic strings are for gooses!


   Explore very rich serialization hooks and
    levers
    ◦ (SetIgnoreIfNullConvention, BsonExtraElements,…)
Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C#
Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C#
Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C#
   Now that you’ve created static types, leverage
    them!
   LINQ support is great. Just know that:
    ◦ No projection [CSHARP-456]
    ◦ Hard to mix in dynamic schema elements (use Inject
      extension method)


   Fall back to
    MongoDB.Driver.Builders.Query<T> or
    QueryBuilder<T>
    ◦ Mix in dynamic schema elements via non-generic
      version
3 HIT
COMBO
   !!!
   Laser focus your Updates
   Be careful with the blanket Save method!
    ◦ Can’t stop it from Upserting
    ◦ Often overkill to replace entire Document
   Data modeling without Joins
   Concurrency modeling without Transactions
   Denormalize!
   If your data can’t be dirty, don’t denoramlize

   Example: Store only the FolderId on Content
    Document instead of materialized Folder path
    ◦ Pros: Updates are easy!
    ◦ Cons: Queries are hard!
    ◦ When wanting to find Content within child
      Folders, must first query for all child Folders, then
      OR those IDs using the ‘In’ operator
Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C#
Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C#
   MongoDB.org approaches for actually
    retrieving the Folders :
    http://docs.mongodb.org/manual/tutorial/m
    odel-tree-structures/
   Optimistic Concurrency
   Benign Writes
   Benign Wrongs
   Compensate

   Be prepared to carefully think this through.
   http://blog.mongodb.org/post/475279604/
    on-distributed-consistency-part-1
   http://docs.mongodb.org/manual/tutorial/p
    erform-two-phase-commits/
   Vote!

More Related Content

PPTX
Web App for Containers + MySQLでコンテナ対応したPHPアプリを作ろう!
PDF
MongoDBのアレをアレする
PDF
イケてる技術で品質を担保しつつスピード感のある開発を実現する冴えたやり方
PPTX
Spring CloudとZipkinを利用した分散トレーシング
PPTX
ネットワークシミュレータで手軽にネットワークのお勉強(GNS3編)
PDF
Play with DockerでDocker学習環境を整えよう!
PDF
Enterprise Networking (May – 2019) [Choice Based | Question Paper]
PDF
メタバースのビジネスモデルと技術限界
Web App for Containers + MySQLでコンテナ対応したPHPアプリを作ろう!
MongoDBのアレをアレする
イケてる技術で品質を担保しつつスピード感のある開発を実現する冴えたやり方
Spring CloudとZipkinを利用した分散トレーシング
ネットワークシミュレータで手軽にネットワークのお勉強(GNS3編)
Play with DockerでDocker学習環境を整えよう!
Enterprise Networking (May – 2019) [Choice Based | Question Paper]
メタバースのビジネスモデルと技術限界

What's hot (20)

PDF
そろそろ知っておきたい!!コンテナ技術と Dockerのキホン
PDF
Azure Infrastructure as Code 体験入隊
PDF
自動化ハンズオン
PDF
Docker Swarm入門
PDF
nioで作ったBufferedWriterに変えたら例外になった
PDF
Oracle Database Appliance X5-2 アップデート内容のご紹介
PDF
serviceクラスをやめようサブクラスを使おう
PPTX
CloudFront最近の事例と間違った使い方
PPTX
0から始めるコンテナの学び方(Kubernetes Novice Tokyo #14 発表資料)
PPTX
Spanner移行について本気出して考えてみた
PDF
使ってみませんか?pg hint_plan
PPTX
しばちょう先生が語る!オラクルデータベースの進化の歴史と最新技術動向#2
PPTX
Webアプリケーション負荷試験実践入門
PPTX
Drone programming with ArduPilot
PDF
WebSocketプロトコル
PDF
SQL大量発行処理をいかにして高速化するか
PPTX
Google Codelabsをやってみた
PPTX
Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)
PDF
ゼロからはじめるKVM超入門
PDF
45分で理解する SQL Serverでできることできないこと
そろそろ知っておきたい!!コンテナ技術と Dockerのキホン
Azure Infrastructure as Code 体験入隊
自動化ハンズオン
Docker Swarm入門
nioで作ったBufferedWriterに変えたら例外になった
Oracle Database Appliance X5-2 アップデート内容のご紹介
serviceクラスをやめようサブクラスを使おう
CloudFront最近の事例と間違った使い方
0から始めるコンテナの学び方(Kubernetes Novice Tokyo #14 発表資料)
Spanner移行について本気出して考えてみた
使ってみませんか?pg hint_plan
しばちょう先生が語る!オラクルデータベースの進化の歴史と最新技術動向#2
Webアプリケーション負荷試験実践入門
Drone programming with ArduPilot
WebSocketプロトコル
SQL大量発行処理をいかにして高速化するか
Google Codelabsをやってみた
Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)
ゼロからはじめるKVM超入門
45分で理解する SQL Serverでできることできないこと
Ad

Similar to Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C# (20)

PPTX
Getting Started with MongoDB Using the Microsoft Stack
PPTX
Techorama - Evolvable Application Development with MongoDB
PPTX
MongoDB 2.4 and spring data
PDF
MongoDB for Coder Training (Coding Serbia 2013)
PDF
Mongodb, Node.js and You: PART I
PDF
MongoDB.pdf
PDF
NDC London 2013 - Mongo db for c# developers
PDF
The emerging world of mongo db csp
PPT
9. Document Oriented Databases
PPTX
Intro To Mongo Db
PDF
Mongodb in-anger-boston-rb-2011
PDF
Quick overview of MongoDB
KEY
MongoDB - Ruby document store that doesn't rhyme with ouch
PDF
Mongo db for C# Developers
PPTX
Getting Started with MongoDB
PPTX
Webinar: Scaling MongoDB
PPTX
Document databases
PDF
MongoDB NoSQL database a deep dive -MyWhitePaper
PPTX
MongoDB_ppt.pptx
PDF
Best Practices for Migrating RDBMS to MongoDB
Getting Started with MongoDB Using the Microsoft Stack
Techorama - Evolvable Application Development with MongoDB
MongoDB 2.4 and spring data
MongoDB for Coder Training (Coding Serbia 2013)
Mongodb, Node.js and You: PART I
MongoDB.pdf
NDC London 2013 - Mongo db for c# developers
The emerging world of mongo db csp
9. Document Oriented Databases
Intro To Mongo Db
Mongodb in-anger-boston-rb-2011
Quick overview of MongoDB
MongoDB - Ruby document store that doesn't rhyme with ouch
Mongo db for C# Developers
Getting Started with MongoDB
Webinar: Scaling MongoDB
Document databases
MongoDB NoSQL database a deep dive -MyWhitePaper
MongoDB_ppt.pptx
Best Practices for Migrating RDBMS to MongoDB
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...

Lessons Learned from Building a Multi-Tenant Saas Content Management System on Mongo with C#

  • 2. Kevin Wright (The long-haired hippie one) ◦ Over 100 years of experience! (Just look at this PowerPoint Template!) ◦ Worked on the Space Station! ◦ 2 years of Mongo experience  Jonathan Roeder (The short-haired hipster one) ◦ 10 years of High Scale eCommerce / CMS / Search ◦ 1.5 years of Mongo experience
  • 3. Founded in 1999  SaaS eCommerce and related services  40,000+ Online stores  330+ Employees  $2.8B processed on our platform in 2012
  • 5. Dog Fridays  Guys in suspenders!
  • 6. Just who are you guys?
  • 7. WHY write one? The world needed ONE MORE!?! Critical focus on  Multi-Tenancy  Focus on Small footprint / Efficient scaling
  • 8. What it is:  .NET REST Service  Standard use case of enabling CMS users to define Meta schemas (Content & Property Types)  CRUD operations on Data that conforms to the Meta schemas (Content)  Structures for organizing Content (Content Lists and Folders)
  • 9. Initial approach programmatically provisioned a Mongo Database for each Tenant.  Reinventing the wheel with database management.  Suffering from two minute incremental boot up time per Database was untenable (get it!).  New approach: Embrace Sharding as the appropriate scale out approach
  • 10. Opt-in per Collection  Don’t do it to earn your Sharding merit badge  Read the documentation three times.  Implement four times. (a.k.a Prototype)  The Along Came Polly joke will never get old
  • 11. .NET static type system + MongoDB dynamic schema is like mixing Simon and Garfunkel …(it can be great if you don’t Garfunkel it up)  Driver allows for pure dynamic schema interaction but is maturing to allow type safe access via Lambdas and LINQ. ◦ Aggregation framework tbd [CSHARP-601]
  • 12. KEVIN WILL DEMO  Mongo SHELL  MONGOVUE  LINQPAD
  • 13. Be as static as you can be. ◦ POCO types for each MongoDB Document schema (Data Transfer Object, DTO pattern) ◦ Leverage compile-time safety. The newest driver makes it easy with Generics and Lambdas ◦ Duck-typing and magic strings are for gooses!  Explore very rich serialization hooks and levers ◦ (SetIgnoreIfNullConvention, BsonExtraElements,…)
  • 17. Now that you’ve created static types, leverage them!
  • 18. LINQ support is great. Just know that: ◦ No projection [CSHARP-456] ◦ Hard to mix in dynamic schema elements (use Inject extension method)  Fall back to MongoDB.Driver.Builders.Query<T> or QueryBuilder<T> ◦ Mix in dynamic schema elements via non-generic version
  • 19. 3 HIT COMBO !!!
  • 20. Laser focus your Updates
  • 21. Be careful with the blanket Save method! ◦ Can’t stop it from Upserting ◦ Often overkill to replace entire Document
  • 22. Data modeling without Joins  Concurrency modeling without Transactions
  • 23. Denormalize!
  • 24. If your data can’t be dirty, don’t denoramlize  Example: Store only the FolderId on Content Document instead of materialized Folder path ◦ Pros: Updates are easy! ◦ Cons: Queries are hard! ◦ When wanting to find Content within child Folders, must first query for all child Folders, then OR those IDs using the ‘In’ operator
  • 27. MongoDB.org approaches for actually retrieving the Folders : http://docs.mongodb.org/manual/tutorial/m odel-tree-structures/
  • 28. Optimistic Concurrency  Benign Writes  Benign Wrongs  Compensate  Be prepared to carefully think this through.  http://blog.mongodb.org/post/475279604/ on-distributed-consistency-part-1  http://docs.mongodb.org/manual/tutorial/p erform-two-phase-commits/
  • 29. Vote!