What's the most optimized way to run MongoDB in AWS? I'm getting some slow disk i/o bench marks (which I understand is the norm on EC2). Is a large ec2 instance my best bet? is there anyway to get better disk reads?
MongoDB performs best if the entire database can fit in memory - so a high memory instance may be a consideration, especially if your application is read-heavy (good indexes will also help).
MongoDB uses memory mapped files - so it is fairly efficient about what it stores in memory and what it writes to disk. Indexes are prioritized, and should always be in memory (the performance implications are significant if the indexes do not fit in memory).
As a general guideline, you should try to minimize indexes on write-heavy applications (since each write requires an additional write for the index). Read-heavy applications should use indexes on whatever fields are commonly accessed.
Secondly, various instance classes have different 'I/O Performance' - the large instance class has 'high' I/O performance.
Finally, You can improve the read/write performance of your EBS volumes by setting them up as a RAID. This is fairly easy to accomplish using
You can check disk access using
For a small read-heavy database residing on the same machine as the application querying it, all instance sizes (except, perhaps t1.micro) that will fit it in memory should be essentially equivalent (since the required I/O is minimal). For write-heavy applications, I/O becomes a much more significant consideration.