blob: f67b9297831caaea64b80e82c8829a6e0a64035d [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[5475],{3905:(e,t,n)=>{n.d(t,{Zo:()=>s,kt:()=>k});var a=n(67294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},l=Object.keys(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var d=a.createContext({}),p=function(e){var t=a.useContext(d),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},s=function(e){var t=p(e.components);return a.createElement(d.Provider,{value:t},e.children)},c="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,d=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),c=p(n),m=r,k=c["".concat(d,".").concat(m)]||c[m]||u[m]||l;return n?a.createElement(k,i(i({ref:t},s),{},{components:n})):a.createElement(k,i({ref:t},s))}));function k(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,i=new Array(l);i[0]=m;var o={};for(var d in t)hasOwnProperty.call(t,d)&&(o[d]=t[d]);o.originalType=e,o[c]="string"==typeof e?e:r,i[1]=o;for(var p=2;p<l;p++)i[p]=n[p];return a.createElement.apply(null,i)}return a.createElement.apply(null,n)}m.displayName="MDXCreateElement"},43764:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>d,default:()=>k,frontMatter:()=>o,metadata:()=>p,toc:()=>c});var a=n(87462),r=n(63366),l=(n(67294),n(3905)),i=["components"],o={id:"redis-cache",title:"Druid Redis Cache"},d=void 0,p={unversionedId:"development/extensions-contrib/redis-cache",id:"development/extensions-contrib/redis-cache",title:"Druid Redis Cache",description:"\x3c!--",source:"@site/docs/latest/development/extensions-contrib/redis-cache.md",sourceDirName:"development/extensions-contrib",slug:"/development/extensions-contrib/redis-cache",permalink:"/docs/latest/development/extensions-contrib/redis-cache",draft:!1,tags:[],version:"current",frontMatter:{id:"redis-cache",title:"Druid Redis Cache"}},s={},c=[{value:"Installation",id:"installation",level:2},{value:"Enabling",id:"enabling",level:2},{value:"Configuration",id:"configuration",level:2},{value:"Cluster mode",id:"cluster-mode",level:3},{value:"Example",id:"example",level:4},{value:"Standalone mode",id:"standalone-mode",level:3},{value:"Shared Properties",id:"shared-properties",level:3},{value:"Metrics",id:"metrics",level:2}],u={toc:c},m="wrapper";function k(e){var t=e.components,n=(0,r.Z)(e,i);return(0,l.kt)(m,(0,a.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,l.kt)("p",null,"A cache implementation for Druid based on ",(0,l.kt)("a",{parentName:"p",href:"https://github.com/redis/redis"},"Redis"),"."),(0,l.kt)("p",null,"Below are guidance and configuration options known to this module."),(0,l.kt)("h2",{id:"installation"},"Installation"),(0,l.kt)("p",null,"Use ",(0,l.kt)("a",{parentName:"p",href:"/docs/latest/operations/pull-deps"},"pull-deps")," tool shipped with Druid to install this ",(0,l.kt)("a",{parentName:"p",href:"/docs/latest/configuration/extensions#community-extensions"},"extension")," on broker, historical and middle manager nodes."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},'java -classpath "druid_dir/lib/*" org.apache.druid.cli.Main tools pull-deps -c org.apache.druid.extensions.contrib:druid-redis-cache:{VERSION}\n')),(0,l.kt)("h2",{id:"enabling"},"Enabling"),(0,l.kt)("p",null,"To enable this extension after installation,"),(0,l.kt)("ol",null,(0,l.kt)("li",{parentName:"ol"},(0,l.kt)("a",{parentName:"li",href:"/docs/latest/configuration/extensions#loading-extensions"},"include")," this ",(0,l.kt)("inlineCode",{parentName:"li"},"druid-redis-cache")," extension"),(0,l.kt)("li",{parentName:"ol"},"to enable cache on broker nodes, follow ",(0,l.kt)("a",{parentName:"li",href:"/docs/latest/configuration/#broker-caching"},"broker caching docs")," to set related properties"),(0,l.kt)("li",{parentName:"ol"},"to enable cache on historical nodes, follow ",(0,l.kt)("a",{parentName:"li",href:"/docs/latest/configuration/#historical-caching"},"historical caching docs")," to set related properties"),(0,l.kt)("li",{parentName:"ol"},"to enable cache on middle manager nodes, follow ",(0,l.kt)("a",{parentName:"li",href:"/docs/latest/configuration/#peon-caching"},"peon caching docs")," to set related properties"),(0,l.kt)("li",{parentName:"ol"},"set ",(0,l.kt)("inlineCode",{parentName:"li"},"druid.cache.type")," to ",(0,l.kt)("inlineCode",{parentName:"li"},"redis")),(0,l.kt)("li",{parentName:"ol"},"add the following properties")),(0,l.kt)("h2",{id:"configuration"},"Configuration"),(0,l.kt)("h3",{id:"cluster-mode"},"Cluster mode"),(0,l.kt)("p",null,"To utilize a redis cluster, following properties must be set."),(0,l.kt)("p",null,"Note: some redis cloud service providers provide redis cluster service via a redis proxy, for these clusters, please follow the ",(0,l.kt)("a",{parentName:"p",href:"#standalone-mode"},"Standalone mode")," configuration below."),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",{parentName:"tr",align:null},"Properties"),(0,l.kt)("th",{parentName:"tr",align:null},"Description"),(0,l.kt)("th",{parentName:"tr",align:null},"Default"),(0,l.kt)("th",{parentName:"tr",align:null},"Required"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.cluster.nodes")),(0,l.kt)("td",{parentName:"tr",align:null},"Redis nodes in a cluster, represented in comma separated string. See example below"),(0,l.kt)("td",{parentName:"tr",align:null},"None"),(0,l.kt)("td",{parentName:"tr",align:null},"yes")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.cluster.maxRedirection")),(0,l.kt)("td",{parentName:"tr",align:null},"Max retry count"),(0,l.kt)("td",{parentName:"tr",align:null},"5"),(0,l.kt)("td",{parentName:"tr",align:null},"no")))),(0,l.kt)("h4",{id:"example"},"Example"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-properties"},"# a typical redis cluster with 6 nodes\ndruid.cache.cluster.nodes=127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003,127.0.0.1:7004,127.0.0.1:7005,127.0.0.1:7006\n")),(0,l.kt)("h3",{id:"standalone-mode"},"Standalone mode"),(0,l.kt)("p",null,"To use a standalone redis, following properties must be set."),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",{parentName:"tr",align:null},"Properties"),(0,l.kt)("th",{parentName:"tr",align:null},"Description"),(0,l.kt)("th",{parentName:"tr",align:null},"Default"),(0,l.kt)("th",{parentName:"tr",align:null},"Required"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.host")),(0,l.kt)("td",{parentName:"tr",align:null},"Redis server host"),(0,l.kt)("td",{parentName:"tr",align:null},"None"),(0,l.kt)("td",{parentName:"tr",align:null},"yes")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.port")),(0,l.kt)("td",{parentName:"tr",align:null},"Redis server port"),(0,l.kt)("td",{parentName:"tr",align:null},"None"),(0,l.kt)("td",{parentName:"tr",align:null},"yes")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.database")),(0,l.kt)("td",{parentName:"tr",align:null},"Redis database index"),(0,l.kt)("td",{parentName:"tr",align:null},"0"),(0,l.kt)("td",{parentName:"tr",align:null},"no")))),(0,l.kt)("p",null,"Note: if both ",(0,l.kt)("inlineCode",{parentName:"p"},"druid.cache.cluster.nodes")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"druid.cache.host")," are provided, cluster mode is preferred."),(0,l.kt)("h3",{id:"shared-properties"},"Shared Properties"),(0,l.kt)("p",null,"Except for the properties above, there are some extra properties which can be customized to meet different needs."),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",{parentName:"tr",align:null},"Properties"),(0,l.kt)("th",{parentName:"tr",align:null},"Description"),(0,l.kt)("th",{parentName:"tr",align:null},"Default"),(0,l.kt)("th",{parentName:"tr",align:null},"Required"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.password")),(0,l.kt)("td",{parentName:"tr",align:null},"Password to access redis server/cluster"),(0,l.kt)("td",{parentName:"tr",align:null},"None"),(0,l.kt)("td",{parentName:"tr",align:null},"no")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.expiration")),(0,l.kt)("td",{parentName:"tr",align:null},"Expiration for cache entries"),(0,l.kt)("td",{parentName:"tr",align:null},"P1D"),(0,l.kt)("td",{parentName:"tr",align:null},"no")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.timeout")),(0,l.kt)("td",{parentName:"tr",align:null},"Timeout for connecting to Redis and reading entries from Redis"),(0,l.kt)("td",{parentName:"tr",align:null},"PT2S"),(0,l.kt)("td",{parentName:"tr",align:null},"no")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.maxTotalConnections")),(0,l.kt)("td",{parentName:"tr",align:null},"Max total connections to Redis"),(0,l.kt)("td",{parentName:"tr",align:null},"8"),(0,l.kt)("td",{parentName:"tr",align:null},"no")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.maxIdleConnections")),(0,l.kt)("td",{parentName:"tr",align:null},"Max idle connections to Redis"),(0,l.kt)("td",{parentName:"tr",align:null},"8"),(0,l.kt)("td",{parentName:"tr",align:null},"no")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"druid.cache.minIdleConnections")),(0,l.kt)("td",{parentName:"tr",align:null},"Min idle connections to Redis"),(0,l.kt)("td",{parentName:"tr",align:null},"0"),(0,l.kt)("td",{parentName:"tr",align:null},"no")))),(0,l.kt)("p",null,"For ",(0,l.kt)("inlineCode",{parentName:"p"},"druid.cache.expiration")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"druid.cache.timeout")," properties, values can be format of ",(0,l.kt)("inlineCode",{parentName:"p"},"Period")," or a number in milliseconds."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-properties"},"# Period format(recomended)\n# cache expires after 1 hour\ndruid.cache.expiration=PT1H\n\n# or in number(milliseconds) format\n# 1 hour = 3_600_000 milliseconds\ndruid.cache.expiration=3600000\n")),(0,l.kt)("h2",{id:"metrics"},"Metrics"),(0,l.kt)("p",null,"In addition to the normal cache metrics, the redis cache implementation also reports the following in both ",(0,l.kt)("inlineCode",{parentName:"p"},"total")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"delta")),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",{parentName:"tr",align:null},"Metric"),(0,l.kt)("th",{parentName:"tr",align:null},"Description"),(0,l.kt)("th",{parentName:"tr",align:null},"Normal value"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},(0,l.kt)("inlineCode",{parentName:"td"},"query/cache/redis/*/requests")),(0,l.kt)("td",{parentName:"tr",align:null},"Count of requests to redis cache"),(0,l.kt)("td",{parentName:"tr",align:null},"whatever request to redis will increase request count by 1")))))}k.isMDXComponent=!0}}]);