I want to store data on a MonogoDB. Therefore I have one mongos, three configserver and a sharding set that consists of two replicasets (each with prim./sec./arbiter).
I have two problems
1) Whats the best way to measure the time that is needed to store all the data?
by now I execute “time mongo 141.100.55.72:25001/mydb –quiet /data/javascript/insert.js” via the mongos (insert.js is the javascript descriped later)
I want to measure multiple operations – whats a good way to store each output in a file (working on ubuntu server)
2)The measured time is really really slow -e.g.: The execution needs about 5 min. for 100.000 dataobjects..
How can I speed up the performance?
the javascript looks like this: (I’m creating testdata ; the sharding key is a iteration just for testing (key:x) – could that cause the low performance?)
var amount = 100000/4;
var x=1;
var doc= "";
for (i=0; i<amount; i++)
{
doc = { datetime: '1119528044', att2: '...', key: x,...} //14 attributes
db.mycol.insert(doc);
x=x + 1
}
for (i=0; i<amount; i++)
{
doc = { datetime: '1219268044', att2: '...', key: x,...} //14 attributes
db.mycol.insert(doc);
x=x + 1
}
for (i=0; i<amount; i++)
{
doc ={ datetime: '1355851700', att2: '...', key: x,...} //14 attributes
db.mycol.insert(doc);
x=x + 1
}
for (i=0; i<amount; i++)
{
doc = { datetime: '1444851704', att2: '...' key: x,...} //14 attributes
db.mycol.insert(doc);
x=x + 1
}
Furthermore I’m not sure how to check if the data is on both replicasets – what would be the best way to check that?
best regards
By running
time mongoyou are adding a lot of extra time with the process to open, establish a connection, and finish the entire script.Is that what are you trying to mesure? or the amount it takes for every insert to be replicated/stored in a shard?
If you want to run the script inside the shell:
And the measure how long it takes.