The document discusses some common gotchas and best practices for using MongoDB, including:
- Using MongoDB to store all persistent data and room state for the music site Turntable.
- Ensuring MongoDB has enough RAM to perform quickly.
- Being aware of connection limits and vague error messages around connections.
- Using libraries like async mongo when using MongoDB with Tornado to avoid thread issues.
- Analyzing queries with explain() and monitoring the slow query log to optimize indexes.
- Only requesting needed fields from MongoDB to optimize returned data size.
1 of 8
Download to read offline
More Related Content
Mongo gotchas
1. Mongo
Gotchas
by
Billy
Chasen
Founder,
CEO
turntable.fm
@billychasen
3. How
we
use
mongo
≒ All
turntable
room
state
in
mongo
≒ All
persistent
data
≒ Logging
(use
safe
=
False)
≒ Incredibly
fast,
make
sure
you
give
it
enough
RAM
4. ConnecPons
≒ The
magic
number
819
Depends
on
open
鍖le
limits
Throws
a
vague
cannot
connect
to
primary/slave
error
5. Threads
≒ CauPon
when
using
pymongo
with
Tornado
≒ Use
libraries
like
async
mongo
for
Tornado
6. Indexes
≒ Important!
Analyze
every
query
you
use
with
explain()
and
monitor
slow
query
log
7. OpPmize
returned
data
≒ If
you
have
large
objects,
request
only
needed
鍖elds
≒ Its
like
using
SELECT
uid,name
FROM
user