2. Mongo as a Data Store is
Dev Friendly: Data modeling and Programming
Business Friendly: Evolving schema - MVP
Ops Friendly: ReplSet in 30 minutes
UI Friendly : no-impedance gap with JS
Analytics friendly: Ad Hoc queries
Reporting friendly: ??
3. But Why?
- Right tool for Right job
Image credit: http://blog.pilotfishseo.com/open-sourced-content-management-system-cms-is-it-right-for-
you/
Hi! This is Mahesh. I lead the teams that builds the backend systems @ homeshop18.com Homeshop18 is a tv / e-comerce business e-commerce is a thin margin business - its profitable when done a scale Technology is our leverage to make that happen In this talk; I'll present how we use Mongo (and plan it) as an extension to our current data stores: MySql, Solr
DataStore: A Store(age) of Data
Why should you look beyond: RDBMS (MySQL) We all use Lucene/Solr for search - Why? Its the right thing to do for supporting search Similarly Mongo is the right thing to do for storing and serving data in denormalized form at scale Its in the sweet spot between Key-Value stores and RDBMS
1. images of a Product product with multiple images pid - img1 url pid - img2 url small image, zoom images pid - img1 - img type imgtype master default image pid - img1 - img type - seq nr Thats not how we think... its cognitive burden- unnecessary cognitive burden we are thinking in terms of the tools - and that inherently wrong 2. Books : Author, Publisher, Nr of pages Mobile: Brand, Battery Life, Screen size pid-aid aid-keyid-value aid-keyid-value keyid-keyname-datatype multiple values? maintain order? The write model has to all validations Read model has to parse all this crap to simply compare two products knowling data type is good: you can leverage a whole lot code like comparing two integers ;) 3. Order States process variables order is verifed, its cr'ed, shipped, rto or delivered; sales resturn being a good business; we capture diff data at diff steps to improve the process 10 states, 4 variables each = 40 cols!! inefficient use of space, dev time, maintainability, extending it etc.. Lets model this in rdbms
MySQL is you write Store : CQRS/DDD Mongo/Solr are your read stores Don't use Solr as a Doc store; use it as a search store-- that is what it is good at. Mongo is denormalized data store that is good for serving data to apps Write app can send an event to update read model (think of it as a cache; but its more than that) Beautiful for storing search click logs : capped collections Nice to use as a cache: ttl collections
Store denormalized product in mongo as a batch job every 8 hours
Now, you website need not hit Mysql - its just key lookups now, no joins ;) Keep updating data in Mongo in real-time whenever there is a update to DB
if u haven't heard of JPA itself ;) think of it as hibernate standardised If you are on java stack and use spring - definetly look at spring-data-mongo Its amazing how little code you need to write to do CRUD on a data store. persist and fetch data from your data store Amazing DSL for querying