• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Learn Learn how to build your mobile back-end with MongoDB

on

  • 7,312 views

Will Shulman, from MongoLab, shows us how to to persist our mobile app data in the cloud using a super-scalable and amazingly developer-friendly MongoDB back-end.

Will Shulman, from MongoLab, shows us how to to persist our mobile app data in the cloud using a super-scalable and amazingly developer-friendly MongoDB back-end.

Statistics

Views

Total Views
7,312
Views on SlideShare
7,085
Embed Views
227

Actions

Likes
9
Downloads
126
Comments
1

4 Embeds 227

http://friendfeedredux.appspot.com 223
http://www.scalebig.com 2
http://paper.li 1
http://marakana.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • MongoDirector (www.mongodirector.com) is a great hosting solution/platform for MongoDB on Amazon EC2. It completely automates the entire process of deploying and managing Mongo replica sets and shards on AWS using a simple two step wizard. You can pick the number of replicas and shards and the regions in which you want to place them. Provisioned IOPS and RAID can be used for optimal performance. Automatic backups can also be configured. LVM snapshots are used for backup - so backups take the same amount of time irrespective of the size of data.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Learn Learn how to build your mobile back-end with MongoDB Learn Learn how to build your mobile back-end with MongoDB Presentation Transcript

    • MongoDB for mobile app backends sf android meetup 08.31.2010
    • I’ve written my mobile app… where should I store my data ? ?
    • Mobile apps do not exist in a vacuum • user profile data • logging • location-based data collection • game data (stats, high scores) • polls and surveys • user feedback
    • Do I want to host this Java + Spring + Hibernate ? myself ? Ruby on Rails ? Hmmm… I will probably need to build a REST API…
    • General approach GET, POST, PUT, DELETE •RoR REST API •J2EE •MySQL •SQLServer •Postgres •EC2 •Rackspace •App Engine*
    • How can this be even simpler and more awesome?
    • • “Scalable, open-source, high- performance, document-oriented database” - 10gen • “The database your database could smell like” - old spice guy
    • MongoDB is designed to address two modern DB problems 1. object / relational “impedance mismatch” 2. horizontal scalability
    • Native drivers in almost every language • Java • Javascript • Python • Ruby • C# • PHP • and more…
    • A paradigm shift… • Traditional RDMS • MongoDB – database – database – table – collection – row – document / object
    • Documents (a.k.a. Objects) { _id: 1234, author: { name: “Bob Jones”, email: “b@b.com” }, post: “In these troubled times I like to …“, date: { $date: “2010-07-12 13:23UTC” }, location: [ -121.2322, 42.1223222 ], rating: 2.2, comments: [ { user: “jgs32@hotmail.com”, upVotes: 22, downVotes: 14, text: “Great point! I agree” }, { user: “holly.davidson@gmail.com”, upVotes: 421, downVotes: 22, text: “You are a moron” } ] }
    • Flexible “schemas” { _id: 1234, author: { name: “Bob Jones”, email: “b@b.com” }, post: “In these troubled times I like to …“, date: { $date: “2010-07-12 13:23UTC” }, location: [ -121.2322, 42.1223222 ], rating: 2.2, comments: [ { user: “jgs32@hotmail.com”, upVotes: 22, downVotes: 14, text: “Great point! I agree” }, { user: “holly.davidson@gmail.com”, upVotes: 421, downVotes: 22, text: “You are a moron” } ], tags: [ “politics”, “Virginia” ] }
    • Dynamic queries db.posts.find({ author.name: “mike” }) db.posts.find({ rating: { $gt: 2 }}) db.posts.find({ tags: “software” }) db.posts.find().sort({date: -1}).limit(10)
    • Atomic update operators Comment c = {author: “will”, date: new Date(), text: “great post!”} db.posts.update({_id: post._id}, {$push: {comments: c}})
    • Aggregation and Map/Reduce
    • Focus on scalability and performance
    • scalability and performance •memcached •key / value • •RDBMS depth of functionality
    • High performance, fault tolerant clusters made easy • master / slave replication • replica sets • auto-sharding
    • MongoDB is great for mobile • everything is JSON! – storage model is JSON – queries are in JSON – update operators are in JSON • geospatial indexing built-in • GridFS
    • Geospatial indexing • index on geo coordinate pairs • search by – bounding box – bounding circle (point, radius)
    • Geospatial indexing db.places.ensureIndex( { loc: “2d” } ) db.places.find({ loc: { $near : [50, 50] } }).limit(10) db.places.find({loc: {$within : {$box : [[40,40],[60,60]]}}}) db.places.find({loc: {$within : {$center : [[40,40],10]}}})
    • Geospatial indexing at Foursquare • ~1.3M registered users • ~615k check-ins a day • “Who’s here” service tracks last 3 hours for every user; uses mongo exclusively • all checkins, tips and venues written to mongo; reads a mix of mongo / legacy postgres
    • GridFS • distributed filesystem inside MongoDB • stores large files by splitting them into smaller documents • leverages existing sharding and replication configuration • stores metadata along with files • works well behind a CDN
    • Street cred • Shutterfly • Sugar CRM • Foursquare • Electronic Arts • bit.ly • Evite • Sourceforge • CollegeHumor • Etsy • Disqus • The New York Times • Justin.tv • Business Insider • Chartbeat • Github • Hot potato • Gilt Groupe • Eventbrite
    • Not so good for • Complex / multi-operation transactions • When you (really) need joins
    • How can this be even simpler and more awesome?
    • • MongoLab provides cloud-hosted MongoDB • It’s EC2 hosting + MongoDB + REST API + awesome admin tools • http://mongolab.com
    • Two ways to use MongoLab method 1: REST API GET, POST, PUT, DELETE REST API Your application method 2: MongoDB driver MongoDB EC2
    • MongoLab API /databases/<d>/collections GET /databases/<d>/collections/<c> GET POST /databases/<d>/collections/<c>/<_id> GET PUT DELETE /databases/<d>/collections/<c>?[q=<query>] [&f=<fields>] [&s=<order>] [&sk=<skip>] [&l=<limit>] GET
    • Example app: GeoPost • add a GeoPost (email, date, message, location) • list nearby GeoPosts
    • Example app: GeoPost • POST URL: https://mongolab.com/api/1/databases/demo/collections/geoposts data: { “email” : “will@mongolab.com”, “date” : { “$date” : “2010-02-03 10:21:21 UTC” }, “location” : { “lat” : 41, “long” : -82 }, “message” : “Hello Cleveland!” } • GET URL: https://…/geoposts?q={"location":{"$near":{"lat":38,"long":-122}}}
    • Android SDK makes client-side easy • JSON: org.json.* • REST: org.apache.http.* HttpClient client = new DefaultHttpClient() HttpGet request = new HttpGet(url); HttpResponse response = client.execute(request); HttpEntity entity = response.getEntity(); InputStream in = entity.getContent(); String json = convertStreamToString(in); JSONObject o = new JSONObject(json);
    • For more info… • MongoDB / 10Gen – http://mongodb.org – http://10gen.com • MongoLab – http://mongolab.com – will@mongolab.com