当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - MongoDB very slow write performance on server hardware

问题描述:

I've run into an odd performance issue while assessing MongoDB on Windows.

I've been running on a basic Windows 7 laptop (16GB RAM, i7-3540M CPU) and have seen great performance.

I've been given access to a more powerful Windows 2008 R2 server (128GB RAM, Xeon E7-4807 (4 processors)) for testing.

I'm benchmarking a single line of code which is giving me the problem - it's a simple insert using the new c# driver:

 await Collection.InsertOneAsync(entity);

My entity class is straightforward (EntityBase is just an ObjectID Id property):

[DataContract]

public class SamplePacket : EntityBase

{

[DataMember]

public ObjectId SampleId { get; set; }

[DataMember]

public int NumberOfScans { get; set; }

[DataMember]

public double MinimumScanTime { get; set; }

[DataMember]

public double MaximumScanTime { get; set; }

[DataMember]

public byte[] IndexStream { get; set; }

[DataMember]

public byte[] ContentStream { get; set; }

[DataMember]

public int PacketNumber { get; set; }

}

The ContentStream byte array can be between 0.1 and 5MB.

The configuration of the laptop and the server is as identical as I can make it. I have three mongod instances (2 shards and 1 config) and one mongos instance all running on the one machine. The c# program is running on the same machine as these instances and is talking to the mongos instance. The instances are all installed as services with default configurations, for example:

mongod --install --serviceName "Mongo DB Shard 1" --serviceDisplayName "Mongo DB Shard 1" --port 10001 --dbpath g:\data\db --logpath g:\data\logs\log.txt

If, in my entity class, ContentStream is a random byte array of 1MB, the sustained average time for the insert on the laptop is around 28ms. On the more powerful server it is around 500ms! This is from scratch, even when the database does not initially exist - this is not an issue with a big collection.

Using mongoperf with this configuration:

{nThreads:1, fileSizeMB:3, r:true, w:true, mmf:false}

shows the disk performance of the server to be much greater than the laptop. The server reports ~ "8729 ops/sec, 33 MB/sec" and the laptop reports ~ "1866 ops/sec, 7 MB/sec". CrystalDiskMark shows much better performance on the server.

After reading the warning message about NUMA, I've ensured that it is disabled on the server, to no effect.

Hotfix KB2731284 is installed to the best of knowledge - the installation of the hotfix seemed to go well but I still get the warning message when starting a mongo shell.

The same performance differential exists when writing to a single, non-sharded mongod instance.

If I write to a single Mongod instance with --nojournal as an option, the average write speed comes down from ~500ms to around 35ms (still slower than the journalled laptop!)

I can't see anything odd in the logs. The memory usage on the server is around 20GB of the 128GB available - there's nothing else significant running on it.

The only difference I can't do anything about is that on the server the disks are devices connected as SCSI devices through a PERC H700. I'm not sure what the configuration of these disks are - the server is on another continent!

Could a weird SCSI configuration be causing this, or is there some other issue I need to look at?

分享给朋友:
您可能感兴趣的文章:
随机阅读: