dispatch read and write from replicat on same machine ?

40 views
Skip to first unread message

petit curieux

unread,
May 21, 2015, 8:56:59 AM5/21/15
to mongod...@googlegroups.com
Hi ,

we'd like to know if  this model bellow is possible on mongodb on the same machine ?

all write on secondary  ==== > configure some delay (each 100s for ex) to update data primary from secondary ===>  all read on primary 


The fact is we don't need data accuracy so we can accept to have not always equal datas on primary and secondary , if its possible , is
this logic process makes sens for improving performance ?

regards,
gui

Stephen Dillon

unread,
May 21, 2015, 1:55:42 PM5/21/15
to mongod...@googlegroups.com

Do you mean you want to set your write preference to "All" when you say "all write on secondary? You can only write to primaries.

  • Yes, technically you are able to set up multiple instances of MongoDB on the same machine although this is only for simplistic test purposes when learning MongoDB.
  • Using a Write Preference of All would not make sense for performance. It is the opposite of what you wish to do. 
  • I do not understand why you wish to set a delay.
Per your statement "The fact is we don't need data accuracy so we can accept to have not always equal datas on primary and secondary ", you should instead set up three servers in a replica set and set the write preference to 1 and allow the secondaries to naturally accept the oplog operations from the primary.

Stephen Steneker

unread,
May 22, 2015, 5:27:16 AM5/22/15
to mongod...@googlegroups.com, mescomp...@gmail.com
On Thursday, 21 May 2015 22:56:59 UTC+10, petit curieux wrote:
we'd like to know if  this model bellow is possible on mongodb on the same machine ?

If your goal is to increase performance, you probably want to look at tuning your existing environment or spreading the load across additional machines via a replica set or sharded cluster deployment. Adding replica set nodes on the same machine is a multiplier for write I/O: each replica set secondary has to perform the same data updates as the primary.

If your server resource is currently under-utilised I would encourage you to try MongoDB 3.0 with the WiredTiger storage engine. It's not necessarily a panacea, but generally should perform significantly better for concurrent workloads.

 
all write on secondary  ==== > configure some delay (each 100s for ex) to update data primary from secondary ===>  all read on primary 
 
MongoDB's replication model is currently single master. That means that all writes go to the primary, and secondaries pull their data from the current primary (or an upstream secondary via replication chaining): http://docs.mongodb.org/manual/core/replication-introduction/.


The fact is we don't need data accuracy so we can accept to have not always equal datas on primary and secondary , if its possible , is
this logic process makes sens for improving performance ?

If you are OK with eventual consistency, it's possible to read from secondaries. However, secondaries are generally intended for data redundancy rather than read scaling.

For a lengthier explanation see: http://askasya.com/post/canreplicashelpscaling.

Regards,
Stephen

petit curieux

unread,
May 26, 2015, 7:31:18 PM5/26/15
to mongod...@googlegroups.com, mescomp...@gmail.com
thanks Stephen, ur link answer perfectly my need
Reply all
Reply to author
Forward
0 new messages