python - Slow insert into MongoDB Replica Set, with pymongo -
i'm doing project university have perform tests check times insert , find in replica set of mongodb changing number of members (nodes). 1 member plus 1 arbiter 3 member plus arbiter.
i have instantiated , configured correctly 4 instances t2.micro (with aws ec2) ubuntu server os , mongodb installed , configured on each instance. have initialized replica set 1 node.
after programmed tests in python, realized insert of 1,000 items in mongodb collection took 23 s perform it, seems strange since make insert query replication set 4 nodes , arbiter.
this code wrote test, , takes 23 seconds execute queries:
import timeit pymongo import mongoclient time import sleep _connection = mongoclient('84.93.90.12', 27017) _dbmongodb = _connection.test start_time = timeit.default_timer() # inizio contare il tempo d'esecuzione in range(1000): _dbmongodb.test.insert({"test":1}) elapsed = timeit.default_timer() - start_time print(elapsed)
is there specific driver connect replication set mongodb in python? doing wrong connection replica set?
if try insert 1000 data directly primary node in mongodb shell these instructions:
start = new date(); for(var = 0; < 1000; i++){db.timecheck.insert({"_id" : i})}; end = new date(); print(end - start);
the execution time of query 8 ms.
any idea slowness? can me?
thanks in advance!
Comments
Post a Comment