Mongo db - How we use Go and MongoDB by Sam Helman


Published on

In this talk, we'll hear from Sam Helman, Software Engineer at 10gen, on how 10gen is integrating Go into our new and existing cloud tools. Some of the tools leveraging Go include the backup capabilities in MongoDB Management Service and a continuos integration tool. This was an opportunity to experiment with new technologies and create a better product for end users.

Programming the in Go and the mgo driver has been extremely satisfying. Between the lightweight syntax, the first-class concurrency and the well documented, idiomatic libraries such as mgo, Go is a great choice for writing anything from small scripts to large distributed applications. In this talk, Sam will go through how the team has integrated Go and why Go and MongoDB are a great match for cloud services.

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • MongoDB Management Service (MMS) is a cloud-based suite of services for managing MongoDB deployments. MMS provides monitoring and backup capabilities, helping users optimize clusters, automate tasks and mitigate operational risk. For customers that prefer to manage MongoDB on their own infrastructure, 10gen also offers MMS MonitoringOn-Prem as part of MongoDB Enterprise (backup features coming soon).
  • Install lightweight agent written in Go so it’s compiled nativelyPerform an initial syncOplog tails going forward – performance impact similar to adding another secondaryEncrypted in motion
  • 6 hour snaps for 48Dailys kept for 1 week1 snap kept 1 monthMonthlys kept for a yearDatacenters on east coast
  • Get the discount code from Meghan or Rhea
  • Mongo db - How we use Go and MongoDB by Sam Helman

    1. 1. Go at 10gen Sam Helman, Software Engineer
    2. 2. What is Go? “Go is an open source programming environment that makes it easy to build simple, reliable, and efficient software” - Google
    3. 3. What is Go? - A programming language (Golang)
    4. 4. Language features - Code organized into packages - Distinction b/t pointers and values - Structs instead of objects
    5. 5. Language features - First-class functions - Multiple return values - Concurrency via goroutines
    6. 6. Development features - Compiles quickly - Easy to learn, small - Strong standard libraries - http - subprocess - time - Nice plugins for editors - sublime text, vim, emacs
    7. 7. What else is Go? - A collection of development tools
    8. 8. mgo (mango) - Go Driver - - Uses standard API for MongoDB drivers - A little syntactic sugar (UpdateId, Upsert) - Connection pooling, cluster discovery, read preference, auth, GridFS
    9. 9. mgo's BSON Implementation - - Fully to spec - Supports marshalling, unmarshalling, ordered, unordered
    10. 10. Built-in ODM - Uses struct tags to define db->struct mappings - Tags aid mgo in unmarshalling documents
    11. 11. How we came to use Go
    12. 12. MMS Backup - Hosted backups for MongoDB - Lots of flexibility o Periodic snapshots o Point-in-time restore o Support for sharded clusters
    13. 13. How it works (in a nutshell) - Backup agent o Runs on customer’s machine o Syncs data, then tails oplog - Backend storage ("Mothership") o Collection of oplog operations (sent from agent) o Deduped block storage of periodic snapshots
    14. 14. Backup Agent - Originally written in Java - However, needs to live on customer's machines - Needs to be easily deployable - Java relies on customer's JVM, installed libraries, etc.
    15. 15. Benefits of Go - Go is compiled and statically linked o Doesn't rely on anything on target machine o Large binaries, but no dependencies - Can be cross-compiled easily o o GOOS, GOARCH
    16. 16. Mongo Continuous Integration (MCI) - Our home-brewed CI system - Used to test MongoDB cross-platform - Built for a number of considerations o Parallelization o Flexibility o Ease of tuning o Speed - (Will be open-source soon)
    17. 17. How it works - One master machine o Stores config info o Polls github for changes o Divides steps (compile, test) among workers o Sends agent process over to workers - Numerous worker machines o Run steps (via agent), report back to master
    18. 18. MCI Agent - Independent of master process - Runs on worker machines - Needs to run on all supported platforms o With minimal maintenance - Want to minimize worker machine setup o Many are dynamically spun up o As few dependencies as possible
    19. 19. Benefits of Go - No dependencies o Worker machines need only the agent binary - Cross-platform o Build on master machine, scp to workers - Single binary to copy to workers - Go dynamicallycompiles quickly o Agent code changes a lot o Rebuilt
    20. 20. MongoDB Management Service: Backup Overview
    21. 21. 21 What is MongoDB Management Service (MMS)?
    22. 22. How It Works
    23. 23. 23 Overview
    24. 24. 24 • From the initial sync, we rebuild your data in our datacenters and take a snapshot • We take snapshots every 6 hours • Oplog is stored for 48 hours Under the Hood
    25. 25. 25 • Balancer paused every 6 hours • A no-op token is inserted across all shards, mongoses and config servers • Oplog applied to replica sets until point in which token was inserted • Provides a consistent state of database across shards Sharded Clusters
    26. 26. Key Benefits
    27. 27. 27 • Oplog stored for 48 hours • Restore your replica set to any point-in-time in the last 48 hours by creating a custom snapshot Point-In-Time
    28. 28. 28 • Pull from custom URL • Push via SCP Easy to Restore
    29. 29. 29 • Confidence in your restore process • Build development, QA, analytics environments without impacting production Unlimited, Free Restores
    30. 30. 30 • Created by the engineers that build MongoDB • No need to write or maintain custom backup scripts Fully Managed
    31. 31. Getting Started
    32. 32. 32 1. Create an account at 2. Install MMS Monitoring Agent on your deployment 3. Register at 4. Install MMS Backup Agent on your deployment 5. Start initial sync 6. Rest easy! Getting Started
    33. 33. Free Month – Register Using Coupon Code “MUG_NYC”