Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
mongoDB at Intercom
Search
ciaranlee
May 23, 2012
Technology
3
380
mongoDB at Intercom
These slides are from a talk I gave at the first meeting of the Dublin mongoDB users group.
ciaranlee
May 23, 2012
Tweet
Share
More Decks by ciaranlee
See All by ciaranlee
Query Fingerprinting
ciaranlee
0
36
Other Decks in Technology
See All in Technology
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
140
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.6k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
650
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
500
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.4k
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
760
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
Taming you application's environments
salaboy
0
190
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Six Lessons from altMBA
skipperchong
27
3.5k
RailsConf 2023
tenderlove
29
900
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Making Projects Easy
brettharned
115
5.9k
Become a Pro
speakerdeck
PRO
25
5k
Designing Experiences People Love
moore
138
23k
4 Signs Your Business is Dying
shpigford
180
21k
A Tale of Four Properties
chriscoyier
156
23k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Transcript
Wednesday 23 May 12
Ciaran Lee @ciaran_lee CTO of @intercom Wednesday 23 May 12
MongoDB at Intercom Wednesday 23 May 12
• What we do • Why we started using mongoDB
• Learnings • Problems • Hosting Overview Wednesday 23 May 12
CRM & Messaging Tool for Web Apps Wednesday 23 May
12
<script> var intercomSettings = { app_id:"tx2p130c", email:"
[email protected]
" }; </script> <script
src="https://api.intercom.io/api/ js/library.js"</script> Wednesday 23 May 12
Wednesday 23 May 12
Wednesday 23 May 12
• Rails • MySQL • MongoDB • Redis • Memcached
• Solr Technology Stack Wednesday 23 May 12
• Open beta • Installed on thousands of apps •
Tracking millions of end users Current status Wednesday 23 May 12
MySQL • Initially used for all data • We had
a built high traffic apps with it before (@exceptional) Wednesday 23 May 12
Wednesday 23 May 12
var intercomSettings = { app_id:"tx2p130c", email:"
[email protected]
", custom_data: { plan: "Small",
teammates: 4, revenue: 312, } }; Wednesday 23 May 12
http://en.wikipedia.org/wiki/Entity-attribute-value_model Entity–attribute–value pattern Wednesday 23 May 12
Wednesday 23 May 12
class User < ActiveRecord::Base serialize :custom_data end user.custom_data = {
:plan => "Small", :team_mates => 4, :revenue => 312, } Wednesday 23 May 12
• Reading and writing worked fine • Sorting or filtering
was a disaster Results Wednesday 23 May 12
Why MongoDB? • Handles arbitrary document structure • Flexible querying
• Can use an ActiveRecord compatible ORM (mongomapper) • Available as a heroku addon Wednesday 23 May 12
Users -> mongoDB Wednesday 23 May 12
Wednesday 23 May 12
The Mongo way • Different way of thinking to relational
DB • Often denormalised • Desired read scenarios influence design Wednesday 23 May 12
Tagging Wednesday 23 May 12
Tagging • Relational way is users + tags + join
table • Mongo way is a tag_ids array in the user record Wednesday 23 May 12
db.users.update( { app_id: 6, 'custom_data.apps': { $gte: 5 } },
{ $addToSet: { tag_ids:1234 } } ); Wednesday 23 May 12
db.users.update( { app_id: 6, 'custom_data.apps': { $gte: 5 } },
{ $addToSet: { tag_ids:1234 } } ); Wednesday 23 May 12
db.users.update( { app_id: 6, 'custom_data.apps': { $gte: 5 } },
{ $addToSet: { tag_ids:1234 } } ); Wednesday 23 May 12
Challenges Wednesday 23 May 12
Activity Stream Wednesday 23 May 12
Wednesday 23 May 12
Problem #1 • Querying users has gotten slower • Users
collection is 1/4 the size of activities • Activity stream growing too fast • Knocks the users collection out of RAM Wednesday 23 May 12
Solution • Move the activity stream over to a separate
database • We can use the more powerful database for complex user queries • sorting + filtering should be quicker Wednesday 23 May 12
Problem #2 • Can’t index every custom data attribute •
Intend to experiment with app specific user collections (+ index all custom data attrs on that app’s collection) Wednesday 23 May 12
Slowness • Always seems to involve disk access • Slow
performance of simple queries after big addToSet operations (> 200k users) Wednesday 23 May 12
Hosting • MongoHQ • Replica set - heroku addon •
ec2 cluster • Dedicated hardware with SSDs • Amazing service Wednesday 23 May 12
Thanks for listening! Wednesday 23 May 12
Wednesday 23 May 12