Improving MongoOptions in Java driver

212 vues
Accéder directement au premier message non lu

Jérôme Leleu

non lue,
16 avr. 2012, 07:51:2816/04/2012
à mongodb-dev
Hi,

I'm using Mongo server 2.0.2 and java Mongo driver 2.7.3.

I would suggest some improvments on the driver and in particular on
the MongoOptions class :

- some default values are IMHO very dangerous :
* maxWaitTime : it's 120 seconds : I would set it to 200 ms
* connectTimeout : it's unlimited : I would set it to 200 ms
* socketTimeout : it's unlimited : I would set it to 1 second
* wtimeout : it's unlimited : I would set it to 1 second

- there is no setters/getters for these values : it makes uneasy to
define MongoOptions configuration bean with Spring framework. It would
be great to have setters/getters for all options.

Is this something possible ?

Thanks.
Best regards,
Jérôme


Eliot Horowitz

non lue,
16 avr. 2012, 09:20:0816/04/2012
à mongo...@googlegroups.com
> - some default values are IMHO very dangerous :
>  * maxWaitTime : it's 120 seconds : I would set it to 200 ms

Most connection pools have no timeout, so I think 120 seconds is a good start.
Obviously it is too high for certain apps, but I do think its a good default.

>  * connectTimeout : it's unlimited : I would set it to 200 ms

Agree this shouldn't be unlimited. 200ms is way too aggressive though.
5 or 10 seconds seems appropriate.

>  * socketTimeout : it's unlimited : I would set it to 1 second
>  * wtimeout : it's unlimited : I would set it to 1 second

For both of these, most people expect no timeout for db operations.

> - there is no setters/getters for these values : it makes uneasy to
> define MongoOptions configuration bean with Spring framework. It would
> be great to have setters/getters for all options.

This definitely makes sense.

For the connect timeout and getters/settings, can you make 2 cases @
https://jira.mongodb.org/browse/JAVA

Jérôme Leleu

non lue,
16 avr. 2012, 10:52:0116/04/2012
à mongodb-dev
I'm using MongoDB in production on a system handling hundreds of
requests per second.

First time I configured the java driver, I was mistaken between my
internal pool and the mongo connection pool : as threads were blocked
120 seconds waiting for available connection, my system died in a few
seconds, all threads blocked.
I think that 120 seconds is really too much.

For connectTimeout, it's a network timeout, it's a low-level system
action : establishing a connection wouldn't last more than a few
hundreds of milliseconds even if you reach a system on the other side
of the planet !

I'm always expecting to have a value for timeout as I can't imagine
waiting an unlimited amout of time for reading or writing : what
system can wait for ever to read or write something ? Seems to me
there is something wrong if read or write never ends.

I'll create the two JIRAs.

Best regards,
Jérôme
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message