On 9 Feb, 14:09, Scott Hernandez <
scotthernan...@gmail.com> wrote:
> If you do the same query from the mongo javascript shell from the host
> the java code is running to the remote data center how long does the
> query take?
I don't know how to measure it. It looks to return immediatly. Surely
not seconds.
>
> Also, tagging is not yet supported in the driver for ReadPreferences.
> Can you post your java code, esp. the part where you create the Mongo
> instance and ReadPreference for the query?
Well, I've discovered this problem while I was testing new driver for
tagging feature. Actually we have 2.6.5 in production. This is the
scala code
val host1 = "fr01-baldb01:27017" // parigi
val host2 = "de01-baldb01:27017" // francoforte
val addresses = new ArrayList[String]()
addresses.add(host1)
addresses.add(host2)
val mongo1 = new Mongo(addresses.map(new ServerAddress(_)))//
mongo1.setReadPreference( new ReadPreference.TaggedReadPreference
(Map("dc" -> tag))).
'tag' is argument of the script
When I use 2.6.5 driver I replace last line with SlaveOK option.
>
> Also, can you describe which machine the java code is running on and
> when you simulate the network error which hosts you are querying?
> Including their geographical location and latency would help as well.
> On Thu, Feb 9, 2012 at 3:49 AM, Emanuele Bragagnolo
This is the conf for replica set
config = {_id: 'testmultisite', members: [
{_id: 0, host: 'fr01-baldb01:27017', tags :
{"dc": "fr"}},
{_id: 1, host: 'de01-baldb01:27017', tags :
{"dc": "de"}},
{_id: 2, host: 'fr01-baldb01:27019', tags :
{"dc": "fr"}}]
}
Fr: node in Paris, France
De: node in Frankfurt, Germany
Ping time 13 ms.
Hosts are connected with vpn.
Script run in a host in Paris.
When master is up:
Mongo Response time from Paris: 0-1 ms
Mongo Response time from Frankfurt: 14 ms
When master is down:
Mongo Response time from Paris: 1 - 6 sec
Mongo Response time from Frankfurt: 1 - 6 sec
About java driver tag feature suppport:
I am a little bit confused about it: Java Driver API and release notes
indicates tag feature is supported, but in
https://jira.mongodb.org/browse
I've found several open issues about tag feature.
Do you mean that actually java driver tag feature has some bugs? If
yes, do you know if 2.7.4 release will fix them?
However this is what I've seen running the test :
The result I've got with 3 nodes up seems to indicate that java driver
tagging function works quite well:
The test consist in reading 20 value in sequence and output response
time. I run it several times getting always similar results.
with tag="fr" I always got a 0 ms response time
with tag="de" 85% I got 15ms response time, 15% 0 ms
I don't konw how to interpret the second result. But the first clearly
indicates the query are routed to the closest slave.
This is how I measure time in scala
val then = System.currentTimeMillis
var resp = collection1.findOne(new BasicDBObject(newKey, newValue))
val now = System.currentTimeMillis
println("Got updated object: " + resp.toString + " after: " + (now -
then) + " ms")