spring security redis token store in clustered redis - spring

I am trying to deploy a spring-security server, with Redis as token store.
In order to have some redundancy in Redis, we want to deploy it as a cluster.
The problem is Jedis, which is used by spring security as underlying library, doesn't support pipelining in cluster mode, but spring security uses pipelining.
My question is how can I solve this situation. More precisely:
1- Should I use another mode of deployment form Redis? What actually works.
2- Can I somehow force spring security to use reddison for connecting to Resid?
Please adivse.

If you want redundancy, use replication (master/slave) not cluster.
If you have more data than RAM on a machine, use cluster.
If you have more data than RAM on a machine and want redundancy, use cluster with replication.
Jedis supports replication with sentinel, so give that a go unless you have a lot of data. Some more info on usage here: https://github.com/xetorthio/jedis/issues/725

Related

Access to Redis Cluster via Single Endpoint

I have a application using Redis. This system implemented with java spring used jedis package for connection to the redis with the configuration as follow
jedis.pool.host=redisServer-IP
so the application connect to redis server on the redisServer-IP and works fine but, for the lack of memory on a single server and and HA capability I need to use a redis cluster I used docker compose to create a redis cluster using the here.
Also redis cluster working fine with three masters and three replicas.
I just need to understand, the Redis Cluster can work with the single endpoint, because I can only set single endpoint in the above jedis.pool.host configuration, or I need to have a proxy to deal with the redis cluster ?
NOTE: I can not make any changes in my application

communication between spring instances behind a load balancer

I have a few instances of Spring apps running behind a load balancer. I am using EHCache as a caching system on each of these instances.
Let's say I receive a request that is refreshing a part of the cache on one instance. I need a way to tell the other instances to refresh their cache (or to replicate it).
I'm more interested in a solution based on Spring and not just cache replication and that's because there are other scenarios similar with this one that require the same solution.
How can I achieve this?
There is no simple Spring solution for this. Depends on the requirements. You can use any kind of PubSub like a JMS topic to notify your nodes. This way the problem can be that you cannot guarantee consistency. The other nodes can still read the old data for a while. In my current project we use Redis. We configured it as cache with Spring Data Redis and theres no need to notify the other nodes since the cache is shared. In non cache scenarios we also use redis as a PubSub service.

Redis or Hazelcast, or others?

I took an old web application recently. The App will save a lot of object into Ehcache at init time.And then obtain the object from the cache. And now, the object has increased many times. Ehcache in the app can not meet the requirement. So, we consider using a distributed cache. We will set some strategies and let the objects save in different cache server.
Redis and Hazelcast are both good. Question is, the Redis and Hazelcast compared to the previous Ehcache, Redis and Hazelcast must Serialize objects. May be it will consume more time.
So which is better?
Or are there no other better alternatives?
Thanks in advance.
What are your requirements? Hazelcast has pluggable serialization and there are serialization libraries like FlatBuffers that are exceedingly fast if needed.
Hazelcast is ideal if you are Java centric, of course you can also access Hazelcast via .Net CLR languages if you are using Hazelcast Enterprise.
Hazelcast is more than just a simple distributed cache, you can also leverage the distributed CPUs in your cluster and execute processes directly in the grid, which can result in very high performance.
If you are multi-language and dont need to execute code on top of distributed data (in-memory executor service, mapreduce or entryprocessors) Redis would make sense.
Have a look at Redisson - Redis based In-Memory Data Grid is a good alternative for Ehcache. Provides a lot data serialization codecs like:
Jackson JSON, Avro, Smile, CBOR, MsgPack, Amazon Ion, Kryo, JDK Serialization, LZ4 and Snappy.
It also allows to store Map data in external storage along with Redis store using Read-through, Write-through and Write-behind strategies.
Offers distributed MapReduce and Executor/Scheduler services.

Cache Replication in Clustered Environment using EHCache JGroups

I am using EhCache framework to cache application data and thinking to use JGroups cache replication to replicate cache in a clustered environment.
Is it really an industry standard for cache replication in clustered environment? Or, there can be other better options that I should think about. Please notice that I am not using any centralized cache server at this point of time. I have already done POC on JGroups Cache Replication. Could you please share your experience in terms of its robustness and major concerns? What are the pros cons of using JGroups for cache replication?
I am using Jgroups for clustering various application nodes. We have our own cache implementation which uses the underlying Jgroups for data replication/distribution. So far it is working fine without issues.
Could you please check 'infinispan'. It's a distributed cache which uses Jgroups for handling cluster.

enable hibernate app to use clustered hazelcast

our prod environment architecture is decided to be like this:
2 machines that each of them have 2 tomcat instances (on vm). there is spring web app with hibernate running on tomcat.
there are also 2 db instances distributed to both machines.
so, we think that hazelcast fits this achitecture well. hazelcast will be second level cache for hibernate, it will manage clustered cache over db instances.
we installed hibernate server and defined our clusters on it.
i've searched offical hazelcast doc and several sites but i couldnt find the way to configure hibernate to use this hazelcast server as L2 cache.
we dont want to change our existing app. we'll keep using hibernate as it is. is it possible? if so, how we can configure hazelcast server on our web app?
I think it is important to understand that your probably don't want to have a standalone Hazelcast cluster/server; what you normally do is to embed Hazelcast within your application.
Like Miko said, you can just enable Hazelcast to be used as second level cache; no need to make any fundamental changes.
I also don't understand what you mean with 'hibernate server', because Hibernate is just an OR mapper library and has no concept of server.
So can you tell a bit more what you want so we can help you out?

Resources