【发布时间】:2020-09-04 07:12:25
【问题描述】:
我在将 hazelcast 配置为客户端-服务器时遇到了性能问题。 我有一个由 5 个节点和 1 个主节点组成的 K8S 集群。每个节点有 64 GB 的 RAM 和 16 核(Hazelcast 版本 3.12.4) Hazelcast 服务器部署在 K8S 上,在集群中可用的节点之一上有一个 POD 我的客户端部署在 K8S 上,它通过智能客户端连接到 Hazelcast 之上(为 K8S 启用了 Hazelcast 发现)。我的应用程序总共有 10 个 POD,每个节点由我的应用程序的 2 个 POD 组成。
我正在运行不同的 API 并对我的应用程序执行负载测试(一次大约 110 个线程在所有 10 个 POD 之间共享)
我的应用程序中有以下代码来获取缓存。
public Map<Object, Object> get(String cacheId, Long lTenantId) {
String strMethodName="get";
long t1 = System.currentTimeMillis();
Map<Object,Object> cacheDataMap=hazelcastInstance.getMap(cacheId);
long totalTimeTaken = (System.currentTimeMillis()-t1);
if(totalTimeTaken > 10){
logger.warnLog(CLASSNAME, strMethodName,"Total time taken by "+cacheId+" identifier for get operation is : "+totalTimeTaken+" ms");
}
return cacheDataMap;
}
我的应用程序使用此地图的方式各不相同
1)
map.get(key);
2)
Set keys = map.keySet();
Iterator iterator = keys.iterator(); //I changed to keyset iterator because entryset was causing lot of performance issues
while (iterator.hasNext()) {
// doing stuff
}
当我的所有 API 都为 Load 启动时,我将这些日志打印在一个应用程序中(总时间……),其中每个缓存访问时间 > 10 毫秒,这会导致性能问题,因此我不是能够为所有 API 实现我想要的 TPS。
大约有 300 个地图存储在缓存中,缓存的总大小为 4.22 MB
我正在使用近缓存配置,并且在管理中心上它显示为 100% 的有效性。 (这是在启用 hazelcast.client.statistics.enabled 时拍摄的)。
我还尝试在 Hazelcast 服务器的 4 个节点和 1 个专用节点上部署 8 个 POD,但问题仍然存在。当我将 Hazelcast 连接为嵌入式时没有观察到任何问题,并且我能够为所有 API 实现我想要的 TPS。
我是否缺少导致此问题的任何配置或任何其他内容?
这是我的 hazelcast-client.xml
<hazelcast-client
xmlns="http://www.hazelcast.com/schema/client-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/client-config
http://hazelcast.com/schema/client-config/hazelcast-client-config-3.11.xsd">
<group>
<name>dev</name>
</group>
<instance-name>hazelcast</instance-name>
<properties>
<property name="hazelcast.client.shuffle.member.list">true</property>
<property name="hazelcast.client.heartbeat.timeout">600000</property>
<property name="hazelcast.client.heartbeat.interval">180000</property>
<property name="hazelcast.client.event.queue.capacity">1000000</property>
<property name="hazelcast.client.invocation.timeout.seconds">120</property>
<property name="hazelcast.client.statistics.enabled">false</property>
<property name="hazelcast.discovery.enabled">true</property>
<property name="hazelcast.map.invalidation.batch.enabled">false</property>
</properties>
<network>
<discovery-strategies>
<discovery-strategy enabled="true"
class="com.hazelcast.kubernetes.HazelcastKubernetesDiscoveryStrategy">
<properties>
<property name="service-name"><service-name></property>
<property name="namespace"><namespace></property>
</properties>
</discovery-strategy>
</discovery-strategies>
<smart-routing>true</smart-routing>
<redo-operation>true</redo-operation>
<connection-timeout>90000</connection-timeout>
<connection-attempt-period>100</connection-attempt-period>
<connection-attempt-limit>0</connection-attempt-limit>
</network>
<near-cache name="default">
<in-memory-format>OBJECT</in-memory-format>
<serialize-keys>true</serialize-keys>
<invalidate-on-change>true</invalidate-on-change>
<eviction eviction-policy="NONE" max-size-policy="ENTRY_COUNT"/>
</near-cache>
</hazelcast-client>
这是我的 hazelcast.xml
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.11.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<management-center enabled="${hazelcast.mancenter.enabled}">${hazelcast.mancenter.url}</management-center>
</hazelcast>
【问题讨论】:
-
您能否尝试启动多个 Hazelcast 成员作为服务器部分并检查问题是否仍然存在?
-
感谢您的建议。尝试使用 3、4 和 5 个 Hazelcast 成员作为服务器,但无法达到我想要的 TPS。它与 Single POD 几乎相同。
标签: java performance kubernetes hazelcast hazelcast-imap