web projects • Popular • High performance (No joins and embedding makes reads and writes fast) • High availability (Replicated servers with automatic master failover) • Easy scalability (Automatic sharding)
store arrays of addresses with ease • CMS: the flexible schema of MongoDB is great for heterogeneous collections of content types • Form data: MongoDB makes it easy to evolve structure of form data over time • Blogs / user-generated content: can keep data with complex relationships together in one object • Messaging: vary message meta-data easily per message or message type without needing to maintain separate collections or schemas • System configuration: just a nice object graph of configuration values, which is very natural in MongoDB • Log data of any kind: structured log data is the future • Graphs: just objects and pointers – a perfect fit • Location based data: MongoDB understands geo-spatial coordinates and natively supports geo- spatial indexing http://blog.mongolab.com/2012/08/why-is-mongodb-wildly-popular/
for you if you follow these rules for your entities • Has a public no-argument constructor • Has a public get set property for each value you want to have serialized
write concern will wait for acknowledgement from the primary server before returning. • Unacknowledged • Write operations that use this write concern will return as soon as the message is written to the socket. • Journaled • Exceptions are raised for network issues, and server errors; the write operation waits for the server to group commit to the journal file on disk. • Replica Acknowledged • Exceptions are raised for network issues, and server errors; waits for at least 2 servers for the write operation. http://docs.mongodb.org/manual/core/write-concern/ http://api.mongodb.org/java/current/com/mongodb/WriteConcern.html https://github.com/mongodb/mongo-csharp-driver/blob/master/MongoDB.Driver/WriteConcern.cs
parameter and be sure your your queries are not making full table scans... • You get exceptions if a query needs a table scan, it gives you a chance to fix your indexes on development time.
good to use relational databases (oracle, sql server) for this purpose • If you are stuck in a situation that needs transactions with MongoDB you must implement it by your self. • http://docs.mongodb.org/manual/tutorial/perform-two-phase-commits/ • https://github.com/rystsov/mongodb-transaction-example
Asynchronous replication • Master - Slave model • Not master-master, when your data change there are times that you only have one master… • Statement based • For example, insert statement send to the replica and will run there… • Driver is replica set aware, • Connection to replica set mongodb://server1,server2:27017,server2:27018
begins with A, B-E, F-H …. • Shardkey is important! • Bad shard key choice can cause too many split and merge operations on chunks mongod mongod mongod Replicaset mongod mongod mongod Replicaset S1 S2 mongos mongod mongod mongod Config Server Client 1 2 3 4