Skip to content

Implement Redis cache extension#1937

Closed
estliberitas wants to merge 1 commit intoapache:masterfrom
estliberitas:redis-cache
Closed

Implement Redis cache extension#1937
estliberitas wants to merge 1 commit intoapache:masterfrom
estliberitas:redis-cache

Conversation

@estliberitas
Copy link
Copy Markdown
Contributor

This is a first working draft of extension. It provides basic caching functionality and cache statistics, while doMonitor() still does nothing(). Data is compressed using LZ4.

This is to resolve #1927.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be useful to share the code with memcached cache here instead of having two different implementation, unless there is a good reason to have two different ones.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of CacheUtils class to put serialize / deserialize stuff in druid-processing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, something along those lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xvrl there is already a class called CacheUtil, can it be used for purpose described above? Or these things worth another utility class which to reside in druid-processing?

This CacheUtil class has quite a few methods right now. Maybe it's a good idea to extend it with those methods?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xvrl will use existing CacheUtil then )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CacheUtils seems fine to me, unless you want to have it as part of io.druid.client.cache, in which case we can call it CacheImplUtils or something

@estliberitas
Copy link
Copy Markdown
Contributor Author

@xvrl Thanks for reviewing and notes, I'll make all the additions tomorrow thus very busy today.

@xvrl
Copy link
Copy Markdown
Member

xvrl commented Nov 10, 2015

@estliberitas no worries, take your time.

@estliberitas
Copy link
Copy Markdown
Contributor Author

@xvrl can you answer a question about CacheUtils above?

Also, about sharding, are we talking about Sentinel or Cluster which is in development as far as I remember?

@xvrl
Copy link
Copy Markdown
Member

xvrl commented Nov 24, 2015

@estliberitas
Regarding sharding, I meant client-side sharding, i.e. similar to what we do on the memcached side.
We simply run multiple independent cache nodes, and have the client distribute the keys.
We use the built-in ketama factory in spymemcached https://github.com/couchbase/spymemcached/blob/master/src/main/java/net/spy/memcached/KetamaConnectionFactory.java for consistent hashing on the memcached side

Regarding CacheUtil, see my answer above.

@estliberitas
Copy link
Copy Markdown
Contributor Author

@xvrl As far as I know, Jedis has nothing similar to this. So I'm gonna implement it or extend some pool class which would given a key pickup client by hash.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be removed according to the contrib-guide

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@xvrl
Copy link
Copy Markdown
Member

xvrl commented Nov 24, 2015

@estliberitas it looks like jedis supports client-side sharding using something that looks like ketama https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/ShardedJedis.java
https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/util/Sharded.java

I would just use that and use murmurhash to be consistent with the memcached configuration.

@estliberitas
Copy link
Copy Markdown
Contributor Author

@xvrl Sounds reasonable, thanks, I'll use it!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@b-slim what about it?

@thedrow
Copy link
Copy Markdown

thedrow commented Dec 1, 2015

This needs to be rebased FYI.

@estliberitas
Copy link
Copy Markdown
Contributor Author

@thedrow @b-slim Thanks for pointing, guys. I'm on my way to German work visa and as soon as I visit consulate I'll have enough time then to rebase, reformat, implement, etc. )

@fjy
Copy link
Copy Markdown
Contributor

fjy commented Dec 3, 2015

@xvrl @b-slim do u guys have more comments?

@estliberitas
Copy link
Copy Markdown
Contributor Author

Finally got the time for contribution again. Will have something by end of week or so.

@fjy
Copy link
Copy Markdown
Contributor

fjy commented Jan 7, 2016

@estliberitas any chance of finishing this up?

@estliberitas
Copy link
Copy Markdown
Contributor Author

@fjy yep. Let me check what needs to be done.

@estliberitas
Copy link
Copy Markdown
Contributor Author

@xvrl @fjy One thing left is client-side sharding.

@estliberitas
Copy link
Copy Markdown
Contributor Author

