Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MongoDB Belgium #1: The kickoff

MongoDB Belgium #1: The kickoff

MongoDB introduction and How we use MongoDB at Darwin Analytics

Hannes Van De Vreken

March 18, 2014
Tweet

More Decks by Hannes Van De Vreken

Other Decks in Programming

Transcript

  1. • Registered on Meetup.com 6 months ago,
 day-to-day
 • 150+

    members • Every 3 months • What about MongoDB Brussels? MONGODB BELGIUM
  2. Nils De Moor
 CTO & Co-founder of Woorank 
 Moving

    from the past (MySQL) to the present (MongoDB, S3, Redis) & the future (MongoDB, S3, Hadoop) ! ! Arthur Viegers
 Senior solutions architect at MongoDB inc ! Internet of Things & MongoDB ! ! Hannes Van De Vreken Back-end engineer at Darwin Analytics ! MongoDB intro and MongoDB at Darwin Analytics SPEAKERS
  3. Hannes Van De Vreken • Developer at Darwin Analytics (host)

    • Using MongoDB for 1.5 years • Started the Meetup group WHO AM I
  4. • Document store for (nested) JSON objects • Schema-less documents

    • Sharding & replication (horizontal scaling) • Uniform drivers for every major language MONGODB INTRO
  5. Driver’s crud operations 
 Store documents • db.collection.insert({“name”: “John Doe”});

    ! Retrieve documents • db.collection.find({“_id”: “abcdef”}, {“name”: 1}) • .sort({“age”: -1}).skip(20).limit(10)
 Update documents: • db.collection.update({“_id”: “abcdef”}, {“name”: “J”})
 Delete documents: • db.collection.remove({“_id”: “abcdef”}) MONGODB ! ! ! ! ! // first parameter is a query object
 // operations on a cursor
 
 // same query object
 
 // same query object
  6. Query operators ! • $gt, $lt, $gte, $lte
 • $in,

    $nin
 • $ne
 • $or MONGODB // greater|less than (or equal) 
 // array operators 
 // not equal ! // combine
  7. MONGODB • Aggregation pipeline
 $match, $group, $project & $unwind
 $sort,

    $skip, $limit
 $geoNear
 $group accumulators: 
 $addToSet, $push, $first, $last, $min, $max, $avg, $sum
 • MapReduce: JS functions 
 More flexible aggregation but no use of indexes: 
 runs over every single document
  8. MONGODB • Replication
 Read >> Write (master-slave replication)
 High availability


    • Sharding (based on a key)
 Writes are distributed
 MapReduce execution improvement (read operation)
  9. MONGODB • Store it in the format you want to

    retrieve the documents
 • Filter and query the documents on some well defined fields (and add indexes)
 • You can put indexes on array fields (eg. tags) but limit the array size
  10. • Tracking content and its result on online sales
 •

    Only show marketers notable metrics and their content WHAT IS DARWIN ANALYTICS?
  11. • Step 1: Retrieve all data from APIs
 • Step

    2: Store it on Amazon S3
 • Step 3: Write it sequentially to MongoDB
 • Step 4: Process the new data and store raw numbers
 • Step 5: Show statistical data to users and noteworthy content, retrieved from MongoDB MONGODB USAGE
  12. MONGODB USAGE • PHP 5.4
 • LaravelPHP 4.1 (and Angular.js)


    • jenssegers/mongodb-lite (adapter)
 • $db = DB::connection(‘mongodb’);