【问题标题】:Service Fabric Transactions are x10 times slower than SQL transactions in another machineService Fabric 事务比另一台计算机上的 SQL 事务慢 10 倍
【发布时间】:2017-06-29 11:48:25
【问题描述】:

我在 Reliable 字典中尝试过事务处理,它们的执行速度比 SQL 处理外事务慢 10 倍。我们想使用服务结构,但如果它不能在正在处理的事务中执行简单的增量任务,我们怎么能依赖它。

在 Service Fabric 上

简单调用 GetFromStateful 方法 5000 次大约需要 100 秒才能完成

在 RDBMS 上

相同的操作需要 10 秒才能完成。(即使这是在进程之外,也要慢 10 倍)

我没有得到的是?

  • 为什么这么慢?
  • Microsoft 将其宣传为 FAST?

代码

   using System.Collections.Generic;
   using System.Fabric;
   using System.Threading.Tasks;
   using Microsoft.ServiceFabric.Data.Collections;
   using Microsoft.ServiceFabric.Services.Communication.Runtime;
   using Microsoft.ServiceFabric.Services.Remoting.FabricTransport.Runtime;
   using Microsoft.ServiceFabric.Services.Runtime;

   namespace Counting
    {
   internal sealed class Counting : StatefulService,
       ICount
   {
       private IReliableDictionary<string, int> _myDictionary = null;

       public Counting(StatefulServiceContext context)
           : base(context)
       {
       }

       protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
       {
           var settings = new FabricTransportRemotingListenerSettings
           {
               MaxConcurrentCalls = 32
           };

           yield return
               new ServiceReplicaListener(
                   context =>
                       new FabricTransportServiceRemotingListener(context, this, settings));
       }

       async Task<int> ICount.GetFromStateful()
       {
           if (_myDictionary == null)
           {
               _myDictionary = await StateManager.GetOrAddAsync<IReliableDictionary<string, int>>("myDictionary").ConfigureAwait(false);
           }

           using (var tx = StateManager.CreateTransaction())
           {
               var result = await _myDictionary.AddOrUpdateAsync(tx, "Counter", 0, (key, value) => ++value).ConfigureAwait(false);

               await tx.CommitAsync().ConfigureAwait(false);

               return result;
           }
       }
   }
  }

Microsoft Service Fabric 团队将此作为市场营销

来自笔记

Reliable Dictionary 会定期从内存中删除最近最少使用的值。这是为了启用

· 大而可靠的字典

· 更高的密度:每个副本的可靠集合密度更高,每个节点的副本密度更高。 权衡是,这会增加读取延迟:需要磁盘 IO 来检索未缓存在内存中的值。“

但我们在执行此操作时看不到任何 cpu/ram/disk IO。

【问题讨论】:

  • ConfigureAwait(false) 语句是怎么回事?
  • 全部删除,没有区别。在这条线上,我们正在减速。等待 tx.CommitAsync().ConfigureAwait(false);
  • 这有影响吗\\\\\ [StatePersistence(StatePersistence.Persisted)] internal class CountingActor : Actor, ICountingActor
  • 从您发布的内容中,无法判断您做错了什么,但您做错了什么,因为其他人每秒可以收到 1,000 个请求。也许您应该下载性能示例,看看正确编写的解决方案可以做什么github.com/Azure-Samples/service-fabric-dotnet-performance
  • 正如我在其他相关问题中所问的那样,发布调用者的代码。

标签: performance azure dictionary transactions azure-service-fabric


【解决方案1】:

您更新单个记录.. SF 将对其进行写锁定。

SF 恕我直言,专为 3 个案例设计

  • 1) 非常小的东西,例如微服务和参与者,其中的成本 管理许多 SQL 服务器的成本太高了
  • 2) 超大规模分片等。
  • 3) 高可用,SQL 只掉过,它的 那就很难了。

记住它是一个 NoSQL,所以你需要考虑文档而不是表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 2018-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多