MongoDB Assignment- 5

Basic Questions

  1. Enable sharding on shopDB, insert 5M docs into orders, and run sh.status() to observe sharding in action.
  2. Set up replication and sharding in a test environment, then run rs.status() vs sh.status() to observe their behavior differences.
  3. Create a collection users and enable a shard key on the userId field.
  4. Scale MongoDB in Docker twice: once by adding CPU/memory (vertical) and once by adding shards (horizontal), then compare performance using inserts
  5. Enable sharding on a database named ecommerce.
  6. Create a text index on the description field of the products collection.
  7. Perform a full-text search query for “laptop” in the products collection.
  8. Insert a document into locations with name, latitude, and longitude.
  9. Create a 2dsphere geospatial index on the locations collection.
  10. Write a query to find all places within 5km of a given point.
  11. Insert 3 sample documents into a time-series collection named sensorData.
  12. Create a time-series collection in MongoDB with timeField: “timestamp”.
  13. Show how to query documents in sensorData for the last 1 hour.
  14. In MongoDB Atlas, create a cluster named TrainingCluster.
  15. Demonstrate how to configure IP whitelisting in Atlas.
  16. Enable encryption at rest in MongoDB Atlas.
  17. Create an alert in Atlas when CPU usage exceeds 80%.
  18. Enable TLS/SSL connections for MongoDB and connect with –tls parameter to verify secure communication.
  19. View cluster metrics and performance graphs in Atlas dashboard.
  20. Trigger a manual backup in Atlas from UI/API, then configure automated backup policy and observe differences in restore options.

Intermediate Questions

  1. Configure a 3-shard cluster with one config server and one mongos router.
  2. Create a students collection, shard it on two different keys (rollNo vs class), and measure query performance for each.
  3. Demonstrate how to reshard a collection in MongoDB.
  4. Insert 10K docs into orders, enable sharding, then run db.orders.getShardDistribution() to view how data is distributed.
  5. Create two sharded collections: one with range‑based shard key and one with hashed shard key, then compare query times for lookups.
  6. Write a full-text search query to find documents with “apple” but exclude “juice”.
  7. Use the $text operator with a relevance score to sort search results.
  8. Create a multilingual full-text search index supporting English and Hindi.
  9. Write a query using $geoWithin to find restaurants in a defined polygon (city boundary).
  10. Use $near query to list the nearest 5 hospitals from a given location.
  11. Create a compound index combining timestamp and sensorId in time-series data.
  12. Run a query to calculate the average temperature from time-series sensorData.
  13. In Atlas, upgrade a cluster tier from M10 to M20 and log query performance before vs after scaling.
  14. Configure VPC Peering in Atlas with a cloud app, then ping the DB from your app to test connectivity.
  15. Write a script to automatically back up salesDB every 24 hours using Atlas automated backups.
  16. Stop the primary node in Atlas, then run rs.status() to capture the failover event and time taken for new primary election.
  17. Create a role-based access control in Atlas allowing only read access for analytics users.
  18. Configure Atlas network rules to restrict connections only to India IP range and attempt a connection from outside India to verify denial.
  19. Monitor query performance using Atlas Performance Advisor.
  20. Create a custom alert in Atlas for slow query execution.

Advanced Questions

  1. Create a sharded orders collection in a cluster handling simulated 1M orders/day, test possible shard keys (orderId vs customerId) and measure query balance.
  2. Move a chunk manually using moveChunk between two shards and check performance logs before and after.
  3. Generate heavy writes into a sharded collection and run sh.status() to observe how the balancer redistributes chunks automatically.
  4. Implement text search + geospatial query together (e.g., “Find cafés mentioning ‘coffee’ within 2 km”).
  5. Build two multilingual text indexes (English & Hindi) and run searches to demonstrate language‑specific stemming differences.
  6. Ingest live IoT sensor data into a time‑series collection, then create an aggregation query to detect anomalies (e.g., temperature > 100°C).
  7. Partition time‑series data into hot (recent) and cold (archived) collections and query both to illustrate tiered storage.
  8. Deploy Atlas Global Clusters in Asia + US, then run queries with readPreference: nearest from both regions to measure latency.
  9. Enable both “Encryption at Rest” and “TLS in Transit” in Atlas, then test connectivity with a secure client certificate.
  10. Configure an Atlas alert + auto‑scaling rule that upgrades cluster tier when memory hits 75% and verify it with workload simulation.