Skip to content

Instantly share code, notes, and snippets.

@alanshaw
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanshaw/10046987 to your computer and use it in GitHub Desktop.
Save alanshaw/10046987 to your computer and use it in GitHub Desktop.
Meteor, MongoDB, oplog tailing and you

Meteor, MongoDB, oplog tailing and you


Prior art

  • Pub sub
  • Live data sets
  • Poll and diff

What's wrong with poll and diff?

  • More writes, more polls
  • Mongo bandwidth
  • Large record sets
  • Latency

What is oplog?

  • MongoDB replica set
  • A capped collection
  • A rolling record of all operations that modify data

What is oplog tailing?

  • Follow along and find out about changes immediately
  • Let the database tell us when things have changed

What does an entry look like?

{
    "ts" : Timestamp(1396897233, 1),
    "h" : NumberLong(-8686789604923146223),
    "v" : 2,
    "op" : "i",
    "ns" : "bookstore.users",
    "o" : {
        "password" : "$2a$10$ZK5uFJ8T4Z.TMbvafMIpauYQf0CrGN2DXbJrgVlbFlOgDHnTjWTw6",
        "email" : "test@example.org",
        "name" : "Test User",
        "settings" : {
            "fontSize" : 160,
            "colourScheme" : "standard"
        },
        "books" : [],
        "canAccessKeystone" : false,
        "joinDate" : ISODate("2014-04-07T19:00:33.371Z"),
        "_id" : ObjectId("5342f5d15d28ce2802021770"),
        "__v" : 0
    }
}

What does it mean?

  • Less computation
  • Reduced db bandwidth
  • More connected clients
  • Profit?

More info


@LeCoupa
Copy link

LeCoupa commented May 18, 2014

Nice! Great Summary!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment