Hi Eliot,
The hardware I applied for is not ready yet. But I don't want to wait
for it. So I make another comparation test among write to file system,
write to single mongodb and write to a cluster with autosharding
mongodb.
On the same vm, write 1000 files(each has 512KB in size) to file
system takes about 80 seconds averagely, and write 1000 chunks(each
has 512KB in size) to single mongodb takes about 80 seconds averagely
too.
But write 1000 chunks(each has 512KB in size) to a cluster with
autosharding mongodb takes more than 1000 seconds averagely.
So I draw a conclusion that performance of write to single mongodb is
almost as same as that of write to file system, but performance of
write to autosharding mongodb cluster declines sharply.
With further investigation, I find, in the intensively inserting
period, autosharding mongodb also splits and migrates its chunks
constantly. Just inserting is intensive enough to cause the IO
bottleneck, let alone chunks' splitting and migrating.
So is there any way to tune the autosharding policy more subtly so
that chunks' splitting and migrating will only run when the load is
not high? I just insert 50 files(each has 20 chunks), the chunks are
splitted 13 times. As far as my requirement, chunks' splitting and
migrating takes place excessively frequently.
According to
http://www.mongodb.org/display/DOCS/Sharding+Design"split - split a chunk that is growing too large into pieces. as the
two new chunks are on the same machine after the split, this is really
just a metadata update and very fast."
But on the surface of my observation, that's not true. I add only one
shard. So there's no migrating, but still splitting. However, the
performance is still so poor (about 800 seconds).
In fact, I don't really understand the relationships between the
chunks and the data files on the disk. Under the dbpath, there're 6
files for the db. However there're 28 chunks in chunks collection of
config db, and the number of chunks is continually growing with
objects being inserted. But I have never seen it declining even if
many objects are deleted. Dividing shard into chunks may make things
complicated. Why not look the shard as one chunk and set a migrating
threshold for its capacity? For example, we believe the max space is
20GB for a shard, when its capacity reaches 16GB, find a spare time to
migrate data until its capacity is 10GB. I know the load may not be
proportional to the amount of the data, but it's really difficult to
find a way to meet all kinds of requirement without sacrificing other
aspacts.
All in all, IO performance is very important to my application. If
autosharding introduces performance degrading, I plan to use single
replica set and do sharding on application level. On the other hand, I
still want to utilize mongos to simplify the interface to mongodb.
However, it seems both or neither for autosharding and mongos. Is it
right? If no, how to achieve it? If yes, must I take care of the
replica set in client itself?