简体   繁体   English

MongoDB在Azure平台上非常慢

[英]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. 我在Windows Azure平台上的Linux服务器( 标准D2 v2(2核,7 GB内存) )中创建了MongoDB数据库。

I'm testing data insert to database with following codes. 我正在使用以下代码测试数据插入数据库。 But result is not good..! 但结果并不好......! 47 second for inserting 100.000 record very bad. 47秒插入100.000记录非常糟糕。 What is the problem? 问题是什么? 在此输入图像描述

Codes for insert to mongodb 插入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内存))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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