Slide 1

Slide 1 text

Migrating from EC2 to Atlas

Slide 2

Slide 2 text

! Jesse Dearing Lead Site Reliability Engineer

Slide 3

Slide 3 text

InVisionApp

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

MongoDB @ InVision • Chef to manage EC2 instances and MongoDB • 28 MongoDB replica sets across 4 environments • 1500-2000 documents per second retrieved, 300-600 documents per second created or modified

Slide 6

Slide 6 text

MongoDB @ InVision • Powers various features of our application • We find it useful for when a document model makes the most sense • Example of this is Inspect

Slide 7

Slide 7 text

Starting out with Mongo on AWS • Provision EC2 instances • Chef, Puppet, Ansible, or manually install and configure MongoDB • Set it up as a replica set • Maybe even sharded

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

You still have to take care of • Backups • Monitoring • Alerting • Security • Updates

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Why? This is what I do • Your job is to maintain MongoDB infrastructure • What are the hiring projections for your team? • At InVision we believe in multiplying the efforts of our teams while growing them at a linear growth (a la SRE)

Slide 12

Slide 12 text

Classic Build vs Buy Proposition DevOps edition • You and your team are smart and capable, of course you can build it!

Slide 13

Slide 13 text

Classic Build vs Buy Proposition DevOps edition • Do you have the time to maintain the new infrastructure? • Do you want to answer the pager for when your EC2 instances have issues?

Slide 14

Slide 14 text

Why we switched to Atlas • Easier management of the aforementioned reasons • Easy to use REST API • Graphical dashboards

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

How do we get on Atlas?

Slide 17

Slide 17 text

Preparation • Atlas requires SSL • Set up AWS VPC peering • VPN and Security setup • Make sure we were using Amazon DNS

Slide 18

Slide 18 text

Preparation • Pick a network CIDR that won’t collide with your networks • We have multiple VPCs for different environments so we picked something like 10.200.0.0/16 • Assess current instances I/O, CPU, and Memory and figure out how they can map to the Atlas instance types • Make sure you don’t have any locale requirements for your Mongo data

Slide 19

Slide 19 text

Preparation • Need to be on MongoDB 3.x using WiredTiger • Test on replicas and use testing/staging environments

Slide 20

Slide 20 text

Migration • Simple • Just write a simple daemon in C++ that tails and parses the oplog and replay it in your Atlas MongoDB cluster

Slide 21

Slide 21 text

Just Kidding

Slide 22

Slide 22 text

Atlas Live Migration • MongoDB announced live migration to Atlas in March • Built into the web UI • Or you can use mongomirror

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Create Atlas cluster

Slide 25

Slide 25 text

Create Instance to run mongomirror

Slide 26

Slide 26 text

Perform initial sync

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Stream oplog to sync

Slide 29

Slide 29 text

Cut over application

Slide 30

Slide 30 text

Post Migration • Set up alerts • Start with a low watermark until you have a good baseline after a week or so • Update runbooks and test backup restores

Slide 31

Slide 31 text

Where we’ve gone • With a good API we’ve found that we can automate provisioning • Self service integration into provisioning • Deploying a new service? Want some MongoDB with that?

Slide 32

Slide 32 text

Automation • The REST API is pretty easy to use • We’ve incorporated it into our Ansible scripts • Source at github.com/jessedearing/ansible- mongodb-atlas

Slide 33

Slide 33 text

Using Ansible to easily add new Mongo Replicasets 1 --- 2 - hosts: mongodb_atlas 3 connection: local 4 roles: 5 - role: mongodb_atlas 6 clusters: 7 - name: staging-mongo-loginapi 8 size: M30 9 state: present 10 - name: prod-mongo-loginapi 11 size: M30 12 state: present

Slide 34

Slide 34 text

Using Ansible to easily add new Mongo Replicasets 1 --- 2 - hosts: mongodb_atlas 3 connection: local 4 roles: 5 - role: mongodb_atlas 6 clusters: 7 - name: staging-mongo-loginapi 8 size: M30 9 state: present 10 - name: prod-mongo-loginapi 11 size: M30 12 state: present 1 --- 2 - hosts: mongodb_atlas 3 connection: local 4 roles: 5 - role: mongodb_atlas 6 clusters: 7 - name: staging-mongo-loginapi 8 size: M30 9 state: present 10 - name: prod-mongo-loginapi 11 size: M30 12 state: present 13 - name: test-mongo-loginapi 14 size: M10 15 state: present

Slide 35

Slide 35 text

Go give Atlas a shot • Requires MongoDB SSL • Pick your region and a network CIDR that doesn’t collide with your existing CIDR • mongomirror or live migrate • Leave running MongoDB to the experts

Slide 36

Slide 36 text

Thanks!

Slide 37

Slide 37 text

Questions?