Notes from a production MongoDB deployment
blog.boxedice.com
blog.boxedice.com
- that seems really scary
head -c 2146435072 /dev/zero > local.$i
Can it be lazily allocated by doing something like `open(); seek(2146435072); write("\0");`. Is a sparse file required to return "0" when reading empty places? (or does it just happen very often)There are two reasons to preallocate. One is so that you can get by with fdatasync rather than full fsync (that is, you don't have to sync file metadata as well, which is usually an extra seek; file length is the most commonly changed part of "metadata").
The other is to use mmap, since you can't change the size of an mmap'd file. This is the only part that mongodb cares about, since they never fsync.
There may be reasons to mmap a sparse file but I can't think of any.
It sounds like you understand the forces at work here, but I am confused by your statements. Do you think that "pre-allocating" a sparse file is a valid alternative to writing 2GB of zeros to disk in this case?
Essentially this decision was due to the disk space requirements because of the way MongoDB allocates files for each DB.
There are no performance tradeoffs for using lots of collections. See http://www.mongodb.org/display/DOCS/Using+a+Large+Number+of+...
With the new built-in sharding support, couldn't you have a 'customer_id' field and collapse many of those collections into larger collections, then shard by 'customer_id'? I'm just trying to understand tradeoff between these two types of schemas.