@xvrl @fjy Please, check out, guys. You can see that using of ShardedJedis from other side makes us at least for now forget about MGET and DEL with multiple arguments because of key distribution.

Also, for each namespace there is a set with keys, so close(namespace) reads members of namespace set and deletes those keys plus set itself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing license header

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@estliberitas
Copy link
Copy Markdown
Contributor Author

@drcrallen Updated with question about jackson-annotations

@estliberitas
Copy link
Copy Markdown
Contributor Author

Travis build failed somehow, but output says SUCCESS everywhere.

Also implemented `CacheImplUtils` to share functionality with Memcached
cache extension.
@estliberitas
Copy link
Copy Markdown
Contributor Author

@drcrallen @fjy Guys, I put <scope>provided</scope> in every commented line so, now it's gonna be OK. Check, plz.

@fjy
Copy link
Copy Markdown
Contributor

fjy commented Feb 24, 2016

@drcrallen going to merge this in 24 hours and then refactor extensions

@drcrallen
Copy link
Copy Markdown
Contributor

@fjy You had a thumbs up and I didn't see anything from xavier yet, though I haven't heard any complaints from him yet either. Didn't realized this was blocked on me instead of xavier. Merging to a extensions.contrib should be good.

@fjy fjy modified the milestones: 0.9.2, 0.9.1 Feb 26, 2016
@fjy
Copy link
Copy Markdown
Contributor

fjy commented Feb 26, 2016

@xvrl just realized this isn't a module...

Are the caches extendable?

@estliberitas
Copy link
Copy Markdown
Contributor Author

@fjy Well, I can try make them truly extendable. Like introduce interfaces in appropriate module (druid-api? druid-processing?) and change existing implementations. Or what do you mean?

@drcrallen
Copy link
Copy Markdown
Contributor

@fjy
Copy link
Copy Markdown
Contributor

fjy commented Feb 26, 2016

@estliberitas I mean like one of the modules in the extensions directory

@estliberitas
Copy link
Copy Markdown
Contributor Author

@fjy And now I don't get at all 😄 So this cache extension is in extensions directory. And it's a separate Maven module.

@estliberitas
Copy link
Copy Markdown
Contributor Author

@fjy what should I do next? Rebase / put into another repo?

@fjy
Copy link
Copy Markdown
Contributor

fjy commented May 1, 2016

@estliberitas is it possible for this work to be done as a extension in the extensions-contrib folder?

@estliberitas
Copy link
Copy Markdown
Contributor Author

@fjy it's your project, man, you are the one to answer )) so now I know, I should move it and rebase based on the new way of handling extensions. thanks

@fjy
Copy link
Copy Markdown
Contributor

fjy commented May 16, 2016

@estliberitas can you please update this PR such that the code is contained in an extension-contrib module similar to other community contributed extensions?

Apologies for the delay in reviewing this, we are extremely backed up in reviewing PRs.

|`druid.cache.maxObjectSize`|Maximum object size in bytes for a Memcached object.|52428800 (50 MB)|
|`druid.cache.memcachedPrefix`|Key prefix for all keys in Memcached.|druid|

#### Redis
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have these docs in a separate file similar to how the other extensions are structured?

Can we also update the extensions.md file to include the new redis extension?

@fjy
Copy link
Copy Markdown
Contributor

fjy commented Jun 15, 2016

@estliberitas there are merge conflicts and let's make sure this is set up similar to the other extensions in extensions-contrib

@fjy fjy modified the milestones: 0.9.3, 0.9.2 Jun 22, 2016
@fjy
Copy link
Copy Markdown
Contributor

fjy commented Nov 8, 2016

Removing milestone as this PR appears to be abandoned

@fjy fjy removed this from the 0.9.3 milestone Nov 8, 2016
@estliberitas
Copy link
Copy Markdown
Contributor Author

@fjy gonna continue working on it. Hopefully, not that much in code base has changed.

@drcrallen
Copy link
Copy Markdown
Contributor

Closing to see if #4615 can get through

@drcrallen drcrallen closed this Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement cache module for Redis

6 participants