Table of contents : Cover Title Page Copyright and Credits Dedication Contributors Table of Contents Preface Part 1 – Basic MongoDB – Design Goals and Architecture Chapter 1: MongoDB – A Database for the Modern Web Technical requirements The evolution of SQL and NoSQL The evolution of MongoDB MongoDB for SQL developers MongoDB for NoSQL developers MongoDB’s key characteristics and use cases Key characteristics Use cases for MongoDB MongoDB criticism MongoDB configuration and best practices Operational best practices Schema design best practices Best practices for write durability Best practices for replication Best practices for sharding Best practices for security Best practices for AWS Reference documentation and further reading Summary Chapter 2: Schema Design and Data Modeling Technical requirements Relational schema design MongoDB schema design Data modeling Data types Modeling data for atomic operations Read isolation and consistency Modeling relationships One-to-one One-to-many and many-to-many Modeling data for keyword searches Modeling data for Internet of Things Connecting to MongoDB Connecting using Ruby Connecting using Python Connecting using PHP Summary Part 2 – Querying Effectively Chapter 3: MongoDB CRUD Operations Technical requirements CRUD using the shell Scripting for the mongo shell Administration MapReduce in the mongo shell Aggregation framework Securing the shell Authentication with MongoDB The new mongosh shell MongoDB Stable API Summary Chapter 4: Auditing Technical requirements Auditing and logging differences Audit setup in MongoDB Enterprise Edition Audit events and format Audit filters Audit guarantee Audit setup in MongoDB Atlas JSON audit filter Audit logging access Audit case study MongoDB CLI Mongo shell and audit logs Summary Chapter 5: Advanced Querying Technical requirements MongoDB CRUD operations CRUD using the Ruby driver CRUD in Mongoid CRUD using the Python driver CRUD using PyMODM CRUD using the PHP driver CRUD using Doctrine Update operators Smart querying Change streams Introduction Queryable encryption Summary Chapter 6: Multi-Document ACID Transactions Technical requirements Transactions background Exploring ACID properties Atomicity Consistency Isolation Durability When do we need ACID in MongoDB? Building a digital bank using MongoDB E-commerce using MongoDB The best practices and limitations of multi-document ACID transactions Summary Chapter 7: Aggregation Technical requirements Why aggregation? Aggregation options Single-purpose aggregation methods Aggregation operators Aggregation pipeline stages Aggregation pipeline expression operators Literal expression operator Miscellaneous operators Object expression operators Expression string operators Text expression operators Timestamp expression operators Trigonometry expression operators Type expression operators Time series collections MongoDB views Limitations Optimizing aggregation pipelines Aggregation use case Summary Chapter 8: Indexing Index internals Index types Building and managing indexes Using indexes efficiently Further reading Summary Part 3 – Administration and Data Management Chapter 9: Monitoring, Backup, and Security Technical requirements Monitoring clusters What should we monitor? Monitoring memory usage in WiredTiger Tracking page faults Working set calculations Monitoring tools Cluster backups Backup options EC2 backup and restore Incremental backups Securing our clusters Authentication Role-based access control-based authorization Network-level security Auditing security Special cases Overview Summary Chapter 10: Managing Storage Engines Pluggable storage engines WiredTiger Encrypted at rest Client-side field-level encryption In-memory Other storage engines Locking in MongoDB Lock reporting Lock yield Commonly used commands and locks Commands requiring a database lock Further reading Summary Chapter 11: MongoDB Tooling Technical requirements Introduction to MongoDB tools MongoDB Atlas Setting up a cluster MongoDB Atlas Search MongoDB Kubernetes Operator An introduction to Kubernetes Enterprise Kubernetes Operator MongoDB Atlas Serverless MongoDB Realm Realm Sync Realm Sync data model Realm Sync mode Realm Application Services MongoDB Charts MongoDB Compass MongoDB Connector for Business Intelligence MongoDB Cloud Manager MongoDB Ops Manager Summary Chapter 12: Harnessing Big Data with MongoDB Technical requirements What is big data? The big data landscape Message queuing systems Data warehousing MongoDB as a data warehouse Big data use case with servers on-premises Setting up Kafka Setting up Hadoop Using a Hadoop-to-MongoDB pipeline Setting up a Spark connection to MongoDB MongoDB Atlas Data Lake Summary Further reading Part 4 – Scaling and High Availability Chapter 13: Mastering Replication Technical requirements Replication Logical or physical replication Different high availability types An architectural overview How do elections work? What is the use case for a replica set? Setting up a replica set Converting a standalone server into a replica set Creating a replica set Read preference Write concern Priority settings for replica set members Production considerations Connecting to a replica set Replica set administration How to perform maintenance on replica sets Initial sync Resyncing a member of a replica set Changing the oplog’s size Reconfiguring a replica set when we have lost the majority of our servers Chained replication Streaming replication Flow control Cloud options for a replica set Amazon DocumentDB Microsoft Azure Cosmos DB MongoDB Atlas Replica set limitations Summary Chapter 14: Mastering Sharding Technical requirements Why do we need sharding? Architectural overview Development, continuous deployment, and staging environments Planning ahead with sharding Setting up sharding Choosing the shard key Choosing the correct shard key Sharding administration and monitoring Balancing data – how to track and keep our data balanced Chunk administration Sharding limitations Querying sharded data The query router Hedged reads Querying using Ruby Performance comparison with replica sets Sharding recovery mongos mongod Config server A shard goes down The entire cluster goes down Further reading Summary Chapter 15: Fault Tolerance and High Availability Application design Schema-less doesn’t mean schema design-less Design patterns Design anti-patterns Read performance optimization Defensive coding Elevating operations Boosting security Enabling security by default Isolating our servers Checklists Summary Further reading Index About Packt Other Books You May Enjoy