How about using MongoDB to build a mail server?

1,010 views
Skip to first unread message

rick_du

unread,
Mar 23, 2012, 5:25:22 AM3/23/12
to mongodb-user
Hi all,

I wanna know if we use MongoDB to save emails and attachments, about 1
TB per month, will it be ok?

I'm afraid of the performance using mongodb to store huge amount of
attachments.

Or I can choose mongodb to store mail contents, then any suggestions
for attachment storage?

Sam Millman

unread,
Mar 23, 2012, 5:52:11 AM3/23/12
to mongod...@googlegroups.com
You could use gridfs for mail attachment storage and a normal collection for mail storage.

I can see that working in my opinion.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


gregor

unread,
Mar 23, 2012, 5:56:11 AM3/23/12
to mongod...@googlegroups.com
This will be fine and mongodb is a good fit for this - storing emails as documents maps well plus you can scale mongodb as your collection grows in size. 
Be aware that there is a limit of 16MB for document size so if your attachments are larger than this then you may want to look at GridFS.

rick_du

unread,
Mar 23, 2012, 10:38:24 AM3/23/12
to mongodb-user
Thank you Sam, thank you gregor.

I've seen the Java implementation of GridFS. It uses a simple way to
divide a large file among multiple documents, store the metadata in
*.files, and the file data in *.chunks. But the performance seems not
good.

I tested it in this way:
10 threads, 1000 insert per thread, size of each document is 100k, so
it's totally 1GB

First, I used GridFS to create and save. It cost 141s.
Then, I removed GridFS and just inserted the document directly. In
this way it cost 101s.

It seems that GridFS will cost a lot more time, right?

Sam Millman

unread,
Mar 23, 2012, 10:57:44 AM3/23/12
to mongod...@googlegroups.com
Indeed, Gridfs is better for larger files at times. But gmail and hotmail etc allow 25meg attachments, so attachments can be larger than 16meg, you might be able to do some kind of hybrid system between the two.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.

Scott Hernandez

unread,
Mar 23, 2012, 11:01:21 AM3/23/12
to mongod...@googlegroups.com
You can also change the chunksize for how many documents the files are
broken up into. This may change your performance characteristics.

gregor

unread,
Mar 30, 2012, 11:22:20 AM3/30/12
to mongod...@googlegroups.com
Are you good to go or do you need more help?

> To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages