Amazon EC2 is a great platform to deploy and manage MongoDB. The EC2 platform is a highly functional cloud platform and provides a huge array of knobs (which can sometimes be a problem) to optimize your deployments. In this post I will share some of our learnings from managing MongoDB servers from various deployments on AWS.
1. Disk performance
Over the years this has consistently been an issue with Amazon EC2 – however the release of Provisioned IOPS has almost eliminated this issue! If you have a production cluster for which you need consistent disk performance use Provisioned IOPS. If you want to take it one step further and would like performance isolation between your application traffic and the disk traffic use EBS optimized instances. Stay away from RAID unless you know what you are doing and have the operations staff to support you in case something goes wrong.
2. DNS name and IP address
By default the DNS name and public IP address allocated to your instance is not static. This means when you reboot your instance (you will eventually) you might get a different IP and DNS name. This will break connection between your app and the db. There are a couple of ways around this – use a static elastic IP (costs extra) or configure Route 53 DNS and setup your own DNS mappings.
3. Availability zones
Distribute your replica sets across the availability zones in a region. This will increase the availability of your replica set especially when AWS is doing routine maintenance. In extreme cases you might want to deploy your replica sets across regions.
4. Security groups
Security groups are the ‘firewall’ for your AWS platform. They are a powerful tool and should be leveraged. Make sure you lock down access to your MongoDB servers and don’t expose them to the internet. Ideally only your front end or mid tier servers have access to the database. Security groups can be used in a region even across AWS accounts
5. Reserved instances
If your MongoDB server is up and running 365 days a year you can achieve almost a 50% reduction in costs by purchasing reserved instances. It will require you to pay a certain amount upfront but will save you money in the long run. Reserved instances are a billing construct and can be applied to any of your running instances.
6. 10gen best practices
10gen does a great job of putting together best practices for each cloud platform. Read through the 10gen best practices on Amazon – http://docs.mongodb.org/ecosystem/platforms/amazon-ec2/. You can also read the Amazon white paper - http://aws.amazon.com/whitepapers/mongodb-on-aws/
There are also several other non functional aspects to consider while deploying MongoDB on Amazon. You can read our other post for more details - https://scalegrid.io/blog/10-questions-to-ask-and-answer-when-hosting-mongodb-on-aws/
At MongoDirector.com we provide a single click deployment of Mongo replica sets across availability zones or regions. We have automated backup and recovery. We only use provisioned IOPS and provide easy ways for our customers to benchmark Mongo and also simulate failover in mongo clusters. If you have other questions/comments or feature requests we would love to hear from you. You can email us at support@MongoDirector.com