Y NoSQL: An Example

13,735 views

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
2 Comments
5 Likes
Statistics
Notes
No Downloads
Views
Total views
13,735
On SlideShare
0
From Embeds
0
Number of Embeds
50
Actions
Shares
0
Downloads
64
Comments
2
Likes
5
Embeds 0
No embeds

No notes for slide

Y NoSQL: An Example

  1. 1. Y NoSQL Jim Van Fleet @bigfleet Jan 2010 http://jimvanfleet.com/
  2. 2. Congratulations ✤ You just landed a really sweet gig. Y NoSQL http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  4. 4. Feeling Good? Y NoSQL http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  7. 7. This isn’t so bad... Y NoSQL http://jimvanfleet.com/
  8. 8. This isn’t so bad... Y NoSQL http://jimvanfleet.com/
  9. 9. This isn’t so bad... Y NoSQL http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  11. 11. Why is that? Y NoSQL http://jimvanfleet.com/
  12. 12. One more thing... Y NoSQL http://jimvanfleet.com/
  13. 13. ... you’re screwed. Y NoSQL http://jimvanfleet.com/
  14. 14. ... you’re screwed. Y NoSQL http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  18. 18. Picking up the pieces Y NoSQL http://jimvanfleet.com/
  19. 19. Picking up the pieces Y NoSQL http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  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 http://jimvanfleet.com/
  22. 22. To Learn More... ✤ Ben Scofield’s overview of the field: http://www.slideshare.net/bscofield/nosql-death-to-relational- databases ✤ One-stop shop for NoSQL overview: http://www.vineetgupta.com/2010/01/nosql-databases-part-1- landscape.html Y NoSQL http://jimvanfleet.com/

×