Saturday 15 March 2014

performance - how mongodb sharding works ?how to improve insert speed via sharding? -



performance - how mongodb sharding works ?how to improve insert speed via sharding? -

i want test mongodb's insert speed.there 4 shardings,3 config, 4 mongos, chunksize 64m,and when insert 100 double[100000] data,it can auto sharding ,but insert speed didn't improve.

(1) create database,create collection "docs",and insert 100 double[100000],it takes 30s (2) drop "docs",create new collection "docs",enablesharding ,insert {name:"hashed"},it takes 30s or more.

every sharding have same data,or chunk's number,i have changed chunksize 5mb,20mb,100mb,200mb, can't create speed cut down 3/4.

sharding reduces number of operations each shard handles,so how can cut down insert time,improve insert speed via add together sharding ? or test info wrong ,it little display mongodb's performance? stop balancer(),sh.stopbalancer(),sh.status()

mongos> sh.status() --- sharding status --- sharding version: { "_id" : 1, "version" : 4, "mincompatibleversion" : 4, "currentversion" : 5, "clusterid" : objectid("5450ed56eb3978383f81a863") } shards: { "_id" : "s1", "host" : "192.168.137.101:27017" } { "_id" : "s2", "host" : "192.168.137.102:27018" } { "_id" : "s3", "host" : "192.168.137.103:27019" } { "_id" : "s4", "host" : "192.168.137.104:27020" } databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "liu", "partitioned" : true, "primary" : "s2" } liu.docs shard key: { "name" : "hashed" } chunks: s1 4 s2 7 s3 6 s4 5 many chunks print, utilize verbose if want forcefulness print { "_id" : "test", "partitioned" : false, "primary" : "s1" }

every sharding have data, means mongodb have distributed evenly via shard key?but why insert speed not reduce,is there wrong ?do have same situation or cut down time successfully?

i utilize multithreadings cut down time successfully.

there 2 possible scenarios here: 1. inserts spread evenly across shards, in such scenario read write performance improve linearly every shard added. number of mongos(routers) can increased. 2. inserts focused on 1 or subset of shards, in such scenario adding shards not help increment performance. indicates shardkey has lower cardinality or randomness factor. check out link : choosing shard key

since have not given sufficient data(with respect shardkey used , inserts affecting shards), need deduce of above 2 scenarios preventing improvements in write performance.

hope helps.

performance mongodb insert sharding

No comments:

Post a Comment