Top 10 mobile apps in new york city presentation-relational international-

29
One of the Top 10 Mobile Apps A MongoDB Ready Partner in New York City

description

Our pick for the best high tech employer in New York in the under 50 employee category in the month of January 2014. Technology includes Android iOS mobile Redis MongoDB Python Objective-C JAVA Javascript AWS High Volume B - C environment. Great approachable management. Creative and VERY fast-paced. Good benefits. Contact Greg Hutchinson (212) 470-8005

Transcript of Top 10 mobile apps in new york city presentation-relational international-

Page 1: Top 10 mobile apps in new york city presentation-relational international-

One of the Top 10Mobile Apps

A MongoDB Ready Partner in New York City

Page 2: Top 10 mobile apps in new york city presentation-relational international-

Digital Collectible Card PlatformThree apps that run on the same system

so far…

MLB

NFL BPL

Collectible Card Games

Page 3: Top 10 mobile apps in new york city presentation-relational international-

Yes, Trading Cards!

Page 4: Top 10 mobile apps in new york city presentation-relational international-

The New Collectible

Live stats and game info

Online trading

Card sales info

Page 5: Top 10 mobile apps in new york city presentation-relational international-

Brief History of MLB• 2012: Introduced product on MySQL

• Revenue model fine-tuned

• Thought of new features and scaling considerations

• Migrate to MongoDB for MLB 2013 opening day

• Learn MongoDB

• Re-design the schema

• Write & Run migration scripts

• Total: 4-5 months, 1-2 people

Page 6: Top 10 mobile apps in new york city presentation-relational international-

• Product Demo

• System Overview

• Specific example of why MongoDB

• One case where another database technology is used with MongoDB

• Scalability issue and resolution

Page 7: Top 10 mobile apps in new york city presentation-relational international-

Product Demo

Page 8: Top 10 mobile apps in new york city presentation-relational international-

System Overview

Page 9: Top 10 mobile apps in new york city presentation-relational international-

Server Technologies• MongoDB

• MySQL

• Redis

• Python

• AWS

• External data feed

Page 10: Top 10 mobile apps in new york city presentation-relational international-

MongoDB Basic Structure

Page 11: Top 10 mobile apps in new york city presentation-relational international-

Simple View of Server Architecture

Page 12: Top 10 mobile apps in new york city presentation-relational international-

Big Piece 1: Processing Live Data• Live data is received and stored into MySQL• A heartbeat picks up the event and stores player stats into

MongoDB• It then pulls from MongoDB and updates leaderboard data in

Redis

Page 13: Top 10 mobile apps in new york city presentation-relational international-

Big Piece 2: Formatting Leaderboards for Users• API servers combine fan data from MongoDB with points data

from Redis• The result is a richly-detailed set of leaderboards

Page 14: Top 10 mobile apps in new york city presentation-relational international-

All other processes• All other processes are handled by the API servers and MongoDB

• Sign in, Trading, Commenting, Content Management, Purchases, Playing Cards

• Storage is used for fan and player photos as well as other simple files

Page 15: Top 10 mobile apps in new york city presentation-relational international-

Big Piece 1Specific reason we

chose MongoDBProcessing Live Game Data in Realtime

Page 16: Top 10 mobile apps in new york city presentation-relational international-

Realtime Live Game Updates

• Game play requires up-to-the-minute stats from live events for user scoring

• These data are stored in JSON format for the app

• The JSON data has to be updated frequently with stats and player points

• Support multiple live games for multiple apps on the same platform

Page 17: Top 10 mobile apps in new york city presentation-relational international-

Old Way: Processing Live Game Data with MySQL

Page 18: Top 10 mobile apps in new york city presentation-relational international-

New Way: With MongoDB, we can simply update the JSON data in the player’s

document db.players.update( { _id: ObjectId(“52be0717978ca03fc1984069"), ‘games.g':'2013-e.39141 }, { $set:{ 'games.$.b': "1-for-2: Ground out, Walk, Home run" }, $inc:{ 'points': 36 } })

Page 19: Top 10 mobile apps in new york city presentation-relational international-

In general, the system with MongoDB is much simpler, faster, more

scalable

Page 20: Top 10 mobile apps in new york city presentation-relational international-

Where we use Redis with MongoDB

Leaderboards

Page 21: Top 10 mobile apps in new york city presentation-relational international-

Building User Leaderboards

• Leaderboards updated in realtime

• 96 leaderboards in MLB

• Final output is constructed on-demand, no cache

• User scores are stored in sorted sets in Redis (ranking is automatic)

• Redis is an in-RAM key-value data store

Page 22: Top 10 mobile apps in new york city presentation-relational international-

Leaderboard Process

Page 23: Top 10 mobile apps in new york city presentation-relational international-

Scaling issue and resolution

Page 24: Top 10 mobile apps in new york city presentation-relational international-

Scaling Example: Buying Packs of Cards

• In order to support complex trading algorithms, each user profile needs to contain a reference to the owner’s card collection

Page 25: Top 10 mobile apps in new york city presentation-relational international-

Initial Structure of User Profile with Embedded Card Summary

Documents• Profile contains an

embedded document of card summaries

• When users buy cards, the profile can grow out of its allocated space

• MongoDB creates a new, bigger allocation for the user profile

Page 26: Top 10 mobile apps in new york city presentation-relational international-

Profiles were refactored to include only player IDs

• Finite number of players in the system, so size of player IDs list is limited

Page 27: Top 10 mobile apps in new york city presentation-relational international-

Basic Metrics

• On average, 1 pack sold per second

• Consistently top 10 grossing sports app

• Up to 30,000 requests per minute

• Up to 2,000 OPS

Page 28: Top 10 mobile apps in new york city presentation-relational international-

Conclusions• MongoDB great for apps, especially social

• JSON-ready data

• Normal NoSQL arguments

• For realtime leaderboards, Redis provides simple and fast “automatic sorting” of user scores

• Don’t embed documents if you hope for them to grow

• Easy to learn

Page 29: Top 10 mobile apps in new york city presentation-relational international-

Were Hiring!

MongoDB+Py, Web, iOS, Android, App Producer, Project Management, QA

Greg Hutchinson (212) 470-8005