redisson icon indicating copy to clipboard operation
redisson copied to clipboard

Redissonspringlocalcache manager in distributed systems

Open Himanshu4 opened this issue 8 years ago • 5 comments

Hi I have read about the redissonspringlocalcache manager that it is keeping a local cache backed by redis. Please correct me if I am wrong. Please tell me how it works in distributed mode.

Eg. If we have 10 ec2 instances deployed connecting to same redis. Suppose there is a case which has been invalidated by one machine. How early can the other 9 machines would be knowing that their local cache is invalid and they need to call the redis to update it.

Do it use background polling to check if it is enabled.?

Himanshu4 avatar Feb 03 '18 16:02 Himanshu4

Hi!

I have just updated Spring Local Cache configuration example on wiki page. As you can see there is a new syncStrategy setting. It has two options:

INVALIDATE - Default. Invalidate cache entry across all LocalCachedMap instances on map entry change UPDATE - Update cache entry across all LocalCachedMap instances on map entry change

In both cases synchronization works in almost real-time mode using Redis PubSub invoked on each local cache change operation.

mrniko avatar Feb 03 '18 17:02 mrniko

So do the application need to allocate resources/connection for these pubsub mechanism? If yes, Is there any recommendations?

Himanshu4 avatar Feb 03 '18 18:02 Himanshu4

One pussub subscription is used per Spring Local Cache instance. Total maximum subscriptions for Redisson are counted as subscriptionsPerConnection*subscriptionConnectionPoolSize

mrniko avatar Feb 05 '18 05:02 mrniko

Do these Ec2 instances subscribe to redis master / redis slave? Is there any way to provide configuration to redisson to create these subscriptions on slaves/master

Himanshu4 avatar Feb 07 '18 19:02 Himanshu4

subscriptionMode setting allows you to select which type of node use for subscription https://github.com/redisson/redisson/wiki/2.-Configuration#subscriptionmode

mrniko avatar Feb 08 '18 05:02 mrniko