This guide covers essential MongoDB Atlas concepts commonly asked in technical interviews. Each question includes detailed answers and practical examples.
MongoDB Atlas is a fully-managed cloud database service that provides:
Cluster deployment and management in Atlas:
// Atlas API - Create Cluster
{
"name": "myCluster",
"providerSettings": {
"providerName": "AWS",
"regionName": "US_EAST_1",
"instanceSizeName": "M10",
"diskIOPS": 100,
"encryptEBSVolume": true
},
"clusterType": "REPLICASET",
"replicationFactor": 3,
"backupEnabled": true,
"autoScaling": {
"diskGBEnabled": true,
"computeEnabled": true
}
}
// Atlas API - Update Cluster
{
"providerSettings": {
"instanceSizeName": "M20"
},
"autoScaling": {
"diskGBEnabled": true,
"computeEnabled": true,
"compute": {
"minInstanceSize": "M10",
"maxInstanceSize": "M40"
}
}
}
// Atlas API - Configure Backup
{
"snapshotSchedule": {
"type": "DAILY",
"hour": 2,
"minute": 0,
"retentionDays": 7
},
"clusterCheckpointIntervalMin": 15,
"clusterId": "myClusterId"
}
// Atlas API - Configure Alerts
{
"eventTypeName": "OUTSIDE_METRIC_THRESHOLD",
"metricName": "CONNECTIONS",
"threshold": {
"operator": "GREATER_THAN",
"units": "RAW",
"value": 1000
},
"notifications": [
{
"typeName": "EMAIL",
"intervalMin": 5,
"delayMin": 0,
"emailAddress": "admin@example.com"
}
]
}
Security implementation in Atlas:
// Atlas API - IP Whitelist
{
"ipAddress": "192.168.1.1",
"comment": "Office IP"
}
// Atlas API - VPC Peering
{
"vpcId": "vpc-123456",
"awsAccountId": "123456789012",
"routeTableCIDRBlock": "10.0.0.0/16",
"region": "us-east-1"
}
// Atlas API - Private Endpoint
{
"endpointId": "vpce-123456",
"type": "DATA_LAKE",
"provider": "AWS",
"region": "us-east-1"
}
// Atlas API - Create Database User
{
"username": "appUser",
"password": "securePassword123",
"roles": [
{
"roleName": "readWrite",
"databaseName": "myApp"
}
],
"scopes": [
{
"name": "myCluster",
"type": "CLUSTER"
}
]
}
// Atlas API - Configure Encryption
{
"encryptionAtRest": {
"enabled": true,
"provider": "AWS"
},
"encryptionInTransit": {
"enabled": true
}
}
Performance optimization in Atlas:
// Atlas API - Configure Auto-Scaling
{
"autoScaling": {
"diskGBEnabled": true,
"computeEnabled": true,
"compute": {
"minInstanceSize": "M10",
"maxInstanceSize": "M40",
"scaleDownEnabled": true
}
}
}
// Atlas API - Configure Indexes
{
"collection": "users",
"database": "myApp",
"indexes": [
{
"key": {
"email": 1
},
"name": "email_idx",
"unique": true
},
{
"key": {
"status": 1,
"createdAt": -1
},
"name": "status_created_idx"
}
]
}
// Atlas API - Performance Advisor
{
"suggestions": {
"indexes": [
{
"namespace": "myApp.users",
"index": {
"key": {
"status": 1,
"createdAt": -1
},
"name": "status_created_idx"
},
"impact": "HIGH",
"reason": "Frequent queries on status and createdAt"
}
],
"sharding": [
{
"namespace": "myApp.orders",
"suggestedKey": "customerId",
"impact": "MEDIUM",
"reason": "Uneven data distribution"
}
]
}
}
Follow these Atlas best practices:
// Atlas API - Multi-Region Deployment
{
"name": "globalCluster",
"clusterType": "GLOBAL",
"config": {
"regions": [
{
"regionName": "US_EAST_1",
"priority": 1
},
{
"regionName": "EU_WEST_1",
"priority": 2
},
{
"regionName": "AP_SOUTHEAST_1",
"priority": 3
}
]
}
}
// Atlas API - Backup Configuration
{
"snapshotSchedule": {
"type": "HOURLY",
"hour": 0,
"minute": 0,
"retentionDays": 7
},
"clusterCheckpointIntervalMin": 15,
"clusterId": "myClusterId"
}
// Atlas API - Security Settings
{
"encryptionAtRest": {
"enabled": true,
"provider": "AWS"
},
"encryptionInTransit": {
"enabled": true
},
"auditLogging": {
"enabled": true,
"auditFilter": "{ 'atype': 'authCheck', 'param.command': { '$in': ['find', 'insert', 'update', 'remove'] } }"
}
}
// Atlas API - Monitoring Setup
{
"alerts": [
{
"eventTypeName": "OUTSIDE_METRIC_THRESHOLD",
"metricName": "CONNECTIONS",
"threshold": {
"operator": "GREATER_THAN",
"units": "RAW",
"value": 1000
},
"notifications": [
{
"typeName": "EMAIL",
"intervalMin": 5,
"delayMin": 0,
"emailAddress": "admin@example.com"
}
]
}
]
}
Continue your MongoDB interview preparation with: