Hazelcast NearCache对性能没有预期的影响 [英] Hazelcast NearCache doesn't have the expected effect on performance

查看:248
本文介绍了Hazelcast NearCache对性能没有预期的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据环境,我们有一个在1或2个节点上运行的应用程序,该应用程序具有基于Hazelcast的共享缓存.

We have an application running on 1 or 2 nodes, depending on the environment, with a shared cache based on Hazelcast.

应用程序上的一个请求在此缓存上触发了大约1000个请求(所有缓存命中).

One of the requests on the application triggers about 1000 requests on this cache (all cache hits).

在单节点配置中,这很好地工作.具体来说,每个请求只需不到10毫秒的时间.

In a single node configuration this works nicely. Specifically each request takes less then 10ms.

但是,如果我们使用2个节点,则每个缓存请求大约需要20-200ms.我们认为这是由于Hazelcast从远程节点获取数据而引起的,这当然涉及网络流量.因此,我们将其配置为使用NearCache,据我们所知,NearCache的访问速度应与单个本地缓存大致相同.但这并没有,它似乎根本没有影响性能.

But if we use 2 nodes, each cache request takes about 20-200ms. We thought this would be due to Hazelcast getting the data from the remote node, which of course involves network traffic. So we configured it to use a NearCache, which to our understanding should result in about the same access speed as a single local cache. But it doesn't, it doesn't seem to have an effect on the performance at all.

所以现在我想知道:

  • 如何检查NearCache配置是否确实有效?
  • 如何获得接近本地缓存的读取性能,但是如何(异步地)将更新传达给所有远程缓存(我认为可以通过配置NearCache来获得)?

我们使用以下配置初始化缓存:

We initialize our cache with the following configuration:

HazelcastConfiguration.getOrCreateCache(
                cacheName,
                new CacheConfig<K, CR>()
                        .setNearCacheConfig(new NearCacheConfig())
                        .setExpiryPolicyFactory(
                                HazelcastConfiguration.createExpiryPolicyFactory(expiryAfterModification)),
                cacheManager
        );

推荐答案

这取决于很多事情,但是20/200ms很多.当我们在1个标准1 GbE网络上运行4节点群集基准测试(4个双插槽xeon计算机)时,99%远远低于1毫秒.我们在这里没有谈论Nearcache.

It depends on a lot of things, but 20/200ms is a lot. When we run a 4 node cluster benchmark (4 dual socket xeon machine) on 1 standard 1 GbE network, 99 percentile is far below 1 ms. We are talking here without nearcache.

近缓存应该提供非常好的性能,因为如果数据是本地缓存的,则调用是本地的+跳过了用于执行操作的整个内部基础结构(至少对于IMap和Near缓存;不是完全确定缓存)

Near cache should give very good performance because if the data is locally cached, then the call is local + the whole internal infrastructure for operation execution is skipped (at least for the IMap and the near cache; not completely sure about the Cache.

您可以尝试按相同的键集吗?只是为了确保您要命中快缓存.

Can you try hitting the same set of key(s)? Just to make sure you are hitting the near cache.

您使用什么作为键和值?它们很大还是序列化不友好?

What are you using as key and value? Are they large or serialization unfriendly?

我您仍然遇到问题;快速尝试使用IMap并启用近缓存,并检查是否存在较大差异.

I you are still running into problems; quickly try to IMap and enable near cache and check if you see big differences.

这篇关于Hazelcast NearCache对性能没有预期的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