I am using spring-data-redis as the data access layer for Redis, for the data distribution, I tried to use the sharding feature of jedis, but looks spring-data-redis DOES NOT support sharding officially, is there any workaround or 3rd party library can support sharding by spring-data-reids?
thanks,
Emre
I've used twemproxy successfully to shard data across several redis nodes.
I used spring-data-redis as well as others (non java) clients to access it. Since twemproxy 'speaks' the redis protocol, it is (almost) transparent for the clients.
Related
I have a requirement to develop some new feature in a given application which is currently using Jedis for redis operations.
I need to use Redis locks extensively for the new feature and redisson supports them very well.Can I use Redisson client with same redis cluster in my application or will it cause an issue?
The new flow is entirely different and there will be no interesction between operations through redisson and Jedis
regards
Ankit
You can use Redisson along with Jedis with same Redis cluster in same application. This should not cause any problem.
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
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.
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.
We are currently using ehcache : SimplePageCachingFilter to perform webpage caching.
Now we have decided to move on to Hazelcast for our caching and i couldn't find any information related to Web Page caching in HazelCast documentation.
Does Hazel cast support Web Caching?
Any help will be highly appreciated.
Thanks..
Oh yes most definitely.
Hazelcast has many modes of support for web caching...
http://www.hazelcast.org/use-cases/caching/
I assume you are interested in the distributed cache? Hazelcast can be used as a form of elastic Memcached and it supports that protocol natively.
Or you can work more closely with the application and can use it has a Hibernate L2 cache or within spring as a spring cache.
If you explain more about what you're trying to do, it's likely that Hazelcast can be used to achieve that, as Caching is a core use case for Hazelcast.