SlideShare a Scribd company logo
1 of 18
Using MongoDB for IGN’s Social Platform MongoSF Tuesday May 24th, 2011
Agenda About Architecture MongoDB Usage ActivityStreams Configuration, Monitoring, Maintenance Backup Tools Lessons Learned, Next steps
About About IGN We have the largest audience of gamers in the world Over 70M Monthly Uniques About IGN’s Social Platform: An API to connect gamer community with editors, games, other gamers, and help lay the foundation for premium content discovery as well as UGC Launched Sept 2010 ~7M activities  30M API calls per day (24h), ~9ms response times
Architecture REST based API, built in Java Entities are People, MediaItems, Activities, Comments, Notifications, Status Interfaces across IGN.com as well as other social networks Caching tier based on memcached MySQL and MongoDB as persistence PHP/Zend front end
MongoDB Usage Activity Streams : ActivityStrea.ms standard Activity Caching : (more on this later!) Activity Commenting Points, Leaderboards : Also extend to badges Block lists, Ban lists Notifications for conversations  Analytics : Activity snapshot for a user
Challenges with ActivityStreams Lots of data! Large amount of data coming out as a result Reverse sorting The data has to be sorted in reverse natural order ($natural : -1), and we do not use capped collections Aggregation of similar activities Impacts pagination Fetching self activities (profile), and newsfeed (self + friends) Filtering based on the activity type People want to see Game Updates or Blog updates from their friends Hydration of activities for dynamic data The thumbnail and level of the actor or commenter may change Activity Comments  When an activity is rendered, the initial comments and count has to be pulled ($slice). Not having a $sizeOf type operator hurts. No Embedding or References We build data on the fly as a part of hydration process
Caching using MongoDB Caching the entire streams A bad idea (or bad implementation?) The expired objects sat in the db, bloating the database The removal did not free up space, so we ran out Batch removals clogged the slaves Use Mongo as a cache-key-index Cache the streams in Memcached For invalidation, keep the index of the memcached keys in MongoDB. Works!
Configuration Server: 1 Master, 2 Slaves (load balanced thru Netscalar) 2 extra slaves which are not queried (replicate!!) Version 1.6.1 1.8.1 with Journaling is being tested in Stage Clients: Java Driver (2.1) Ruby Driver (1.2) Mappers: Morphia for Java, MongoMapper for Ruby Connections per host : 200, #hosts = 4 Oplog Size: 1GB, gives us ~272 hours Syncdelay: 60s (default) Hardware: 2 core, 6 GB virtualized machine
Monitoring Slow Query Logs after every new build Nagios TCP Port Monitoring  Disk space monitoring CPU monitoring Munin Mongo connections  Memory usage Ops/second Write Lock % Collection Sizes (in terms of # of documents) MMS Started using it 2 weeks ago as a beta customer
Maintenance Data defragmentation Slaves – by running it on different port Master – by having a downtime Collection trimming The scripts block during remove Bulk removes kills the slaves, spiking CPU 100%
Backup or prepping for O S***! NetApp Filter based, snapshots Make sure to do {fsync:1} and {lock:1} on one slave Hourly dumps via a cron job Using mongodump Incremental backup via the oplog Replay the oplog instead of relying on a snapshot Delayed slaves  Not recommended as it almost guarantees data loss proportional to the delay, which is inversely proportional to the time-to-react
Tools to be familiar with mongostat Look at queue lengths, memory, connections and operation mix db.serverStatus() Server status with sync, pagefaults, locks, index misses atop iostat/vm_stat db.stats() Overall info at the database level db.<coll_name>.stats() Overall info at the collection level db.printReplicationInfo() Info about the oplog size andlength in time db.printSlaveReplicationInfo() Info about the master, the last sync timetamp, and how behind the slave is from the master. The delays could be no writes on the master if the numbers look wonky.
What we’ve learned Keep an eye on Page Faults Index misses Queue lengths Write Lock % Database sizes on disk due to reuse vs. release Use .explain()  Watch for nscanned and indexBounds Use limit() when using find While updating, try to load that object in memory so that its in the working set (findAndModify) Try to keep the fields being selected at a minimum Do not use writeconcerns Elegant schema design might bite you – design for performance and ease of programming Write to multiple collections instead of doing mapreduce operations
Next Steps Move to replica sets on 1.8.1 Move relationship graphs to MongoDB Shard the relationships based on the userId Run multiple mongo processes, splitting out collections among multiple databases Fan-out architecture instead of queries – using HornetQ and Scala (Akka)
Extra: Why Fanout vs. Query Mon May  9 14:43:00 [conn63907] query ignsocial.activities ntoreturn:200 scanAndOrder  reslen:7836 nscanned:135727  {query: { isActive: true, actorType: "PERSON", actorId: { $in: [ "230", "1529", "1872", "1915", "2103", "4606", "5759", "5925", "7235", "7580", "9254", "10226", "14508", "16758", "20282", "21246", "21546", "22302", "22376", "23104", "25657", "26421", "28381", "30094", "33409", "33918", "34749", "34901", "35136", "36327", "37473", "37760", "40984", "41701", "44708", "45348", "45950", "47529", "47654", "48249", "49157", "49160", "51094", "51256", "52680", "53301", "53337", "54261", "54270", "56900", "60724", "61119", "61983", "62888", "63546", "64251", "65911", "67058", "70065", "70196", "73863", "74918", "75547", "75993", "77017", "77950", "78211", "78473", "78659", "78858", "82535", "85376", "85384", "86909", "87883", "88489", "88818", "88975", "89783", "90029", "90587", "91206", "93051", "93502", "94200", ..36,203 such lines  …] }, created: {$gte: new Date(1302385379514) }, activityObjects.type: { $in: [ "BLOG_ENTRY" ] } }, orderby:{ created: -1 } }  nreturned:200 1054ms
About Me Manish Pandit Engineering Manager, API Platform IGN Entertainment @lobster1234
We are hiring Software Engineers to help us with exciting initiatives at IGN Technologies we use RoR, Java (no J2EE!), Scala, Spring, Play! Framework PHP/Zend, JQuery, HTML5, CSS3, Sencha Touch, PhoneGap MongoDB, memcached, Redis, Solr, ElasticSearch NewRelic for monitoring, 3Scale for Open APIs http://corp.ign.com/careers @ignjobs
References IGN’s Social Platform http://my.ign.com http://people.ign.com/ign-labs Mongo MuninPlugins https://github.com/erh/mongo-munin https://github.com/lobster1234/munin-mongo-collections Morphia http://code.google.com/p/morphia/

More Related Content

What's hot

1404 app dev series - session 8 - monitoring & performance tuning
1404   app dev series - session 8 - monitoring & performance tuning1404   app dev series - session 8 - monitoring & performance tuning
1404 app dev series - session 8 - monitoring & performance tuning
MongoDB
 
Diagnostics and Debugging
Diagnostics and DebuggingDiagnostics and Debugging
Diagnostics and Debugging
MongoDB
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
Takahiro Inoue
 

What's hot (20)

Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
 
Shootout at the PAAS Corral
Shootout at the PAAS CorralShootout at the PAAS Corral
Shootout at the PAAS Corral
 
MongoDB - Monitoring & queueing
MongoDB - Monitoring & queueingMongoDB - Monitoring & queueing
MongoDB - Monitoring & queueing
 
1404 app dev series - session 8 - monitoring & performance tuning
1404   app dev series - session 8 - monitoring & performance tuning1404   app dev series - session 8 - monitoring & performance tuning
1404 app dev series - session 8 - monitoring & performance tuning
 
Diagnostics and Debugging
Diagnostics and DebuggingDiagnostics and Debugging
Diagnostics and Debugging
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
 
Diagnostics & Debugging webinar
Diagnostics & Debugging webinarDiagnostics & Debugging webinar
Diagnostics & Debugging webinar
 
92 grand prix_2013
92 grand prix_201392 grand prix_2013
92 grand prix_2013
 
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in GoPutting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
Putting the Go in MongoDB: How We Rebuilt The MongoDB Tools in Go
 
Scalable Event Analytics with MongoDB & Ruby on Rails
Scalable Event Analytics with MongoDB & Ruby on RailsScalable Event Analytics with MongoDB & Ruby on Rails
Scalable Event Analytics with MongoDB & Ruby on Rails
 
Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011
 
ElasticSearch
ElasticSearchElasticSearch
ElasticSearch
 
Advanced troubleshooting linux performance
Advanced troubleshooting linux performanceAdvanced troubleshooting linux performance
Advanced troubleshooting linux performance
 
Как построить видеоплатформу на 200 Гбитс / Ольховченков Вячеслав (Integros)
Как построить видеоплатформу на 200 Гбитс / Ольховченков Вячеслав (Integros)Как построить видеоплатформу на 200 Гбитс / Ольховченков Вячеслав (Integros)
Как построить видеоплатформу на 200 Гбитс / Ольховченков Вячеслав (Integros)
 
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
 
Tuning Solr for Logs
Tuning Solr for LogsTuning Solr for Logs
Tuning Solr for Logs
 
How to monitor MongoDB
How to monitor MongoDBHow to monitor MongoDB
How to monitor MongoDB
 
Cassandra Summit 2014: Cassandra at Instagram 2014
Cassandra Summit 2014: Cassandra at Instagram 2014Cassandra Summit 2014: Cassandra at Instagram 2014
Cassandra Summit 2014: Cassandra at Instagram 2014
 
MongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster TutorialMongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster Tutorial
 
Monitoring MongoDB (MongoSV)
Monitoring MongoDB (MongoSV)Monitoring MongoDB (MongoSV)
Monitoring MongoDB (MongoSV)
 

Viewers also liked

Νέα θέματα Χημείας Γ γυμνασίου
Νέα θέματα Χημείας Γ γυμνασίουΝέα θέματα Χημείας Γ γυμνασίου
Νέα θέματα Χημείας Γ γυμνασίου
Christos Gotzaridis
 
Animatic Feedback
Animatic FeedbackAnimatic Feedback
Animatic Feedback
3246
 
Animatic Feedbac Kf
Animatic Feedbac KfAnimatic Feedbac Kf
Animatic Feedbac Kf
3246
 
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειου
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειουΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειου
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειου
Christos Gotzaridis
 
Political Cartoon
Political CartoonPolitical Cartoon
Political Cartoon
Amy
 
第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource
Kaz Watanabe
 
Katechismus 11 - 12 jarigen - De Geloofsbelijdenis
Katechismus 11 - 12 jarigen - De GeloofsbelijdenisKatechismus 11 - 12 jarigen - De Geloofsbelijdenis
Katechismus 11 - 12 jarigen - De Geloofsbelijdenis
N Couperus
 

Viewers also liked (20)

NoSQLCamp : MongoDB at IGN
NoSQLCamp : MongoDB at IGNNoSQLCamp : MongoDB at IGN
NoSQLCamp : MongoDB at IGN
 
Νέα θέματα Χημείας Γ γυμνασίου
Νέα θέματα Χημείας Γ γυμνασίουΝέα θέματα Χημείας Γ γυμνασίου
Νέα θέματα Χημείας Γ γυμνασίου
 
Animatic Feedback
Animatic FeedbackAnimatic Feedback
Animatic Feedback
 
Animatic Feedbac Kf
Animatic Feedbac KfAnimatic Feedbac Kf
Animatic Feedbac Kf
 
Analisi ergonomica della segnaletica nell’edificio U6 Milano Bicocca
Analisi ergonomica della segnaletica nell’edificio U6 Milano BicoccaAnalisi ergonomica della segnaletica nell’edificio U6 Milano Bicocca
Analisi ergonomica della segnaletica nell’edificio U6 Milano Bicocca
 
Futurology Pres Ver 3.1
Futurology Pres Ver 3.1Futurology Pres Ver 3.1
Futurology Pres Ver 3.1
 
οδηγιες & υλη φυσικων μαθηματων ημερ. και εσπ. γυμν. 2010 11
οδηγιες & υλη φυσικων μαθηματων ημερ. και εσπ. γυμν. 2010 11οδηγιες & υλη φυσικων μαθηματων ημερ. και εσπ. γυμν. 2010 11
οδηγιες & υλη φυσικων μαθηματων ημερ. και εσπ. γυμν. 2010 11
 
asptours
asptoursasptours
asptours
 
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειου
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειουΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειου
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΤΗΣ ΦΥΣΙΚΗΣ Α ΛΥΚΕΙΟΥ 2011-12 διδασκαλιασ τησ φυσικησ α λυκειου
 
Mapping an all-weather Tour de France
Mapping an all-weather Tour de FranceMapping an all-weather Tour de France
Mapping an all-weather Tour de France
 
Silicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you RESTSilicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you REST
 
Political Cartoon
Political CartoonPolitical Cartoon
Political Cartoon
 
第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource
 
De Wijding
De WijdingDe Wijding
De Wijding
 
Global warming
Global warmingGlobal warming
Global warming
 
API Design Antipatterns - APICon SF
API Design Antipatterns - APICon SFAPI Design Antipatterns - APICon SF
API Design Antipatterns - APICon SF
 
Katechismus 11 - 12 jarigen - De Geloofsbelijdenis
Katechismus 11 - 12 jarigen - De GeloofsbelijdenisKatechismus 11 - 12 jarigen - De Geloofsbelijdenis
Katechismus 11 - 12 jarigen - De Geloofsbelijdenis
 
Slideshare
SlideshareSlideshare
Slideshare
 
1 3
1 31 3
1 3
 
A R L F Opening Heloisev2
A R L F  Opening  Heloisev2A R L F  Opening  Heloisev2
A R L F Opening Heloisev2
 

Similar to MongoSF 2011 - Using MongoDB for IGN's Social Platform

Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
Rob Davarnia
 
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps PerspectiveMongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB
 
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 

Similar to MongoSF 2011 - Using MongoDB for IGN's Social Platform (20)

Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and PythonRapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and Python
 
MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' MeetupMongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
 
Java one 2010
Java one 2010Java one 2010
Java one 2010
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
[WSO2Con EU 2018] The Rise of Streaming SQL
[WSO2Con EU 2018] The Rise of Streaming SQL[WSO2Con EU 2018] The Rise of Streaming SQL
[WSO2Con EU 2018] The Rise of Streaming SQL
 
Performance Tuning Cheat Sheet for MongoDB
Performance Tuning Cheat Sheet for MongoDBPerformance Tuning Cheat Sheet for MongoDB
Performance Tuning Cheat Sheet for MongoDB
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
MongoDB 3.2 - a giant leap. What’s new?
MongoDB 3.2 - a giant leap. What’s new?MongoDB 3.2 - a giant leap. What’s new?
MongoDB 3.2 - a giant leap. What’s new?
 
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps PerspectiveMongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps Perspective
 
mongodb tutorial
mongodb tutorialmongodb tutorial
mongodb tutorial
 
2021 04-20 apache arrow and its impact on the database industry.pptx
2021 04-20  apache arrow and its impact on the database industry.pptx2021 04-20  apache arrow and its impact on the database industry.pptx
2021 04-20 apache arrow and its impact on the database industry.pptx
 
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
 
Mongodb beijingconf yottaa_3.3
Mongodb beijingconf yottaa_3.3Mongodb beijingconf yottaa_3.3
Mongodb beijingconf yottaa_3.3
 
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
A Front-Row Seat to Ticketmaster’s Use of MongoDB
A Front-Row Seat to Ticketmaster’s Use of MongoDBA Front-Row Seat to Ticketmaster’s Use of MongoDB
A Front-Row Seat to Ticketmaster’s Use of MongoDB
 
Node.js and MongoDB from scratch, fully explained and tested
Node.js and MongoDB from scratch, fully explained and tested Node.js and MongoDB from scratch, fully explained and tested
Node.js and MongoDB from scratch, fully explained and tested
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 

More from Manish Pandit

OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
Manish Pandit
 

More from Manish Pandit (20)

Disaster recovery - What, Why, and How
Disaster recovery - What, Why, and HowDisaster recovery - What, Why, and How
Disaster recovery - What, Why, and How
 
Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018
 
Disaster Recovery and Reliability
Disaster Recovery and ReliabilityDisaster Recovery and Reliability
Disaster Recovery and Reliability
 
OAuth2 primer
OAuth2 primerOAuth2 primer
OAuth2 primer
 
Immutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and JenkinsImmutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and Jenkins
 
AWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaAWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and Java
 
AWS Primer and Quickstart
AWS Primer and QuickstartAWS Primer and Quickstart
AWS Primer and Quickstart
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID Connect
 
Silicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API AntipatternsSilicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API Antipatterns
 
Scalabay - API Design Antipatterns
Scalabay - API Design AntipatternsScalabay - API Design Antipatterns
Scalabay - API Design Antipatterns
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
 
Motivation : it Matters
Motivation : it MattersMotivation : it Matters
Motivation : it Matters
 
Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2
 
Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
 
Evolving IGN’s New APIs with Scala
 Evolving IGN’s New APIs with Scala Evolving IGN’s New APIs with Scala
Evolving IGN’s New APIs with Scala
 
IGN's V3 API
IGN's V3 APIIGN's V3 API
IGN's V3 API
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Silicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDBSilicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDB
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

MongoSF 2011 - Using MongoDB for IGN's Social Platform

  • 1. Using MongoDB for IGN’s Social Platform MongoSF Tuesday May 24th, 2011
  • 2. Agenda About Architecture MongoDB Usage ActivityStreams Configuration, Monitoring, Maintenance Backup Tools Lessons Learned, Next steps
  • 3. About About IGN We have the largest audience of gamers in the world Over 70M Monthly Uniques About IGN’s Social Platform: An API to connect gamer community with editors, games, other gamers, and help lay the foundation for premium content discovery as well as UGC Launched Sept 2010 ~7M activities 30M API calls per day (24h), ~9ms response times
  • 4. Architecture REST based API, built in Java Entities are People, MediaItems, Activities, Comments, Notifications, Status Interfaces across IGN.com as well as other social networks Caching tier based on memcached MySQL and MongoDB as persistence PHP/Zend front end
  • 5. MongoDB Usage Activity Streams : ActivityStrea.ms standard Activity Caching : (more on this later!) Activity Commenting Points, Leaderboards : Also extend to badges Block lists, Ban lists Notifications for conversations Analytics : Activity snapshot for a user
  • 6. Challenges with ActivityStreams Lots of data! Large amount of data coming out as a result Reverse sorting The data has to be sorted in reverse natural order ($natural : -1), and we do not use capped collections Aggregation of similar activities Impacts pagination Fetching self activities (profile), and newsfeed (self + friends) Filtering based on the activity type People want to see Game Updates or Blog updates from their friends Hydration of activities for dynamic data The thumbnail and level of the actor or commenter may change Activity Comments When an activity is rendered, the initial comments and count has to be pulled ($slice). Not having a $sizeOf type operator hurts. No Embedding or References We build data on the fly as a part of hydration process
  • 7. Caching using MongoDB Caching the entire streams A bad idea (or bad implementation?) The expired objects sat in the db, bloating the database The removal did not free up space, so we ran out Batch removals clogged the slaves Use Mongo as a cache-key-index Cache the streams in Memcached For invalidation, keep the index of the memcached keys in MongoDB. Works!
  • 8. Configuration Server: 1 Master, 2 Slaves (load balanced thru Netscalar) 2 extra slaves which are not queried (replicate!!) Version 1.6.1 1.8.1 with Journaling is being tested in Stage Clients: Java Driver (2.1) Ruby Driver (1.2) Mappers: Morphia for Java, MongoMapper for Ruby Connections per host : 200, #hosts = 4 Oplog Size: 1GB, gives us ~272 hours Syncdelay: 60s (default) Hardware: 2 core, 6 GB virtualized machine
  • 9. Monitoring Slow Query Logs after every new build Nagios TCP Port Monitoring Disk space monitoring CPU monitoring Munin Mongo connections Memory usage Ops/second Write Lock % Collection Sizes (in terms of # of documents) MMS Started using it 2 weeks ago as a beta customer
  • 10. Maintenance Data defragmentation Slaves – by running it on different port Master – by having a downtime Collection trimming The scripts block during remove Bulk removes kills the slaves, spiking CPU 100%
  • 11. Backup or prepping for O S***! NetApp Filter based, snapshots Make sure to do {fsync:1} and {lock:1} on one slave Hourly dumps via a cron job Using mongodump Incremental backup via the oplog Replay the oplog instead of relying on a snapshot Delayed slaves Not recommended as it almost guarantees data loss proportional to the delay, which is inversely proportional to the time-to-react
  • 12. Tools to be familiar with mongostat Look at queue lengths, memory, connections and operation mix db.serverStatus() Server status with sync, pagefaults, locks, index misses atop iostat/vm_stat db.stats() Overall info at the database level db.<coll_name>.stats() Overall info at the collection level db.printReplicationInfo() Info about the oplog size andlength in time db.printSlaveReplicationInfo() Info about the master, the last sync timetamp, and how behind the slave is from the master. The delays could be no writes on the master if the numbers look wonky.
  • 13. What we’ve learned Keep an eye on Page Faults Index misses Queue lengths Write Lock % Database sizes on disk due to reuse vs. release Use .explain() Watch for nscanned and indexBounds Use limit() when using find While updating, try to load that object in memory so that its in the working set (findAndModify) Try to keep the fields being selected at a minimum Do not use writeconcerns Elegant schema design might bite you – design for performance and ease of programming Write to multiple collections instead of doing mapreduce operations
  • 14. Next Steps Move to replica sets on 1.8.1 Move relationship graphs to MongoDB Shard the relationships based on the userId Run multiple mongo processes, splitting out collections among multiple databases Fan-out architecture instead of queries – using HornetQ and Scala (Akka)
  • 15. Extra: Why Fanout vs. Query Mon May 9 14:43:00 [conn63907] query ignsocial.activities ntoreturn:200 scanAndOrder reslen:7836 nscanned:135727 {query: { isActive: true, actorType: "PERSON", actorId: { $in: [ "230", "1529", "1872", "1915", "2103", "4606", "5759", "5925", "7235", "7580", "9254", "10226", "14508", "16758", "20282", "21246", "21546", "22302", "22376", "23104", "25657", "26421", "28381", "30094", "33409", "33918", "34749", "34901", "35136", "36327", "37473", "37760", "40984", "41701", "44708", "45348", "45950", "47529", "47654", "48249", "49157", "49160", "51094", "51256", "52680", "53301", "53337", "54261", "54270", "56900", "60724", "61119", "61983", "62888", "63546", "64251", "65911", "67058", "70065", "70196", "73863", "74918", "75547", "75993", "77017", "77950", "78211", "78473", "78659", "78858", "82535", "85376", "85384", "86909", "87883", "88489", "88818", "88975", "89783", "90029", "90587", "91206", "93051", "93502", "94200", ..36,203 such lines …] }, created: {$gte: new Date(1302385379514) }, activityObjects.type: { $in: [ "BLOG_ENTRY" ] } }, orderby:{ created: -1 } } nreturned:200 1054ms
  • 16. About Me Manish Pandit Engineering Manager, API Platform IGN Entertainment @lobster1234
  • 17. We are hiring Software Engineers to help us with exciting initiatives at IGN Technologies we use RoR, Java (no J2EE!), Scala, Spring, Play! Framework PHP/Zend, JQuery, HTML5, CSS3, Sencha Touch, PhoneGap MongoDB, memcached, Redis, Solr, ElasticSearch NewRelic for monitoring, 3Scale for Open APIs http://corp.ign.com/careers @ignjobs
  • 18. References IGN’s Social Platform http://my.ign.com http://people.ign.com/ign-labs Mongo MuninPlugins https://github.com/erh/mongo-munin https://github.com/lobster1234/munin-mongo-collections Morphia http://code.google.com/p/morphia/