如何使用mongo Api利用100%的保留RU/s? [英] How to utilize 100% of the reserved RU/s using mongo Api?
问题描述
当我对mongoDB api进行性能测试时,我发现我无法使用100%的RU/s.
使用替换一个"方法时,我只能使用RU/s的50%,而不会收到429个错误.
When I was performance testing the mongoDB api i found out that I could not utilize 100% of the RU/s.
When using the ReplaceOne Method I was able to utilize only 50% of the RU/s before getting 429 errors.
范围:
一个带分区集合的mongodb使用40000 RU/s和partitionKey MongoDb.Driver v2.7.0(用于MongoDB的官方.net驱动程序)
.net核心2.1
A mongodb with partitioned collection using 40000 RU's/s with partitionKey, no georeplication and strong consistancy
MongoDb.Driver v2.7.0 (official .net driver for MongoDB)
.net core 2.1
代码:
using MongoDB.Driver;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MongoTester
{
public class PerformanceTester
{
private static Random _random = new Random();
private readonly IMongoCollection<RootObject> mongoCollection;
private readonly MongoClient client;
public PerformanceTester()
{
var mongoSettings = MongoClientSettings.FromConnectionString("........");
mongoSettings.MaxConnectionPoolSize = 200;
client = new MongoClient(mongoSettings);
var database = client.GetDatabase("Test");
mongoCollection = database.GetCollection<RootObject>("Test");
StartPerformanceTest();
}
private void StartPerformanceTest()
{
while (true)
{
var testObjects = CreateTestObject();
Parallel.ForEach(testObjects, new ParallelOptions { MaxDegreeOfParallelism = 10 }, (RootObject testObject) =>
{
try
{
var filter = Builders<RootObject>.Filter.Eq(x => x.partitionId, testObject.partitionId);
mongoCollection.ReplaceOne(filter, testObject, new UpdateOptions { IsUpsert = true });
}
catch (Exception e)
{
Thread.Sleep(200);
}
});
};
}
private IEnumerable<RootObject> CreateTestObject()
{
while (true)
{
for (int i = 0; i < 100000; i++)
{
yield return JsonConvert.DeserializeObject<RootObject>(string.Format(@"{{
""partitionId"" : ""{0}"",
""description"" : ""{1}""
}}", i, _random.Next(100,1000)));
};
}
}
}
}
在运行代码时,似乎我们达到了某种未记录的替换"限制.达到限制(已定义吞吐量的50%)时,我们将获得429个状态代码,portal.azure.com/database停止响应.
When running the code it seems that we are hitting some kind of undocumented Replace limit. When reaching the limit (50% of the defined thoughput) we get 429 status codes and the portal.azure.com/database stops responding.
现在有人为什么不能超过50%吗?
Does someone now why are not able to get over the 50%?
Ps.使用具有相同设置的文档客户端可以使我们达到保留的RU/s的总量.但是我们希望使用mongo作为PROMISED的理想迁移路径.
Ps. using the document client with the same setup lets us reach the total amount of RU/s reserved. But we want to use mongo for the nice migration path as PROMISED.
推荐答案
Sietse,
Hi Sietse,
您似乎正在尝试上传一些图片?如果是这样,您能否将它们发送给Microsoft.com上的AzCommunity,我将为您上传/附加到此论坛主题.我需要此信息以进一步了解您的Mongo Client的限制. 谢谢Mike
It looks like you were trying to upload some images? If so, can you please send these to AzCommunity at Microsoft.com and I will upload/attach to this forum thread for you. I need this information to understand the limitation on your Mongo Client a bit more. Thank you, Mike
这篇关于如何使用mongo Api利用100%的保留RU/s?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!