MongoDB and Amazon Web Services are a great match for those deploying and scaling applications in the cloud. This session will highlight the best practices for those running MongoDB on EC2, starting with basic installation using the AMI, to configuration of replica sets, to scaling a sharded system across multiple availability zones in order to ensure fault tolerance. We’ll walk through the specific steps necessary to set up, monitor and backup MongoDB so that you walk away from the presentation ready to deploy in production.
4. MongoDB Basics
• Open source
• Document database
• High performance
• Horizontally scalable
• Full featured
• Built to match agile development and
deployment
5. MongoDB Features
• Flexible document data model
• Rich ad-hoc queries and in-place updates
• Real-time aggregation
• Geospatial support
• Text search
• Built-in support for
– Redundancy, failover, auto-partitioning
6. Accessing MongoDB
Drivers
Drivers for most popular
programming languages and
frameworks
Java
Ruby
JavaScript
Python
Shell
Command-line shell for interacting
directly with database
Perl
Haskell
> db.collection.insert({product:“MongoDB”,
type:“Document Database”})
>
> db.collection.findOne()
{
“_id”
: ObjectId(“5106c1c2fc629bfe52792e86”),
“product”
: “MongoDB”
“type”
: “Document Database”
}
17. Instance Details
• Differences in
– CPU, Memory, Storage, Networking
• Networking
– EBS-optimized, Enhanced, Cluster
• Availability
– Not all are available in all regions
18. Zones, Regions, Security
• Regions
– Data center
• Availability Zones
– Rack in a data center
• Security
– Security Groups, VPC
us-east1
uswest-1
uswest-2
1b
1a
2a
1c
1d
2b
1c
2c
19. Components and Sizing
mongod
config
Core database
process
Sharding
metadata
High
performance
Smaller
Memory,
Storage,
Network
m1.small or
m1.medium
mongos
Sharding query
router
Deploy on app
server
26. High Availability
• Use Replica Sets
– Deploy in odd numbers
– Maintain majority
MongoDB
Primary
• Withstand the loss of
– Any single zone?
– Any single region?
– Deploy in 3 places
MongoDB
Secondar
y
• Scale
– Replica Sets for HA
– Sharding for scale
– Combine for both
MongoDB
Secondar
y
1
2
3
27. Deployment Considerations
• How much availability do you need?
• Can you withstand loss of zone, region?
• Where is your app and where are your users?
• What are the security requirements?
– Note: security groups don’t span regions
– SSL or VPC
30. Instance Configuration Best
Practices
• Launch as EBS-optimized
• Use separate PIOPS volumes for data, log, journal
• Use EXT4
• Set read ahead
• Update ulimits
• Update TCP KeepAlive
31. Sensible Instance Defaults
• Best practices are meant to be a sensible starting
point
• Amazon Linux optimized for EC2
• EBS provides persistent storage
• EBS-optimized allocates additional NIC for storage
• Provisioned IOPS provides consistent EBS
performance
32. Sensible Instance Defaults
• Individual volumes to reduce IO contention
• Default read ahead is too high
• Default ulimits are too low
• Default keepalive too low
34. AWS Marketplace
• The AWS Marketplace is an online store that helps
users find, buy, and deploy software.
• Launch pre-configured software and let AWS handle
billing and payments
39. MongoDB Management Service
• MongoDB Management Service (MMS) is a suite of services for managing
MongoDB deployments.
• Engineered by the team who develops MongoDB, MMS makes it easier to
operate MongoDB at any scale.
• MMS provides monitoring, backup and recovery, helping users optimize
clusters and mitigate operational risk.
• MMS users can visualize database performance and set custom alerts that
notify when particular metrics are out of normal range.
• MMS is also the only continuous backup solution for MongoDB, providing
point-in-time recovery for replica sets and cluster-wide snapshots of sharded
systems.
43. MMS Monitoring
• Agent-based deployment monitoring
• Opcounters, memory usage, index usage, lock %,
connections, background flush, queues, page faults,
and more
• Notifications and alerts on any metric and condition
• Agent pre-installed on AWS Marketplace instances
44. Coming Up Next
• Part 2 in late March
– Storage Configurations
– Storage Tradeoffs
– Disaster Recovery
• Part 3 in late April
– Integrating with AWS Services
– CloudFormation
– Elastic MapReduce
46. Resources
• MongoDB on AWS best practices:
– http://docs.mongodb.org/ecosystem/platforms/amazonec2/#deploy-mongodb-on-ec2
• MongoDB on AWS Marketplace:
– https://aws.amazon.com/marketplace/sellerprofile/ref=dtl_pcp_sold_by?ie=UTF8&id=c9032c7b-70dd459f-834f-c1e23cf3d092
• MongoDB docs
– http://docs.mongodb.org
47. #MongoDBWorld
MongoDB World
New York City, June 23-25
See what’s next in MongoDB including
• MongoDB 2.6
• Sharding
• Replication
• Aggregation
http://world.mongodb.com
Save 25% with discount code 25SandeepParikh