Slide 1

Slide 1 text

MongoDB to Cassandra The Atlas Odyssey Fred van den Driessche Engineer @fredvdd Tom McAdam CTO @tfm Adam Horwich Systems Engineer @Mmmkayness

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

http://flickr.com/photos/dhammza/88644497/

Slide 4

Slide 4 text

tbc Video and audio metadata from 20+ sources Profiles and activity from video and audio products, social networks Our platform - late 2012 tbc MetaBroadcast platform Analytic requests and groupings

Slide 5

Slide 5 text

?

Slide 6

Slide 6 text

Main clients Main Partners Data Partners

Slide 7

Slide 7 text

What is Atlas? ATLAS DB BBC PA C4 etc... /content /schedules /topics sitemaps radioplayer interlinking

Slide 8

Slide 8 text

DEMO

Slide 9

Slide 9 text

Atlas Data Model brand item series version broadcast location

Slide 10

Slide 10 text

MongoDB • flexible • features • really simple • shell

Slide 11

Slide 11 text

Where MongoDB falls short • too simple • lack of control • sharding • embedding

Slide 12

Slide 12 text

Where to?

Slide 13

Slide 13 text

Where to? • add a cache?

Slide 14

Slide 14 text

Atlas API • content • http://atlas.metabroadcast.com/3.0/content.json?uri=http://www.bbc.co.uk/programmes/ b0074g7p&annotations=description,brand_summary,locations&apiKey=6ed2a984627daff816198acde82 • http://atlas.metabroadcast.com/3.0/content.json?apiKey=aaaa&uri=http://www.bbc.co.uk/programmes/ b0074g7p&annotations=description,brand_summary,locations • schedules • http://atlas.metabroadcast.com/3.0/schedule.json?from=now&to=now.plus. 3h&channel=bbcone&publisher=bbc.co.uk • http://atlas.metabroadcast.com/3.0/schedule.json? from=1948-12-24&to=1948-12-25&channel=radio4&publisher=bbc.co.uk • api explorer http://atlas.metabroadcast.com/#apiExplorer

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Atlas API • content • http://atlas.metabroadcast.com/3.0/content.json?uri=http://www.bbc.co.uk/programmes/ b0074g7p&annotations=description,brand_summary,locations&apiKey=6ed2a984627daff816198acde82 • http://atlas.metabroadcast.com/3.0/content.json?apiKey=aaaa&uri=http://www.bbc.co.uk/programmes/ b0074g7p&annotations=description,brand_summary,locations • schedules • http://atlas.metabroadcast.com/3.0/schedule.json?from=now&to=now.plus. 3h&channel=bbcone&publisher=bbc.co.uk • http://atlas.metabroadcast.com/3.0/schedule.json? from=1948-12-24&to=1948-12-25&channel=radio4&publisher=bbc.co.uk • api explorer http://atlas.metabroadcast.com/#apiExplorer

Slide 17

Slide 17 text

Why Cassandra? • scalability/performance • row caches • consistency control • column-based model matches our use case

Slide 18

Slide 18 text

And? • ElasticSearch • messaging • tooling: bootstraps

Slide 19

Slide 19 text

What is Atlas? BBC PA C4 etc... Data ingest server DB Update bus ES HTTP server

Slide 20

Slide 20 text

Data model • columns to model annotations • secondary indexes • index.direct(keyspace, SEGMENT_URI_INDEX_CF, ConsistencyLevel.CL_QUORUM). from(segment.getCanonicalUri()). to(segment.getIdentifier()). index().execute(requestTimeout, TimeUnit.MILLISECONDS);

Slide 21

Slide 21 text

ID generation • give external data our own ID on ingest • needs to be user-friendly: http://www.radiotimes.com/programme/cf2/eastenders • mongo: findAndModify() • solution: uses Astyanax client with its distributed locking • more details: http://metabroadcast.com/blog/let- cassandra-identify-your-data

Slide 22

Slide 22 text

Where we’re at • already live with some data • alpha release of schedule endpoint coming soon • later: roll out across other endpoints

Slide 23

Slide 23 text

Ops

Slide 24

Slide 24 text

Ops in Cassandra • we love Puppet • it’s great for automation and deployment • MongoDB: 1 file • Cassandra: 2 files! • oh... tokens

Slide 25

Slide 25 text

Cassandra Tokens • define where data is written to in a cluster • therefore balanced tokens = balanced cluster • tokens should be rack aware • tools available to provide appropriate tokens for you

Slide 26

Slide 26 text

Cassandra plays nicely with AWS • datacentre / rack aware • AWS Region = Datacentre • AWS Availability Zone = Rack • only recently introduced in MongoDB but simple to implement in Cassandra • horizontally (and vertically) scalable

Slide 27

Slide 27 text

Monitoring • Nagios is a little threadbare for Cassandra • basic TCP service check • stats from API not very helpful • nodetool and CLI tools useful • manual effort to integrate them • if only there was some useful service...

Slide 28

Slide 28 text

OpsCenter • wonderful for an overview • not so much for alerting ;) • ohai API • can integrate metrics into Nagios

Slide 29

Slide 29 text

Disaster Recovery • we operate a 4 node cluster presently • replication factor of 3 with quorum read/writes • DR complicated by tokens • cluster should be balanced • snapshot + S3 Backups

Slide 30

Slide 30 text

Cluster Happiness and Headaches • little maintenance overhead • cluster rebalancing • uncommon maintenance procedure • schema changes are cumbersome • little scope for rollback, can put cluster in unrecoverable state

Slide 31

Slide 31 text

Summary • Mongo is good, Atlas has outgrown it • Cassandra isn’t a drop-in replacement • Ops more complex but so far so good

Slide 32

Slide 32 text

Questions?