SlideShare a Scribd company logo
Scalable Event Analytics with Ruby on Rails & MongoDBRuby Conf China 2010Jared Rosoff (@forjared)  jrosoff@yottaa.com
Yottaa!!!! (www.yottaa.com)
OverviewRuby at ScaleWhat is Event Analytics? What are the different ways you could do it? How we did it
Ruby At Scale?http://www.flickr.com/photos/laughingsquid
Event AnalyticsData SourceEventUserEventEventQueryEvent AnalyticsData SourceReportEventEventEventEventUserQueryData SourceEventEventReportEventEventEventData Source
Scalable Event Analytics with MongoDB & Ruby on Rails
Oh and we are a startup
Our requirements:
Rails default architectureCollection ServerData SourceMySQLUserReporting Server
Rails default architectureCollection ServerData SourceMySQLUserReporting Server“Just” a Rails App
Rails default architecture	Performance Bottleneck: Too much loadCollection ServerData SourceMySQLUserReporting Server“Just” a Rails App
Let’s add replication!MySQLMasterCollection ServerData SourceReplicationMySQLMasterUserReporting ServerMySQLMasterMySQLMaster
Let’s add replication!MySQLMasterCollection ServerData SourceReplicationMySQLMasterUserReporting ServerMySQLMasterMySQLMasterOff the shelf!Scalable Reads!
Let’s add replication!	Performance Bottleneck: Still can’t scale writesMySQLMasterCollection ServerData SourceReplicationMySQLMasterUserReporting ServerMySQLMasterMySQLMasterOff the shelf!Scalable Reads!
What about sharding?Collection ServerData SourceShardingMySQLMasterMySQLMasterMySQLMasterUserReporting ServerSharding
What about sharding?Collection ServerData SourceShardingMySQLMasterMySQLMasterMySQLMasterUserReporting ServerShardingScalable Writes!
What about sharding?	Development Bottleneck:Need to write custom codeCollection ServerData SourceShardingMySQLMasterMySQLMasterMySQLMasterUserReporting ServerShardingScalable Writes!
Key Value stores to the rescue?Collection ServerData SourceMySQLMasterMySQLMasterCassandra orVoldemortUserReporting Server
Key Value stores to the rescue?Collection ServerData SourceMySQLMasterMySQLMasterCassandra orVoldemortUserReporting ServerScalable Writes!
Key Value stores to the rescue?	Development Bottleneck:Reporting is limited / hardCollection ServerData SourceMySQLMasterMySQLMasterCassandra orVoldemortUserReporting ServerScalable Writes!
Can I Hadoop my way out of this?MySQLMasterMySQLMasterCassandra orVoldemortCollection ServerData SourceHadoopMySQLMasterMySQLMasterUserReporting ServerMySQLMasterMySQLSlave
Can I Hadoop my way out of this?MySQLMasterMySQLMasterCassandra orVoldemortCollection ServerData SourceHadoopMySQLMasterScalable Writes!MySQLMasterUserReporting ServerMySQLMasterMySQLSlave
Can I Hadoop my way out of this?MySQLMasterMySQLMasterCassandra orVoldemortCollection ServerData SourceHadoopMySQLMasterScalable Writes!Flexible Reports!MySQLMasterUserReporting ServerMySQLMasterMySQLSlave
Can I Hadoop my way out of this?MySQLMasterMySQLMasterCassandra orVoldemortCollection ServerData SourceHadoopMySQLMasterScalable Writes!Flexible Reports!“Just” a Rails AppMySQLMasterUserReporting ServerMySQLMasterMySQLSlave
Can I Hadoop my way out of this?	Development Bottleneck:Too many systems!MySQLMasterMySQLMasterCassandra orVoldemortCollection ServerData SourceHadoopMySQLMasterScalable Writes!Flexible Reports!“Just” a Rails AppMySQLMasterUserReporting ServerMySQLMasterMySQLSlave
MongoDB! Collection ServerData SourceMySQLMasterMySQLMasterMongoDBUserReporting Server
MongoDB! Collection ServerData SourceMySQLMasterMySQLMasterMongoDBUserReporting ServerScalable Writes!
MongoDB! Collection ServerData SourceMySQLMasterMySQLMasterMongoDBUserReporting ServerScalable Writes!Flexible Reporting!
MongoDB! Collection ServerData SourceMySQLMasterMySQLMasterMongoDBUserReporting ServerScalable Writes!“Just” a rails appFlexible Reporting!
MongoDApp ServerData SourceCollectionMongoDLoadBalancerPassengerNginxMongosReportingUserMongoD
MongoDApp ServerData SourceCollectionMongoDLoadBalancerPassengerNginxMongosReportingUserMongoDSharding!
MongoDApp ServerData SourceCollectionMongoDLoadBalancerPassengerNginxMongosReportingUserMongoDSharding!High Concurrency
MongoDApp ServerData SourceCollectionMongoDLoadBalancerPassengerNginxMongosReportingUserMongoDSharding!High ConcurrencyScale-Out
MongoDBSharding
MongoDBShardingReplica Sets let us scale storage & transaction capacity for each shard
MongoDBShardingReplica Sets let us scale storage & transaction capacity for each shardMongos routes transactions to shards based on “shard key”
MongoDBShardingReplica Sets let us scale storage & transaction capacity for each shardMongos routes transactions to shards based on “shard key”Config servers store information about which shards exist
Inserting32Shard key == namebob  Shard 21insert { ‘name’ : bob }Insert { ‘name’ : bob }
Querying32Shard key == namebob  Shard 21Query { ‘name’ : bob }Query { ‘name’ : bob }
Map Reduce22221Map-reduce( … ) Map-reduce(…)
Working with MongoMongoMapper makes it look like ActiveRecordDocuments are more natural than rows in many casesMap-Reduce rocks (but needs better support in rails)http://www.flickr.com/photos/elhamalawy/2526783078/
Scalable Event Analytics with MongoDB & Ruby on Rails
RubyMongo
Runs over all the objects in the views table, counting how many times a page was viewedAdds up all the counts for a unique url / date combinationRun the map reduce job and return a collection containing the results
ResultsVersion 1 of our analytics system took 2 weeks with 1 engineer We have since added a lot more complexity, but we did it incrementallyWe replaced MySQL entirely with MongoDBNo need for joins, transactions Every table is now a document collectionIt’s fast! 63ms – Average response time for sending data to server93ms – Average response time for displaying reports

