Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
<argument>-c</argument>
<argument>io.druid.extensions:druid-avro-extensions</argument>
<argument>-c</argument>
<argument>io.druid.extensions:druid-caffeine-cache</argument>
<argument>-c</argument>
<argument>io.druid.extensions:druid-datasketches</argument>
<argument>-c</argument>
<argument>io.druid.extensions:druid-hdfs-storage</argument>
Expand Down
3 changes: 2 additions & 1 deletion docs/_redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
{"source": "tutorials/tutorial-all-about-queries.html", "target": "quickstart.html"},
{"source": "tutorials/tutorial-loading-batch-data.html", "target": "tutorial-batch.html"},
{"source": "tutorials/tutorial-loading-streaming-data.html", "target": "tutorial-streams.html"},
{"source": "tutorials/tutorial-the-druid-cluster.html", "target": "cluster.html"}
{"source": "tutorials/tutorial-the-druid-cluster.html", "target": "cluster.html"},
{"source": "development/extensions-core/caffeine-cache.html", "target":"../../configuration/caching.html"}
]
39 changes: 39 additions & 0 deletions docs/content/configuration/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ for both broker and historical nodes, when defined in the common properties file

#### Local Cache

<div class="note caution">
DEPRECATED: Use caffeine instead
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 you please expand on this a little bit? Imagine a reader that doesn't know why it's deprecated, or when it will be removed, how urgent the switch is, and so on. Maybe something like:

The local cache is deprecated in favor of the Caffeine cache, and may be removed in a future version of Druid. The Caffeine cache affords better performance and control over eviction behavior, and is recommended in any situation where you are using JRE 8u60 or higher.

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.

added

The local cache is deprecated in favor of the Caffeine cache, and may be removed in a future version of Druid. The Caffeine cache affords significantly better performance and control over eviction behavior compared to local cache, and is recommended in any situation where you are using JRE 8u60 or higher.

</div>

The local cache is deprecated in favor of the Caffeine cache, and may be removed in a future version of Druid. The Caffeine cache affords significantly better performance and control over eviction behavior compared to `local` cache, and is recommended in any situation where you are using JRE 8u60 or higher.

A simple in-memory LRU cache. Local cache resides in JVM heap memory, so if you enable it, make sure you increase heap size accordingly.

|Property|Description|Default|
Expand All @@ -32,6 +38,39 @@ A simple in-memory LRU cache. Local cache resides in JVM heap memory, so if you
|`druid.cache.initialSize`|Initial size of the hashtable backing the cache.|500000|
|`druid.cache.logEvictionCount`|If non-zero, log cache eviction every `logEvictionCount` items.|0|

### Caffeine Cache

A highly performant local cache implementation for Druid based on [Caffeine](https://github.com/ben-manes/caffeine). Requires a JRE8u60 or higher if using `COMMON_FJP`.

##### Configuration

Below are the configuration options known to this module:

|`runtime.properties`|Description|Default|
|--------------------|-----------|-------|
|`druid.cache.type`| Set this to `caffeine`|`local`|
|`druid.cache.sizeInBytes`|The maximum size of the cache in bytes on heap.|None (unlimited)|
|`druid.cache.expireAfter`|The time (in ms) after an access for which a cache entry may be expired|None (no time limit)|
|`druid.cache.cacheExecutorFactory`|The executor factory to use for Caffeine maintenance. One of `COMMON_FJP`, `SINGLE_THREAD`, or `SAME_THREAD`|ForkJoinPool common pool (`COMMON_FJP`)|
|`druid.cache.evictOnClose`|If a close of a namespace (ex: removing a segment from a node) should cause an eager eviction of associated cache values|`false`|

##### `druid.cache.cacheExecutorFactory`

Here are the possible values for `druid.cache.cacheExecutorFactory`, which controls how maintenance tasks are run

* `COMMON_FJP` (default) use the common ForkJoinPool. Should use with [JRE 8u60 or higher](https://github.com/druid-io/druid/pull/4810#issuecomment-329922810). Older versions of the JRE may have worse performance than newer JRE versions.
* `SINGLE_THREAD` Use a single-threaded executor.
* `SAME_THREAD` Cache maintenance is done eagerly.

#### Metrics
In addition to the normal cache metrics, the caffeine cache implementation also reports the following in both `total` and `delta`

|Metric|Description|Normal value|
|------|-----------|------------|
|`query/cache/caffeine/*/requests`|Count of hits or misses|hit + miss|
|`query/cache/caffeine/*/loadTime`|Length of time caffeine spends loading new values (unused feature)|0|
|`query/cache/caffeine/*/evictionBytes`|Size in bytes that have been evicted from the cache|Varies, should tune cache `sizeInBytes` so that `sizeInBytes`/`evictionBytes` is approximately the rate of cache churn you desire|


#### Memcached

Expand Down
39 changes: 0 additions & 39 deletions docs/content/development/extensions-core/caffeine-cache.md

This file was deleted.

68 changes: 0 additions & 68 deletions extensions-core/caffeine-cache/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<!-- Cannot update to AWS SDK 1.11+ because of Jackson incompatibility.
Need to update Druid to use Jackson 2.6+ -->
<aws.sdk.version>1.10.77</aws.sdk.version>
<caffeine.version>2.5.5</caffeine.version>
</properties>

<modules>
Expand All @@ -100,7 +101,6 @@
<module>hll</module>
<!-- Core extensions -->
<module>extensions-core/avro-extensions</module>
<module>extensions-core/caffeine-cache</module>
<module>extensions-core/datasketches</module>
<module>extensions-core/druid-kerberos</module>
<module>extensions-core/hdfs-storage</module>
Expand Down Expand Up @@ -744,6 +744,11 @@
<version>${calcite.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>${caffeine.version}</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>

<!-- Tests -->
<dependency>
Expand Down
5 changes: 3 additions & 2 deletions server/src/main/java/io/druid/client/cache/CacheProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.inject.Provider;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = LocalCacheProvider.class)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = CaffeineCacheProvider.class)
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 you please edit the first comment of this PR to indicate that you do want to change the default? This threw me for a loop since it said you weren't going to, and I hadn't read the conversation between you and Ben yet where you changed your mind.

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

@JsonSubTypes(value = {
@JsonSubTypes.Type(name = "local", value = LocalCacheProvider.class),
@JsonSubTypes.Type(name = "memcached", value = MemcachedCacheProvider.class),
@JsonSubTypes.Type(name = "hybrid", value = HybridCacheProvider.class)
@JsonSubTypes.Type(name = "hybrid", value = HybridCacheProvider.class),
@JsonSubTypes.Type(name = "caffeine", value = CaffeineCacheProvider.class)
})
public interface CacheProvider extends Provider<Cache>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

package io.druid.client.cache;

import com.fasterxml.jackson.annotation.JsonTypeName;

@JsonTypeName("caffeine")
public class CaffeineCacheProvider extends CaffeineCacheConfig implements CacheProvider
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import javax.validation.constraints.Min;

/**
* Deprecated, use {@CaffeineCacheProvider}
*/
@Deprecated
public class LocalCacheProvider implements CacheProvider
{
@JsonProperty
Expand Down