Return error from :safe => true? And does using :safe => true materially increase reliability of writes?

18 views
Skip to first unread message

Panabee

unread,
Apr 19, 2012, 3:10:00 PM4/19/12
to mongo...@googlegroups.com
Hi all,

According to the MonoMapper docs, using :safe => true on saves is supposed to increase reliability by " the driver to make sure the save succeeds and raise an error if it doesn’t."

Could someone elaborate on the performance/reliability tradeoff, and whether making the switch in production yielded material increases in successful writes?

We have a retry mechanism and can afford to lose data, but we prefer to nail the write the first time and avoid the overhead of a retry if possible.

Also, what is the return value on a save operation with :safe => true when a write fails? We weren't able to reproduce a failed write.

Thanks!




John Nunemaker

unread,
Apr 20, 2012, 8:48:52 AM4/20/12
to mongo...@googlegroups.com
Using safe means that the driver will wait until it receives a response back from the server. Mongo has a global lock, so waiting for the server to respond when there are a ton of ops flying in will definitely slow things down.

If you have a read heavy app, using safe is probably fine. If you have a write heavy app, you might be better off without it.

My advice: try it with safe and if you start to see performance issues, head back to the drawing table and see what you can do to speed things up.





--
You received this message because you are subscribed to the Google
Groups "MongoMapper" group.
For more options, visit this group at
http://groups.google.com/group/mongomapper?hl=en?hl=en

Panabee

unread,
Apr 21, 2012, 4:28:15 PM4/21/12
to mongo...@googlegroups.com
thanks for replying and for creating mongomapper!

to clarify, safe waits for a response, but does this increase write reliability (i.e., # of write fails will decrease) or is the error rate the same? i'm just trying to understand the benefits/costs of using safe.

if the error rate is the same, then is it correct to say the benefit of safe is just knowing an error occurred and not increasing write reliability like some docs suggest?

thanks again!


On Friday, April 20, 2012 5:48:52 AM UTC-7, jnunemaker wrote:
Using safe means that the driver will wait until it receives a response back from the server. Mongo has a global lock, so waiting for the server to respond when there are a ton of ops flying in will definitely slow things down.

If you have a read heavy app, using safe is probably fine. If you have a write heavy app, you might be better off without it.

My advice: try it with safe and if you start to see performance issues, head back to the drawing table and see what you can do to speed things up.

John Nunemaker

unread,
Apr 21, 2012, 5:25:15 PM4/21/12
to mongo...@googlegroups.com
There is no benefit server side. The only benefit is the client knows the error happened. 

Reply all
Reply to author
Forward
0 new messages