Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We use cluster mode, but always have a cache hit rate of 50%. Do you know why? #136

Open
huaism opened this issue Aug 29, 2019 · 6 comments

Comments

@huaism
Copy link

huaism commented Aug 29, 2019

image

@huaism
Copy link
Author

huaism commented Aug 29, 2019

Even if we visit the same KEY multiple times, this result is

@4fath
Copy link

4fath commented Jul 4, 2020

@huaism how did you get that fancy output?

@huaism
Copy link
Author

huaism commented Jul 9, 2020

@4fath
link : https://github.com/junegunn/redis-stat

@NitinK91
Copy link

Hi @huaism , can you please provide the config to implement redis cache using redis-cluster.

@huaism
Copy link
Author

huaism commented Aug 19, 2020

HI @NitinK91

hibernate redis

hibernate.cache.region.factory_class=org.hibernate.cache.redis.hibernate52.SingletonRedisRegionFactory
hibernate.cache.region_prefix=hibernate
hibernate.cache.use_structured_entries=true
hibernate.cache.use_query_cache=false
hibernate.cache.use_second_level_cache=true
hibernate.cache.provider_configuration_file_resource_path=hibernate-redis.properties

hibernate-redis.properties

redisson-config=classpath:redisson.yaml
redis.expiryInSeconds.default=0

redisson.yaml

clusterServersConfig:
idleConnectionTimeout: 10000
pingTimeout: 1000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
reconnectionTimeout: 3000
failedAttempts: 3
password: null
subscriptionsPerConnection: 5
clientName: null
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
slaveSubscriptionConnectionMinimumIdleSize: 1
slaveSubscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 10
slaveConnectionPoolSize: 64
masterConnectionMinimumIdleSize: 10
masterConnectionPoolSize: 64
readMode: "MASTER_SLAVE"
nodeAddresses:

  • "redis://192.168.199.42:6300"
  • "redis://192.168.199.42:6301"
  • "redis://192.168.199.42:6302"
  • "redis://192.168.199.42:6303"
  • "redis://192.168.199.42:6304"
  • "redis://192.168.199.42:6305"
    scanInterval: 10000
    threads: 0
    nettyThreads: 0
    codec: !<org.redisson.codec.FstCodec> {}
    useLinuxNativeEpoll: false

@NitinK91
Copy link

Thanks @huaism for sharing.

I am facing an issue. Can you help.
It is giving following error::

java.lang.IllegalArgumentException: port out of range:-1
at java.net.InetSocketAddress.checkPort(InetSocketAddress.java:143)
at java.net.InetSocketAddress.(InetSocketAddress.java:224)
at org.redisson.client.RedisClient.(RedisClient.java:93)
at org.redisson.connection.MasterSlaveConnectionManager.createClient(MasterSlaveConnectionManager.java:310)
at org.redisson.cluster.ClusterConnectionManager.connect(ClusterConnectionManager.java:150)
at org.redisson.cluster.ClusterConnectionManager.(ClusterConnectionManager.java:81)
at org.redisson.config.ConfigSupport.createConnectionManager(ConfigSupport.java:172)
at org.redisson.Redisson.(Redisson.java:103)
at org.redisson.Redisson.create(Redisson.java:133)

Actually it not generating ClientPartition.getMasterAddress() properly.
Address is //127.0.0.1:8001@18001 as recorded by CLUSTER_NODES, but it reads it as host: 18001 and port=-1.

Cluster config deom CLUSTER_NODES::
[ClusterNodeInfo [nodeId=4317f285b359ddc3ac08bb85239924509146e475, address=//127.0.0.1:8003@18003, flags=[SLAVE], slaveOf=4118a348827e6107d7e35522a251fd39c5a8f82b, slotRanges=[]], ClusterNodeInfo [nodeId=2f7b93c80d3721b3fb26fe87bc28ed04a63fe0ec, address=//127.0.0.1:8005@18005, flags=[SLAVE], slaveOf=8b81c3e1acb4e1959a83267540058d1a6bffa12f, slotRanges=[]], ClusterNodeInfo [nodeId=4118a348827e6107d7e35522a251fd39c5a8f82b, address=//127.0.0.1:8001@18001, flags=[MASTER], slaveOf=null, slotRanges=[[5461-10922]]], ClusterNodeInfo [nodeId=a0770863d893a5b8106a83e247cea2544f99ef36, address=//127.0.0.1:8004@18004, flags=[SLAVE], slaveOf=6b9da1bbe38b978a3017406e5c1e310f4706cfc8, slotRanges=[]], ClusterNodeInfo [nodeId=8b81c3e1acb4e1959a83267540058d1a6bffa12f, address=//127.0.0.1:8000@18000, flags=[MYSELF, MASTER], slaveOf=null, slotRanges=[[0-5460]]], ClusterNodeInfo [nodeId=6b9da1bbe38b978a3017406e5c1e310f4706cfc8, address=//127.0.0.1:8002@18002, flags=[MASTER], slaveOf=null, slotRanges=[[10923-16383]]]]

My code is ::
Config config = new Config();
config.useClusterServers()
.addNodeAddress("redis://127.0.0.1:8000");
RedissonClient redisson = Redisson.create(config);

    RMap<String, String> map = redisson.getMap("simpleMap");
    map.put("mapKey", "This is a map value");
    String mapValue = map.get("mapKey");
    System.out.println("stored map value: " + mapValue);
    redisson.shutdown();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants