1

I was created MongoDB database in Linux Server (Standard D2 v2 (2 cores, 7 GB memory)) on the Windows Azure Platform.

I'm testing data insert to database with following codes. But result is not good..! 47 second for inserting 100.000 record very bad. What is the problem? enter image description here

Codes for insert to mongodb

string connectionString = "mongodb://root:bitnami@myserveraddress:27017";
var client = new MongoClient(connectionString);
var database = client.GetDatabase("testdb");
var collection = database.GetCollection<Item>("foo");
var documents = Enumerable.Range(1, 100000).Select(i => new Item
{
    Address = "Address " + i,
    City = "City " + i,
    Index = i + 1,
    Name = "Name " + i,
    Status = i % 2 == 0,
    Surname = "Surname " + i,
    Title = "Title " + i,
    Town = "Town " + i
});
var models = documents.Select(s => new InsertOneModel<Item>(s)).ToList();
Stopwatch sw = new Stopwatch();
sw.Start();
var result = collection.BulkWrite(models);
sw.Stop();
Console.WriteLine("Seconds:" + sw.Elapsed.Seconds);
result.InsertedCount.Dump();
collection.Count(p => 1 == 1).Dump();

1 Answers1

0

My data files on Azure (Linux Virtual Machine - Standard D2 v2 (2 cores, 7 GB memory))

  • Try to use DS2 series which will have SSD disk for operating system or attach new SSD disk to existing machine and move date files to it. – Pavel Kutakov Sep 21 '16 at 09:09