【问题标题】:Does affinity colocation work with Ignite Thin client?亲和力托管是否适用于 Ignite 瘦客户端?
【发布时间】:2022-07-06 19:48:57
【问题描述】:

the docs 中,我可以找到仅适用于胖客户端的关联托管配置示例。此功能是否适用于瘦客户端?请提供任何配置示例?

在我的应用程序中,我使用键值 API 来处理 Ignite Cache。

我试图简单地将 AffinityKey 作为我的 put/get 操作的键(参见下面的代码)。我使用 clientId 将特定客户端的值存储在同一节点上。但是性能测试并没有显示getAll 计时的任何改进。

我怀疑我的配置有问题:

@Bean
    ClientConfiguration igniteThinClientConfiguration(IgniteProperties igniteProperties) {
        ClientConfiguration clientConfiguration = new ClientConfiguration();
        clientConfiguration.setTimeout(igniteProperties.getTimeout());
        clientConfiguration.setAddresses(igniteProperties.getAddresses());
        clientConfiguration.setPartitionAwarenessEnabled(igniteProperties.isPartitionAwareness());
        return clientConfiguration;
    }
private static ClientCacheConfiguration cacheConfig(String cacheName, String cacheGroup, String dataRegion) {
        ClientCacheConfiguration cfg = new ClientCacheConfiguration();
        cfg.setName(cacheName);
        cfg.setCacheMode(CacheMode.PARTITIONED);
        cfg.setBackups(0);
        cfg.setExpiryPolicy(new TouchedExpiryPolicy(new Duration(TimeUnit.HOURS, 6)));
        cfg.setStatisticsEnabled(true);
        cfg.setDefaultLockTimeout(3000L);
        cfg.setGroupName(cacheGroup);
        cfg.setDataRegionName(dataRegion);
        return cfg;
    }
IgniteClient igniteClient = Ignition.startClient(igniteConfiguration);
ClientCache<AffinityKey<Long>, PaymentReceiptResponse> receiptCache = igniteClient.getOrCreateCache(cacheConfig(...));
...
receiptCache.put(new AffinityKey<>(123L, \"clientId\"), value)
...
Set<AffinityKey<String>> keys = ...;
receiptCache.getAll(keys)

    标签: java ignite


    【解决方案1】:

    是的,亲和力托管在 Ignite 瘦客户端中的工作方式与在胖客户端中的工作方式相同。

    瘦客户端还支持Partition Awareness - 将请求直接发送到给定缓存条目的主节点。默认情况下启用。

    我试图简单地将 AffinityKey 作为我的 put/get 操作的键,但性能测试并没有显示出任何时间改进。

    AffinityKey 不会提高 put 操作的性能。 AffinityKey 控制数据分发并允许诸如“将客户的所有订单放在存储客户条目的同一节点上”, 以便可以一起处理相关数据(使用 Compute 或 SQL) - 这是您可以实现性能提升的地方。

    【讨论】:

    • “将客户端的所有订单放在存储客户端条目的同一节点上” - 这正是我想要实现的目标。我使用 clientId 作为关联键来存储与同一节点上的特定客户端相关的值。在我的性能测试中,我只测试了 get 操作,但没有改进。所以我怀疑我的客户端配置有问题。
    • 您只是将数据从服务器复制到客户端 - 将数据放在同一位置并没有任何好处。你在哪里得到好处就是你在哪里通过网络复制数据。例如,您可以在服务器端(使用计算或 SQL)将所有付款的价值相加,而无需网络访问。
    猜你喜欢
    • 2019-07-20
    • 2020-12-20
    • 2021-09-22
    • 2020-06-21
    • 2020-02-14
    • 1970-01-01
    • 2019-11-09
    • 2020-11-30
    • 1970-01-01
    相关资源
    最近更新 更多