Mongo @ homeshop18


Published on

How you introduce mongo as a datastore for your eCommerce appliactions

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Hi! This is Mahesh. I lead the teams that builds the backend systems @ 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
  • Mongo @ homeshop18

    1. 1. Mongo @ ~ Mongo
    2. 2. Mongo as a Data Store isDev Friendly: Data modeling and ProgrammingBusiness Friendly: Evolving schema - MVPOps Friendly: ReplSet in 30 minutesUI Friendly : no-impedance gap with JSAnalytics friendly: Ad Hoc queriesReporting friendly: ??
    3. 3. But Why?- Right tool for Right jobImage credit:
    4. 4. Data ModelingProduct imagesProduct EAV Books MobilesState machine Order Lifecycle transitions
    5. 5. 3 essential* data storesDB, Mongo, Solr Solr MySql App Mongo Write App * necessary, but may not be sufficient ;)
    6. 6. V1How we evolved from here to prev slide: Solr MySql
    7. 7. V2MySql Solr Mongo
    8. 8. V3MySql Solr Mongo v2 - catalogue, replSet
    9. 9. Ecosystem around MongoSpring-Data has JPA for MongoIts the icing on cake for your to transition
    10. 10. Thank youGlad to answer any questions you have..