简体   繁体   中英

MongoDB is very slow on Azure Platform

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? 在此输入图像描述

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();

我在Azure上的数据文件(Linux虚拟机 - 标准D2 v2(2核,7 GB内存))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM