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
40
Other Decks in Technology
See All in Technology
UIテスト自動化サポート- Testbed for XCUIAutomation practice
notoroid
0
120
25分で解説する「最小権限の原則」を実現するための AWS「ポリシー」大全 / 20250625-aws-summit-aws-policy
opelab
8
910
ローカルLLMでファインチューニング
knishioka
0
140
AWS テクニカルサポートとエンドカスタマーの中間地点から見えるより良いサポートの活用方法
kazzpapa3
1
240
第9回情シス転職ミートアップ_テックタッチ株式会社
forester3003
0
170
20250625 Snowflake Summit 2025活用事例 レポート / Nowcast Snowflake Summit 2025 Case Study Report
kkuv
1
260
菸酒生在 LINE Taiwan 的後端雙刀流
line_developers_tw
PRO
0
1.1k
米国国防総省のDevSecOpsライフサイクルをAWSのセキュリティサービスとOSSで実現
syoshie
2
850
A2Aのクライアントを自作する
rynsuke
1
160
ユーザーのプロフィールデータを活用した推薦精度向上の取り組み
yudai00
0
500
低レイヤを知りたいPHPerのためのCコンパイラ作成入門 完全版 / Building a C Compiler for PHPers Who Want to Dive into Low-Level Programming - Expanded
tomzoh
4
2.3k
“社内”だけで完結していた私が、AWS Community Builder になるまで
nagisa53
1
260
Featured
See All Featured
Designing for humans not robots
tammielis
253
25k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
Embracing the Ebb and Flow
colly
86
4.7k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Done Done
chrislema
184
16k
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Visualization
eitanlees
146
16k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
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