我們正試圖在應用程序中使用Hazelcast作爲分佈式緩存。這是我們的配置:Hazelcast表現較慢
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.7.xsd" xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>sample_dev</name>
<password>[email protected]</password>
</group>
<management-center enabled="false">http://localhost:8080/mancenter</management-center>
<properties>
<property name="hazelcast.logging.type">slf4j</property>
<property name="hazelcast.socket.bind.any">false</property>
</properties>
<serialization>
<serializers>
<global-serializer override-java-serialization="true">com.prasanth.common.KryoSerializer</global-serializer>
</serializers>
</serialization>
<network>
<join>
<multicast enabled="false"/>
<tcp-ip enabled="true">
<member-list>
<member>127.0.0.1:5701</member>
</member-list>
</tcp-ip>
</join>
<interfaces enabled="false">
<interface>192.168.3.*</interface>
</interfaces>
</network>
<map name="com.prasanth.cache.CachedAsset">
<in-memory-format>BINARY</in-memory-format>
<backup-count>1</backup-count>
<async-backup-count>1</async-backup-count>
<time-to-live-seconds>86400</time-to-live-seconds>
<max-idle-seconds>1200</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<max-size policy="PER_NODE">4500</max-size>
<merge-policy>com.hazelcast.map.merge.LatestUpdateMapMergePolicy</merge-policy>
<!--<read-backup-data>true</read-backup-data>-->
<near-cache>
<in-memory-format>OBJECT</in-memory-format>
<cache-local-entries>true</cache-local-entries>
<time-to-live-seconds>86400</time-to-live-seconds>
<max-idle-seconds>1200</max-idle-seconds>
<invalidate-on-change>true</invalidate-on-change>
</near-cache>
</map>
</hazelcast>
從文檔中,我可以看到,每次打電話到Hazelcast,都會涉及到反序列化。因此,爲了優化調用,我們使用Kryo作爲默認序列化器並實現了接近緩存。我們必須將每個大小爲500KB的對象放入地圖中,並且在內存中可以有大約400-500個這樣的活動對象。我們經常在應用程序中使用緩存。
此前我們使用EhCache和配置爲緩存實現的JGroups。操作速度非常快。但是當我們嘗試使用Hazelcast時,我發現運行時間有相當大的差異。我可以不確定Hazelcast不僅僅是緩存實現。但只是想知道爲什麼操作與EhCache(使用jgroups)相比變得非常慢。我們所做的配置有問題嗎?請建議!
另請注意,我正在單節點機器上測試這個。
一個簡單的問題。我已將每個節點的最大大小定義爲4500.這是好嗎?我們在生產中有3個節點的羣集,默認情況下有271個分區,我將同時啓用同步和異步備份。因此,我將擁有270/3 = 90個分區傳輸主數據,其餘180個分區將備份其他節點的數據。我認爲我們每個分區最多可以保存50個元素,因此90 * 50 = 4500。這個配置是否正確?我怎麼知道每個分區可以存儲多少個元素? – PrasanthNath
沒有,您有271個數據分區,這些分區的副本最終在其他羣集節點上。這就是說:1備份= 271個數據分區+271備份分區 – noctarius
http://docs.hazelcast.org/docs/3.7/manual/html-single/index.html#data-partitioning從這個鏈接,我認爲節點將默認情況下有271個分區,這些分區將包含主分區和備份分區中的數據。就我而言,由於每個節點都有2個數據備份,我認爲每個節點只剩下約90個主分區。這不是這種情況嗎? – PrasanthNath