mongdb interview questions

 MongoDB is the best free and open source document-oriented NoSQL database out there. If you're preparing for a technical interview for a MongoDB NoSQL database, you'd better take a look at the MongoDB NoSQL interview questions and answers below. These MongoDB NoSQL interview questions and answers cover the basic concepts of NoSQL databases, replication (Replication), sharding (Sharding), transactions and locks, trace analysis tools (Profiler), Nuances and logging features. Let’s take a look at these interview questions for MongoDB NoSQL databases below:

1. What do you mean by NoSQL database? What is the difference between NoSQL and RDBMS directly? Why use and not use a NoSQL database? What are the advantages of NoSQL databases?

  I wrote a full blog to answer these questions, see here

  2. What are the types of NoSQL databases?

  Types of NoSQL Databases

  For example: MongoDB, Cassandra, CouchDB, Hypertable, Redis, Riak, Neo4j, HBASE, Couchbase, MemcacheDB, RevenDB and Voldemort are the examples of NoSQL databases.  Read on for details .

  3. What are the most basic differences between MySQL and MongoDB?

  Both MySQL and MongoDB are free and open source databases. MySQL and MongoDB have many fundamental differences including data representation, queries, relationships, transactions, schema design and definition, normalization, speed, and performance. By comparing MySQL and MongoDB, we are actually comparing relational and non-relational databases. read carefully

  4. How do you compare MongoDB, CouchDB and CouchBase?

  Both MongoDB and CouchDB are document-oriented databases. Both MongoDB and CouchDB are the most typical representatives of open source NoSQL databases. They have nothing in common except that they are both stored as documents. MongoDB and CouchDB have many differences in data model implementation, interfaces, object storage, and replication methods.

  Details can be found at the link below:

  MongDB vs CouchDB

  CouchDB vs CouchBase

  5. What makes MongoDB the best NoSQL database?

  The following features make MongoDB the best NoSQL database:

  • file-oriented

  • high performance

  • high availability

  • Ease of Extensibility

  • Rich query language

  6. What are the nuances on 32-bit systems?

  Journaling activates additional memory-mapped files. This will further suppress database size on 32-bit builds. So journaling is now disabled by default on 32-bit systems.

  7. Will journal playback encounter problems when the entry is incomplete (eg happens to have a mid-failure)?

  Each journal (group) write operation is consistent, it is not replayed during recovery unless it is complete.

  8. What is the role of analyzers in MongoDB?

  MongoDB includes a database analyzer that displays the performance characteristics of each operation in the database. With this profiler you can find queries (or writes) that are slower than expected; using this information, you can, for example, determine whether an index needs to be added.

  9. What is a namespace?

  MongoDB stores BSON objects in a collection. The database name and cluster name joined by a period are called namespaces.

  10. If a user removes an attribute of an object, is the attribute removed from the storage tier?

  Yes, the user removes the property and the object is re-saved (re-save()).

  11. Can I use the log feature for secure backups?

  Yes.

  12. Is null allowed?

  For object members, yes. However users cannot add null values ​​to a database collection because null values ​​are not objects. However the user can add an empty object {}.

  13. Is the update operation immediately fsynced to disk?

  No, disk writes are deferred by default. Writes may reach disk after two or three seconds (within 60 seconds by default). For example, if the database receives a thousand operations that increment an object in a second, the disk is flushed only once. (Note though that the fsync option is valid on the command line and via getLastError_old).

  14. How to perform transactions/locks?

  MongoDB does not use traditional locks or complex transactions with rollbacks because it is designed to be lightweight, fast, and predictably performant. It can be compared to the autocommit mode of MySQL MylSAM. By streamlining the support for transactions, performance is improved, especially in a system that may traverse multiple servers.

  15. Why is my data file so huge?

  MongoDB aggressively pre-allocates reserved space to prevent file system fragmentation.

  16. How long does it take to enable backup failback?

  It will take 10 to 30 seconds from when the backup database declares the primary database down to electing a backup database as the new primary database. Operations on the primary database during this period will fail -- including writes and strong consistent read operations. However, you can also perform eventually consistent queries (in slaveOk mode) on the second database, even during this time.

  17. What is master or primary?

  It is the primary node/member in the current backup cluster (replica set) responsible for handling all write operations. In a backup cluster, when a failover event occurs, an additional member becomes primary.

  18. What is secondary or slave?

   Seconday copies the corresponding operations from the current primary. It does this by tracking the replication oplog (local.oplog.rs).

  19. Do I have to call getLastError to make sure the write is valid?

  Need not. It doesn't matter whether you call getLastError (aka "Safe Mode") the server does the same thing. The call to getLastError is only to confirm that the write operation was successfully committed. Of course, you often want to get acknowledgment, but the safety and validity of the write operation is not determined by this.

  20. Should I start out with sharded or with a non-sharded MongoDB environment? Should I start out with sharded or with a non-sharded MongoDB environment?

  For ease of development, we recommend starting a MongoDB environment in unsharded mode, unless a single server is insufficient for your initial dataset. Upgrading from non-clustered sharding to clustered sharding is seamless, so there is no need to consider sharding when your dataset is not very large. 

  21. How does sharding and replication work?

  Each shard is a logical collection of partitioned data. A shard may consist of a single server or a cluster, we recommend using a cluster for each shard.

  22. When will data be expanded into multiple shards?

  MongoDB sharding is range based. So all objects in a collection are stored in a chunk. Only when there is more than 1 chunk is there an option for multiple shards to get data. Now, each default block size is 64Mb, so you need at least 64Mb to implement a migration.

  23. What happens when I try to update a document on a chunk that is being migrated?

  Updates happen immediately on the old shard, and changes are then replicated on the new shard before ownership transfers.

  24. What happens if I issue a query while a shard is down or very slow?

  If a shard is stopped, the query returns an error unless the "Partial" option is set for the query. If a shard is slow to respond, MongoDB will wait for its response.

  25. Can I delete old files in the moveChunk directory?

  No problem, these files are temporary files generated when the shard is balancing. Once these operations have been completed, the associated temporary files should also be deleted. However, cleanup is currently manual, so please carefully consider freeing up space for these files.

  26. How do I see what links Mongo is using?

  db._adminCommand("connPoolStats");

  27. If the block move operation (moveChunk) fails, do I need to manually clear some of the transferred documents?

  No, the move operation is consistent and deterministic; after a failure, the move operation will be retried continuously; when completed, the data will only appear in the new shard (shard).

  28. If I am using replication, can I use journaling for one part and not for other parts?

  Can.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326606424&siteId=291194637