【发布时间】:2019-01-08 21:32:41
【问题描述】:
我有一个跨 7 个节点的集群分区的可靠字典。 [60 个分区]。我已经设置了这样的远程监听器:
var settings = new FabricTransportRemotingListenerSettings
{
MaxMessageSize = Common.ServiceFabricGlobalConstants.MaxMessageSize,
MaxConcurrentCalls = 200
};
return new[]
{
new ServiceReplicaListener((c) => new FabricTransportServiceRemotingListener(c, this, settings))
};
我正在尝试进行负载测试,以证明 Reliable Dictionary“读取”性能在负载下不会降低。我有一个像这样的字典方法“读取”:
using (ITransaction tx = this.StateManager.CreateTransaction())
{
IAsyncEnumerable<KeyValuePair<PriceKey, Price>> items;
IAsyncEnumerator<KeyValuePair<PriceKey, Price>> e;
items = await priceDictionary.CreateEnumerableAsync(tx,
(item) => item.Id == id, EnumerationMode.Unordered);
e = items.GetAsyncEnumerator();
while (await e.MoveNextAsync(CancellationToken.None))
{
var p = new Price(
e.Current.Key.Id,
e.Current.Key.Version, e.Current.Key.Id, e.Current.Key.Date,
e.Current.Value.Source, e.Current.Value.Price, e.Current.Value.Type,
e.Current.Value.Status);
intermediatePrice.TryAdd(new PriceKey(e.Current.Key.Id, e.Current.Key.Version, id, e.Current.Key.Date), p);
}
}
return intermediatePrice;
每个分区有大约 500,000 条记录。字典中的每个“键”大约是 200 个字节,“值”大约是 600 个字节。当我直接从浏览器调用这个“读取”[调用 REST API 进而调用有状态服务]时,需要 200 毫秒。 如果我通过负载测试运行此程序,假设 16 个并行线程访问 same partition 和 same record,则每次调用平均需要大约 600 毫秒。如果我将负载测试并行线程数增加到 24 或 30,则每次调用大约需要 1 秒。 我的问题是,Service Fabric Reliable Dictionary 能否处理并行“读取”操作,就像 SQL Server 可以处理并行并发读取一样,而不影响吞吐量?
【问题讨论】:
-
priceDictionary中的项目是否唯一?
标签: c# azure-service-fabric reliable-dictionary