Successfully reported this slideshow.

Y NoSQL: An Example


Published on

Demonstrates how an "activity feed" or notification service can be a good fit for a non-relational database. Includes a sketch of an example solution schema with MongoDB.

Published in: Technology

Y NoSQL: An Example

  1. 1. Y NoSQL Jim Van Fleet @bigfleet Jan 2010
  2. 2. Congratulations ✤ You just landed a really sweet gig. Y NoSQL
  3. 3. Congratulations ✤ You’re doing a baseball app ✤ Twitter and OAuth, so no authentication worries ✤ They only have the MLBPA on board, so no team names or logos ✤ Free mobile apps focusing on great design, where you have help ✤ Twitter DM’s for the premium package Y NoSQL
  4. 4. Feeling Good? Y NoSQL
  5. 5. Feeling Good? Where’s my cocktail?
  6. 6. Not So Fast, My Friend ✤ Your boss comes in one day, he’s ecstatic ✤ You got the MLB license! ✤ You’re going to allow fans to follow a team, or particular games. ✤ They also signed a contract with some marketers, the target is 100k users Y NoSQL
  7. 7. This isn’t so bad... Y NoSQL
  8. 8. This isn’t so bad... Y NoSQL
  9. 9. This isn’t so bad... Y NoSQL
  10. 10. One more thing... ✤ Things are looking great! But... ✤ We want our user’s notifications on their user page ✤ We got a bug report, users are getting some notifications twice Y NoSQL
  11. 11. Why is that? Y NoSQL
  12. 12. One more thing... Y NoSQL
  13. 13. ... you’re screwed. Y NoSQL
  14. 14. ... you’re screwed. Y NoSQL
  15. 15. Math time ✤ 100k user target ✤ Some teams will be more popular than others ✤ Red Sox in ’09: ~ 6050 events over 162 games ✤ Roughly 80 a game ✤ If 20k users follow the Red Sox, you have 160k notifications per game ✤ ... and that’s just when they’re at bat! Y NoSQL
  16. 16. The math gets worse ✤ You’ll come to hate good pitchers. ✤ They’re owned universally, so the top 30 will all be 10% owned ✤ In 2009, Josh Beckett generated 28 events in an average trip to the mound ✤ At 10k users, that’s 280k for one game. ✤ Good pitchers usually pitch against each other Y NoSQL
  17. 17. So what now? ✤ Let’s take a document-based approach to the modeling the problem ✤ For this particular example, we’ll use MongoDB. ✤ The mantra I heard: “Focus on what you want to show” ✤ Schemaless or relational: row scans are what kill you Y NoSQL
  18. 18. Picking up the pieces Y NoSQL
  19. 19. Picking up the pieces Y NoSQL
  20. 20. How does that help? ✤ 200k plays in an entire season. ✤ MongoDB has indexes, maintaining all query richness and staying fast. ✤ Linear user growth is a non-issue ✤ Single-item popularity is similarly a non-issue Y NoSQL
  21. 21. Postlude (NO LOLLIPOPS) ✤ There’s a popular conception that NoSQL is about everything and a pony. ✤ It’s bleeding edge ✤ Talk about this decision with your ops team or your host Y NoSQL
  22. 22. To Learn More... ✤ Ben Scofield’s overview of the field: databases ✤ One-stop shop for NoSQL overview: landscape.html Y NoSQL