More Related Content

KEY
MongoFr : MongoDB as a log Collector
PPT
Mongo Web Apps: OSCON 2011
PPTX
Sharding
PPT
MongoDB Basic Concepts
PPTX
MongoDB's New Aggregation framework
PPTX
Attack monitoring using ElasticSearch Logstash and Kibana
PDF
MongoDB World 2016: From the Polls to the Trolls: Seeing What the World Think...
PPT
Large Scale Log collection using LogStash & mongoDB
MongoFr : MongoDB as a log Collector
Mongo Web Apps: OSCON 2011
Sharding
MongoDB Basic Concepts
MongoDB's New Aggregation framework
Attack monitoring using ElasticSearch Logstash and Kibana
MongoDB World 2016: From the Polls to the Trolls: Seeing What the World Think...
Large Scale Log collection using LogStash & mongoDB

What's hot (20)

PDF
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
PPTX
Back to Basics Spanish 4 Introduction to sharding
PDF
Real time fulltext search with sphinx
PDF
Fluentd - Flexible, Stable, Scalable
PPTX
High Performance Applications with MongoDB
PDF
Async and Non-blocking IO w/ JRuby
PDF
Null Bachaav - May 07 Attack Monitoring workshop.
PDF
Distributed Logging Architecture in Container Era
PDF
Using Sphinx for Search in PHP
PDF
mongoDB Performance
PDF
«Scrapy internals» Александр Сибиряков, Scrapinghub
PDF
Back to Basics 2017: Mí primera aplicación MongoDB
PDF
Mobile Analytics mit Elasticsearch und Kibana
PDF
Presto - Hadoop Conference Japan 2014
PPTX
The tale of 100 cve's
PDF
Introduction to MongoDB
PPTX
Back to Basics Spanish Webinar 3 - Introducción a los replica sets
PPTX
Back to Basics Webinar 6: Production Deployment
PPTX
Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...
PPTX
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Back to Basics Spanish 4 Introduction to sharding
Real time fulltext search with sphinx
Fluentd - Flexible, Stable, Scalable
High Performance Applications with MongoDB
Async and Non-blocking IO w/ JRuby
Null Bachaav - May 07 Attack Monitoring workshop.
Distributed Logging Architecture in Container Era
Using Sphinx for Search in PHP
mongoDB Performance
«Scrapy internals» Александр Сибиряков, Scrapinghub
Back to Basics 2017: Mí primera aplicación MongoDB
Mobile Analytics mit Elasticsearch und Kibana
Presto - Hadoop Conference Japan 2014
The tale of 100 cve's
Introduction to MongoDB
Back to Basics Spanish Webinar 3 - Introducción a los replica sets
Back to Basics Webinar 6: Production Deployment
Efficient cluster resource management by using Cook and Mesos / Li Jin (Two S...
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Ad

Viewers also liked (20)

KEY
Mongoose v3 :: The Future is Bright
PDF
Grid FS
KEY
Rainbird: Realtime Analytics at Twitter (Strata 2011)
PDF
The SPDY Protocol
PPTX
Becoming Node.js ninja on Cloud Foundry
PPTX
Testing nodejs apps
PDF
[C5]deview 2012 nodejs
PPTX
소셜게임 서버 개발 관점에서 본 Node.js의 장단점과 대안
PDF
RESTful API Design, Second Edition
PDF
Module, AMD, RequireJS
PDF
Asynchronous Module Definition (AMD)
PPTX
HTML5 Real-Time and Connectivity
PPTX
Veritabani Programlama MySQL I. Egitimi
ODP
Mongokit presentation mongofr-2010
PPTX
A SOA approximation on symfony
PDF
How We Use MongoDB in Our Advertising System
KEY
Telephony with OpenShift Twilio and MongoDB
PPTX
Build Your Own Custom Mobile Analytics with Node and MongoDB
PDF
10gen MongoDB Video Presentation at WebGeek DevCup
PPT
Rapid Application Development using Ruby on Rails
Mongoose v3 :: The Future is Bright
Grid FS
Rainbird: Realtime Analytics at Twitter (Strata 2011)
The SPDY Protocol
Becoming Node.js ninja on Cloud Foundry
Testing nodejs apps
[C5]deview 2012 nodejs
소셜게임 서버 개발 관점에서 본 Node.js의 장단점과 대안
RESTful API Design, Second Edition
Module, AMD, RequireJS
Asynchronous Module Definition (AMD)
HTML5 Real-Time and Connectivity
Veritabani Programlama MySQL I. Egitimi
Mongokit presentation mongofr-2010
A SOA approximation on symfony
How We Use MongoDB in Our Advertising System
Telephony with OpenShift Twilio and MongoDB
Build Your Own Custom Mobile Analytics with Node and MongoDB
10gen MongoDB Video Presentation at WebGeek DevCup
Rapid Application Development using Ruby on Rails
Ad

Similar to Scalable Event Analytics with MongoDB & Ruby on Rails (20)

PPTX
Agility and Scalability with MongoDB
PDF
MongoDB Versatility: Scaling the MapMyFitness Platform
PDF
MongoDB at FrozenRails
KEY
MongoDB at RuPy
PPT
MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
PPT
Document Databases & RavenDB
PDF
Confluent & MongoDB APAC Lunch & Learn
PPTX
Webinar: Getting Started with MongoDB - Back to Basics
PPTX
Social Analytics on MongoDB at MongoNYC
PDF
Chris Lea - What does NoSQL Mean for You
KEY
Software architectures for the cloud
PDF
Introduction to MongoDB
PPTX
NoSQL Introduction, Theory, Implementations
PPTX
Introduction to NoSQL
PDF
MongoDB.pdf
PPTX
Mongodb beijingconf yottaa_3.3
PDF
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
PDF
MongoDB
PDF
Mongodb my
Agility and Scalability with MongoDB
MongoDB Versatility: Scaling the MapMyFitness Platform
MongoDB at FrozenRails
MongoDB at RuPy
MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
Document Databases & RavenDB
Confluent & MongoDB APAC Lunch & Learn
Webinar: Getting Started with MongoDB - Back to Basics
Social Analytics on MongoDB at MongoNYC
Chris Lea - What does NoSQL Mean for You
Software architectures for the cloud
Introduction to MongoDB
NoSQL Introduction, Theory, Implementations
Introduction to NoSQL
MongoDB.pdf
Mongodb beijingconf yottaa_3.3
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
MongoDB
Mongodb my

More from Jared Rosoff (9)

PPTX
MongoDB Advanced Schema Design - Inboxes
PPTX
Mongosv 2011 - Sharding
PPTX
Mongosv 2011 - Replication
PPTX
Mongosv 2011 - MongoDB on Amazon EC2
PPTX
MongoDB Deployment Tips
PPTX
Scaling with mongo db - SF Mongo User Group 7-19-2011
PPTX
MongoDB on EC2 and EBS
PPT
Indexing & query optimization
PPTX
Web performance meetup bos 11 18-2010
MongoDB Advanced Schema Design - Inboxes
Mongosv 2011 - Sharding
Mongosv 2011 - Replication
Mongosv 2011 - MongoDB on Amazon EC2
MongoDB Deployment Tips
Scaling with mongo db - SF Mongo User Group 7-19-2011
MongoDB on EC2 and EBS
Indexing & query optimization
Web performance meetup bos 11 18-2010

Recently uploaded (20)

PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
cuic standard and advanced reporting.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Transforming Manufacturing operations through Intelligent Integrations
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Advanced IT Governance
PDF
Modernizing your data center with Dell and AMD
NewMind AI Monthly Chronicles - July 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Spectral efficient network and resource selection model in 5G networks
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced Soft Computing BINUS July 2025.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
cuic standard and advanced reporting.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Transforming Manufacturing operations through Intelligent Integrations
20250228 LYD VKU AI Blended-Learning.pptx
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
NewMind AI Weekly Chronicles - August'25 Week I
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Advanced IT Governance
Modernizing your data center with Dell and AMD

Scalable Event Analytics with MongoDB & Ruby on Rails